Makes sense, thanks guys - I had planned on input circuit isolation at the pin, but wasn't sure if there was some other issue that I'd run into during subsequent programming...
Thanks again, and happy new year all!
Makes sense, thanks guys - I had planned on input circuit isolation at the pin, but wasn't sure if there was some other issue that I'd run into during subsequent programming...
Thanks again, and happy new year all!
Hi, new to this forum and to PIC's in general. I fly RC and have used a 12F683 to act as failsafe system for 3 servos.
I've tried the pulsout command but the output just goes HI?? (I have scope to check).
Here is the code:
pos var byte ' Define our storage location for the servo position information.
servo var byte ' Define our storage location for the servo number to move.
cont var byte ' Define a variable to hold the count.
' 4 mhz clock internal
' 500 = 1 ms
' 1000 = 2 ms
' 1250 = 2.5 ms
pos = 1250
start:
for cont = 0 to 50
pulsout portb.4,pos ' Send servo# ? to position ?.
pause 20 ' Wait 20 ms.
next cont ' Next pulse.
goto start ' Return to get more serial input.
Can anyone help??
Try changing pos to a WORD size var and see if that helps
Dave
Always wear safety glasses while programming.
Thanks! it worked on the 16F84A chip.
I'm still having difficulty with the 12F683 though. The pulsout doesn't seem to work. I wonder if the chip supports that command?
I've also tried running the servo by setting the pin high and low timing the high between 1 to 2 ms and the low to 20ms. It works, but it won't accept a decimal number.
at 4 mHz, I need to pause for between .5ms and 2.5ms but it only accepts 1 and 2 !!!
suggestions??
John.
p.s., here's the code:
posit var word
cont var word
cont2 var word
Q var word
let posit = 3/2
Let Q = 25
start:
for cont = 1 to 50
high 0
pause posit
low 0
pause 20
next cont
goto start
It doesn't show in your code so I will assume that the device has not been configured to what you want to do with it since it has other features.
Start by setting the oscillator then the ports with the TRISIO command, found on page 35 of the data sheet, shut OFF the comparators and the A/D feature:
Then use the PAUSES command instead of PAUSE for a better resolution of the timming you need:Code:OSCCON = %01100000 ' Ocs set to 4 MHz TRISIO = %00000000 ' Set all ports to outputs, in this example CMCON0 = 7 ' Analog comparators off ANSEL = 0 ' Analog select set to digital, pg 69 data ADCON0 = 0 ' A/D turned OFF, pg 68 of data
PAUSE 1 gives you 1ms where PAUSES 1000 will do the same but now you can get your 1.5ms with PAUSES 1500.
Last edited by LinkMTech; - 3rd January 2009 at 04:49. Reason: Then use GPIO.# not PORT.#
Louie
Didn't know how to edit last post so:
Use GPIO.# instead of PORTB.# per pg. 35 of data sheet.
Louie
That should be PAUSEUS not PAUSES.
PAUSEUS will pause microseconds, not milliseconds.
If you let PBP devide 3 by 2 then you will always get 1 as an answer.
So if you want to pause 1.5 milliseconds use PAUSEUS 1500 instead.
happy new year
Bookmarks