EE 1106: Introduction to EE
Freshman Practicum
Lab-Lecture: Nonlinear circuit
elements, LABVIEW review and
MSP 430 Programming
Dan O. Popa, Freshman Practicum, Spring 2015
Nonlinear Circuit Elements- Transistor
Dan O. Popa, Freshman Practicum, Spring 2015
Image Sources: Textbook
The Operational Amplifier
The op amp is built using VLSI techniques. The circuit
diagram of an LM 741 from TI is
shown below.
Vp(+)
Vn(-)
Taken from TI
data sheet as
shown on the
web.
Vcc+
Vo
VccDan O. Popa, Freshman Practicum, Spring 2015
Transistor use: Digital Inverter
Dan O. Popa, Freshman Practicum, Spring 2015
D/A and A/D conversion
Dan O. Popa, Freshman Practicum, Spring 2015
Digital to Analog Converter (DAC)
n=4, G=-0.5
Dan O. Popa, Freshman Practicum, Spring 2015
Digital to Analog Converter (DAC)
and the Process of Sampling
Dan O. Popa, Freshman Practicum, Spring 2015
Analog to Digital Converter using a DAC
Dan O. Popa, Freshman Practicum, Spring 2015
Analog to Digital Converter (ADC)
Sample and Hold Circuit
Dan O. Popa, Freshman Practicum, Spring 2015
Texas Instruments MSP430 LaunchPad
•
The LaunchPad development
board features:
– 14-/20-pin DIP (N) socket
– Built-in flash emulation for
debugging and programming
– 2 programmable LEDs
– 1 power LED
– 1 programmable button
– 1 reset button
•
•
Includes one mini USB cable to
interface with a PC.
MSP430G2553IN20 – 16kB
Flash, 512B RAM, interruptible
GPIOs (capacitive sensecapable), 16-bit timers, 8ch 10bit ADC, Comparator, Serial
Communication (USCI – I2C,
SPI & UART) & more
Dan O. Popa, Freshman Practicum, Spring 2015
Programming Constructs
Data Types
- Primitives (Integer, Float, etc)
- Const, Var, Pointer
- Complex (Lists, arrays, etc.)
- Register values (tied to hardware)
- Timer (clocks, tied to hardware)
Operations on data
- +, - , =, etc.
Control Statements
- If, case (conditional)
- While, For (loops)
Function calls
- User defined
- Main ()
- MSP 430 specific: ex. ConfigureADC
10
Microcontroller Programming in C
(Labs 10,11,12)
while(1)
{
ADC10CTL0 |= ENC + ADC10SC;
__delay_cycles(10000);
adcval = ADC10MEM;
// Enable conversion and start conversion
// Delay 10000 clock cycle to allow ADC to settle
// Store ADC sampled value
if (adcval < 380) // Based on sensor input to ADC, determine which pin to turn on. These values were determined
{
// by calibrating the sensor prior to the lab. P1.0 = force < 1/2 lb, P1.1 = 1/2 lb. < force < 1 lb.
if (adcval < 205)
// P1.2 = force > 1 lb.
{
P1OUT = 0x01;
}
else
{
P1OUT = 0x02;
}
}
else
{
P1OUT = 0x04;
}
}
Dan O. Popa, Freshman Practicum, Spring 2015
LabVIEW and connection with
C programming (review)
• LabVIEW programs are called:
– Virtual Instruments (VIs)
– because their appearance and operation
imitate actual instruments.
• However, they are analogous to main
programs, functions and subroutines from
popular language like C …
Dan O. Popa, Freshman Practicum, Spring 2015
Abstraction: LabVIEW Programs
Virtual Instruments (VIs) vs. C programs
• Front Panel
• Controls = Inputs
• Indicators = Outputs
• Block Diagram
• Accompanying “program”
for front panel
• Components “wired”
together
Dan O. Popa, Freshman Practicum, Spring 2015
Abstraction: Dataflow
Programming
• In this case, the block diagram executes from left to right, not
because the objects are placed in that order, but because the
Subtract function cannot execute until the Add function finishes
executing and passes the data to the Subtract function.
• For C language – line by line code execution, compiled, with
function calls, multithreading, etc.
Dan O. Popa, Freshman Practicum, Spring 2015
Primitive Modules
• The basic primitive building blocks in LabVIEW include
–
–
–
–
Numbers – formatted according to type (e.g. integer, boolean, float, etc.)
Loops – While, For
Logical and Arithmetic Ops – Comparator, Summer, Adder
GUI Elements – Button, Knob, Dial
– For C code: int, float, double declared explicitly
Dan O. Popa, Freshman Practicum, Spring 2015
Dataflow Programming
Which VI(s) will execute first?
Dan O. Popa, Freshman Practicum, Spring 2015
Which VI will execute last?
While Loop
while(1)
{
…
else
{
…
}
}
}
Dan O. Popa, Freshman Practicum, Spring 2015
For Loop
for (int i=1; i<=N; i++)
{
…
}
Dan O. Popa, Freshman Practicum, Spring 2015
Decisions
Case Structure
if (adcval < 205)
{
{
…}
else
{
P1OUT = 0x04;
}
}
Dan O. Popa, Freshman Practicum, Spring 2015
Select Function
next week, focus on pressure
sensors with MSP 430 and opamp
Dan O. Popa, Freshman Practicum, Spring 2015
20
Descargar

Behavior-Based Robotics