I am new to GCbasic, but so far I love the program. I am using a PIC16F684 chip and I want to move a single servo from maximum left to maximum right. I tried several examples that were posted but I am not able to get it to work properly. Can anyone help? A working sample code would be excellant.
Thanks in advance for you help.
Nick
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Have you tried looping a pulseout command between 1.0-2.0 ms? I believe 1ms equals far left and 2 ms equals far right (or the opposite, depends on the servo). Sometimes the ms values will need to be altered to get full rotation.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dir ServoPin Out
Do
For Temp = ServoMin to ServoMax
PulseOut ServoPin, Temp 10us
Wait 6 ms
Next
For Temp = ServoMax to ServoMin
PulseOut ServoPin, Temp 10us
Wait 6 ms
Next
Loop
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the replies. I tried the posted code and I think it will work, but my PIC16F684 only supports a 8 MHZ clock. How does this affect the timing? The code will move the servo one direction and it stops. I will try it on a PIC16F690 which supports 20 MHZ as well, but does anyone know if I could use the 8 MHZ clock instead?
Thanks again.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The timing will be very slightly altered, but only by 2 or 3 microseconds - not anything worth worrying about. The code I posted will work fine on any chip down to 4 MHz.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am new to GCbasic, but so far I love the program. I am using a PIC16F684 chip and I want to move a single servo from maximum left to maximum right. I tried several examples that were posted but I am not able to get it to work properly. Can anyone help? A working sample code would be excellant.
Thanks in advance for you help.
Nick
read the picaxe servo interface manual. gcbasic doesnt have a servo command, but the manual tells you the timing so you can make your own code
Have you tried looping a pulseout command between 1.0-2.0 ms? I believe 1ms equals far left and 2 ms equals far right (or the opposite, depends on the servo). Sometimes the ms values will need to be altered to get full rotation.
This worked for me with a 16F877A and a Hitec HS-81 servo. You'll have to change the first 4 lines to suit your setup but otherwise it should be fine:
#chip 16F877A, 20
#define ServoPin PORTD.3
#define ServoMin 65
#define ServoMax 225
Dir ServoPin Out
Do
For Temp = ServoMin to ServoMax
PulseOut ServoPin, Temp 10us
Wait 6 ms
Next
For Temp = ServoMax to ServoMin
PulseOut ServoPin, Temp 10us
Wait 6 ms
Next
Loop
Thanks for the replies. I tried the posted code and I think it will work, but my PIC16F684 only supports a 8 MHZ clock. How does this affect the timing? The code will move the servo one direction and it stops. I will try it on a PIC16F690 which supports 20 MHZ as well, but does anyone know if I could use the 8 MHZ clock instead?
Thanks again.
The timing will be very slightly altered, but only by 2 or 3 microseconds - not anything worth worrying about. The code I posted will work fine on any chip down to 4 MHz.
Thanks again....It works excellant!