MikroElektronika PIC Microcontrollers PIC18 Instrukcja Użytkownika Strona 55

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 88
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 54
Robotics experiment with PIC microcontroller l 55
For Robo-PICA, we prepare the speed control with PWM technique via soft-
ware by the motor.h library file. You can see detail in motor.h sourcecode in Listing 4-1
(in this chapter). motor.h library has PWM function for supporting 2 PWM modules of
PIC16F887 as follows :
Pwm1_Change_Duty(speed); // Motor A Duty
Pwm2_Change_Duty(speed); // Motor B Duty
You can put the required duty cycle value in (speed). The range is 0 to 255 for 0
to 100% duty cycle.
A4.1 Write the Listing A4-1. Compile and download the code to Robo-PICA. Turn-off
power switch.
A4.2 Remove the downlaod cable from Robo-PICA.
A4.3 Place the robot on the floor. Turn-on power to run the program. See the operation.
The Robo-PICA robot will move forward fastest in 2 seconds and spin left
5 second. After that the robot will move foraward with fastest speed again. The robot
will move this routine all times.
Listing A4-1 : The speed control program for Robo-PICA by using PWM.
#include <motor.h>
char i;
void main()
{
Forward(255); // Motor Forward
while(1)
{
Delay_ms(2000);
Pwm1_Change_Duty(220); // Motor A 85% Duty
Pwm2_Change_Duty(255); // Motor B 100% Duty
Delay_ms(5000);
Pwm1_Change_Duty(255); // Motor A 100% Duty
}
}
E
The suitable PWM duty cycle value for driving the robot is more than 70%.
If select the less value, the robot has not torque more enough for turning
or rotation.
INNOVATIVE EXPERIMENT
Przeglądanie stron 54
1 2 ... 50 51 52 53 54 55 56 57 58 59 60 ... 87 88

Komentarze do niniejszej Instrukcji

Brak uwag