1 Attachment(s)
Using A Ds18s20 And Servo
Hi everyone,
I am having difficulties using the ds18s20 and servo together on the pic16f88.
I find that i can't keep the 50Hz req for the servo except when its only running the servo code alone. The ds18s20 is working very well.
What i am hoping to achieve here is when the temp moves either up or down the servo will move to try and maintain the correct temp.
This also needs to be fast as there is more code to come.
Regards
Crazy Cooter
real time servos with slow sensors
I have some code that refreshes servos at 50 Hz and reads some DS1620 slow temperature sensors - they take 400 - 1000 mSecs about the same as the DS1820 I think. I do it with a loopcounter and issue the conversion request in one pass then 1000 mSecs later read the result. SOmething like
MainLoop:
LoopCtr + 1
if LoopCtr > 50 then loopCtr = 0
if LoopCtr = 1 then TempConversion
if LoopCtr = 0 then ReadTemperature
ServoCodeHere:
Low ServoPin
Pulsout ServoPin, ServoWidth
Delay to give 20 mSec looptime
Goto MainLoop
TempConversion:
Issue code to start the temperature conversion - don't wait for result
Goto MainLoop
ReadTemperature:
Issue code to read most recent temperature conversion
Goto MainLoop
HTH
Brian