Hi, I am having some trouble controlling a servo, and I realized to day that the pulses I am outputting are not what I specified in code. I checked them with an oscilloscope and it shows the pulses being 6ms. Is anything obviously wrong with my code? Note: I am using the internal oscillator, I am getting some crystals tomorrow)
#chip 16F688, 20
#config OSC = INTOSC
dir PORTC.2 OUT
Dim i As Byte
Do
i = 1
For i=1 To 50
PULSEOUT PORTC.2, 110 10us
Wait 140 10us
Next
Loop
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I figured it out! I didn't realize that the internal OSC was only 4mhz, so my code cycling the amount of time it would need to output a 1.1ms pulse at 20mhz, but was only running at 4, so the values ended up getting multiplied by around 5.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I am having some trouble controlling a servo, and I realized to day that the pulses I am outputting are not what I specified in code. I checked them with an oscilloscope and it shows the pulses being 6ms. Is anything obviously wrong with my code? Note: I am using the internal oscillator, I am getting some crystals tomorrow)
#chip 16F688, 20
#config OSC = INTOSC
dir PORTC.2 OUT
Dim i As Byte
Do
i = 1
For i=1 To 50
PULSEOUT PORTC.2, 110 10us
Wait 140 10us
Next
Loop
I figured it out! I didn't realize that the internal OSC was only 4mhz, so my code cycling the amount of time it would need to output a 1.1ms pulse at 20mhz, but was only running at 4, so the values ended up getting multiplied by around 5.