Analog dial

Gramps

Senior Member
In Ken Anderson's Book, Picaxe Project Handbook vol.1 pt.1, he describes a analog dial project.
We cannot get it to work. The program loads nicely. Very simple wiring breadboard but the servo does not respond to the pot.

#picaxe 08M2
#no_data

symbol pot1=b1
symbol adc=C.1
init:
dirsC=%00000101
PinsC=%00000000
servo C.2,75

main:
do
select case pot1
case<84:servopos C.2,75
case<112:servopos C.2,112
case<140:servopos C.2,140
case<168:servopos C.2,168
case<196:servopos C.2,196
case<224:servopos C.2,224
end select
loop
Any suggestions would be appreciated!
Gramps
 

hippy

Technical Support
Staff member
You are not reading the pot, not putting anything into 'pot1'. I would presume you need something like the following immediately before your 'select case pot1' -

readadc adc, pot1
 

Gramps

Senior Member
Ken Anderson said, Adding more "case" statements would smooth out the servo operation .
Isn't there a better way to code this then using "case"?
 

hippy

Technical Support
Staff member
Ignoring the first "Case < 84 : ServoPos C.2, 75", the servo settings are the same as the pot values read. So something like this should work -
Code:
Main:
  Do
    ReadAdc adc, pot1
    pot1 = pot1 Min 75 Max 224
    ServoPos C.2, pot1
  Loop
A more mathematical conversion would allow the pot to move from min to max with the servo doing likewise ...
Code:
Main:
  Do
    ReadAdc adc, pot1
    pot1 = 224 - 75 * pot1 / 255 + 75
    ServoPos C.2, pot1
  Loop
 

Gramps

Senior Member
Yes, that works well with the small Futaba S3115 servo but with the big 20 KG.CM servo nothing happens. Is this because we need a duty cycle command?
 

hippy

Technical Support
Staff member
If one servo works then any other should. So not sure why the LD-220MG doesn't. Maybe it requires higher voltage or more current. You could try changing the duty but the PICAXE frame rate is standard, and most servos aren't that particular about whatever it is.

Perhaps it is because it's digital and hyper-sensitive to pulse repeatability. That could probably be solved by using a PULSOUT / PAUSEUS loop instead of the in-built SERVO and SERVOPOS commands.
 
Top