Transcript Slide 1

Robotics Research Laboratory
Louisiana State University

Pulse-width Modulation
◦
◦
◦
◦

What for
How it works
Applications
How to make it
Servo Motor Control
◦ What is servo motor
◦ How it works
◦ Set position of servo head

Simple Hexabot
◦ Walking
◦ Turning
◦ Control hexbot

How to make it?
◦ Digital Out (PINx)
◦ Special Function I/O Regiser (SFR/SFIOR)
◦ Using a main program
 ns_spin( int delay_time ) ; TOGGLE_PIN(PINxx)
◦ Using interrupts
 Timers
 PORTB – PINB5 (OCA1), PINB6 (OC1B), PINB7 (OC2)
 PORTE – PINE3 (OC3C), PINE4 (OC3B), PINE5 (OC3A)

What is it?
◦ Robotic Arms, RC-Airplane, etc.
◦ Mechanical position change

How does it work?
◦
◦
◦
◦
◦
◦
Position Reader (Potentiometer)
DC-Motor
PWM DC-Motor Controller
Body Frame
Gears
Servo Head

How to set position of a servo head
◦ /home/csc2700/csc2700/10-PWM-Servo-01
int count = 0;
while (1){
switch (count++ % 4){
case(0):
OCR3A = 1000; break;
case(1):
OCR3A = 3000; break;
case(2):
OCR3A = 5000; break;
case(3):
OCR3A = 3000; break;
}
ms_spin(1000);
}
// OCR3A is PINE3 , 1000 is 1ms == left (0 degree)
// OCR3A is PINE3 , 3000 is 3ms == middle (90 degree)
// OCR3A is PINE3 , 5000 is 5ms == right (180 degree)
// OCR3A is PINE3
MOSFET-based H-bridges









MOSFET-based H-bridges
Recommended motor voltage (VMOT): 4.5 – 13.5 V
Logic voltage (VCC): 2.7 – 5.5 V
Output current maximum: 3 A per channel
Output current continuous: 1 A per channel (can be
paralleled to deliver 2 A continuous)
Maximum PWM frequency: 100 kHz
Built-in thermal shutdown circuit
Filtering capacitors on both supply lines
Reverse-power protection on the motor supply

The metal–oxide–semiconductor field-effect
transistor

An H bridge is an electronic circuit that
enables a voltage to be applied across a load
in either direction
int main(void){
InitHardware();
initPWM();
MC_HI(STANBY); MC_LO(LEFT0); MC_LO(LEFT1); MC_LO(RIGHT0); MC_LO(RIGHT1);
int speed = 1000;
int delay = 100;
while (1){
MC_LO(LEFT0);MC_HI(LEFT1);
SetPWM( PWM_PINE3, speed);
SetPWM( PWM_PINE4, speed);
ms_spin(delay);
MC_LO(RIGHT0);MC_HI(RIGHT1);
SetPWM( PWM_PINE3, speed);
SetPWM( PWM_PINE4, speed);
ms_spin(delay);
speed += 1000;
if (speed > 40000){
speed = 1000;
}
}
}

Create a DC motor speed control program, which
has a clockwise button, an anti-clockwise button,
and a stop button
◦ The clockwise button is for increasing speed of Motor
controller toward clockwise (speed down for anti-clockwise)
◦ The anti-clockwise button is for increasing speed of Motor
controller toward anti-clockwise (speed down for clockwise)
◦ The stop button is for stop DC motor