newby problem

bluejets

Senior Member
First attempt at programming and started with what I thought to be a fairly simple program but can't get it to work. Basically stripped the servorobotarm.pdf down to one servo and programmed into an 08M but all it does is runs hard to one end of the servo travel. Copy of program below.

`Boat Tacho servo driver using 08M
`Servo follows 0 to 5 volt input
`Travel Limit will be added 75-225
symbol pos1 = b1 `servo position
` *** read analogue input voltage ***
main:
readadc 1,pos1
` ***Test if value between 0-225 ***
` If not then correct to exactly 75 or 225 ***
test1:
if pos1<75 then pos1low
if pos1>225 then pos1high
pulses:
` *** optional display values on serial LCD ***
` serout 2, n2400,(254,128,"0=",pos1," ")
` *** Set servo pulses ***
servo 2,pos1
pause 1000
goto main
pos1low:
let pos1=75
goto test1
pos1high:
let pos1=225
goto pulses

Connected servo signal to pin 5 and V-divider pot across supply and centre wire to pin 6.
Drove servo with seperate supply.
 

Attachments

Last edited:

hippy

Ex-Staff (retired)
let pos1=75
goto test1


Sould probably be a 'goto pulses', or you create a loop which never executes an actual SERVO comand.

You can create a better limiting function using the MIN and MAX commands ...

DO
ReadAdc 1, pos1
pos1 = pos1 MIN 75 MAX 225
Servo 2, pos1
Pause 1000
Loop
 

bluejets

Senior Member
The servo must be getting some command for it to travel fully to one extreme. ??
So therefore the code in the robot arm servo pdf is no good?
 

eclectic

Moderator
@bluejets

The code from post #1

Code:
`Boat Tacho servo driver using 08M
`Servo follows 0 to 5 volt input
`Travel Limit will be added 75-225
symbol pos1 = b1 `servo position
` *** read analogue input voltage ***
main:
readadc 1,pos1
` ***Test if value between 0-225 ***
` If not then correct to exactly 75 or 225 ***
test1:
if pos1<75 then pos1low
if pos1>225 then pos1high
pulses:
` *** optional display values on serial LCD *** 
` serout 2, n2400,(254,128,"0=",pos1," ")
` *** Set servo pulses ***
servo 2,pos1
pause 1000
goto main
pos1low:
let pos1=75
goto test1
pos1high:
let pos1=225
goto pulses
works.

I've just tried it.

Please can you check your wiring and connections.

e
 

hippy

Ex-Staff (retired)
Sorry, eclectic is right - The test is "If pos1 < 75" so although it goes through the loop twice it does get to the SERVO command after that.

I also forgot to say, Welcome to the PICAXE forum.

It does look like a pot wiring problem or a faulty pot, READADC always returning 'pos1' as 225 or greater.
 

bluejets

Senior Member
O.K. ..it's been an afternoon of headscratching since I couldn't get it to work. Good to know I'm on the right track with the program.

I will recheck the wiring. ..... Thanks for the replies.
 

westaust55

Moderator
Servos

Over and above the potential wiring problems, you will also need to run the servo to each end and test its actual setting limits.

The range 75 to 255 may not be valid for the servo you have.

Additionally some servos will not move at all if the new position setting is outside the valid range. I have some Servos in that Category.


EDIT:
If you are also new to Servomotors, you might want to have a read at the basic Servo tutorial I uploaded some time back:
http://www.picaxeforum.co.uk/showthread.php?t=12120
 

bluejets

Senior Member
Eclectic,
Problem was in the test board I have been using for many years. Found some faulty connection busses. Guess where it is destined for.

Thanks again for the replies.
 

bluejets

Senior Member
re-wrote program to conform with the application I have here and wondered if there is somewhere to post the result. I imagine there would be others interested in the project.
 

Attachments

westaust55

Moderator
where to put completed projects

There is a section dedicated to finished projects:
http://www.picaxeforum.co.uk/forumdisplay.php?f=34

To make it valuable and useful to others try to include there elements in your Finished Project post. You may need to use a couple of posts to attached all the information.
1. 1. A good clear written (plain English preferred) description of what the project is intended to do and how you have implemented the project

2. A list of the components used and for special items such as your dial, where you sourced the parts

3. A layout of any board you have designed – be it a proto board or project specific

4. a schematic diagram reflecting your circuit

5. program code list with lots of comments so others can understand the program and adjust to suit their needs

6. photos of the final project and any sub assemblies
 

bluejets

Senior Member
Westaust,
OK...will do when I get a few moments spare...Thanks.

Andrew,
Gearing is to get 270 degrees travel from approx. 90 degrees servo travel. Also it does get to where it has to go in a hurry.
I made the complete gauge. Dial face was made using a program "meterface" . It was available as trial (10 free uses) but has now been superceeded by one free version (limited) and one to purchase. http://tonnesoftware.com/
Printed out on laserjet on photopaper. Must admit it came out quite good.
 

bluejets

Senior Member
@bluejets

The code from post #1

Code:
`Boat Tacho servo driver using 08M
`Servo follows 0 to 5 volt input
`Travel Limit will be added 75-225
symbol pos1 = b1 `servo position
` *** read analogue input voltage ***
main:
readadc 1,pos1
` ***Test if value between 0-225 ***
` If not then correct to exactly 75 or 225 ***
test1:
if pos1<75 then pos1low
if pos1>225 then pos1high
pulses:
` *** optional display values on serial LCD *** 
` serout 2, n2400,(254,128,"0=",pos1," ")
` *** Set servo pulses ***
servo 2,pos1
pause 1000
goto main
pos1low:
let pos1=75
goto test1
pos1high:
let pos1=225
goto pulses
works.

I've just tried it.

Please can you check your wiring and connections.

e
How do you enter the code as you have done here. I read the part at the beginning of the forum which said to enclose in
Code:
  at beginning and end of code but I tried that and it didn't work.
 

westaust55

Moderator
How do you enter the code as you have done here. I read the part at the beginning of the forum which said to enclose in [ code ] at beginning and end of code but I tried that and it didn't work.
You need [code] at the start and [/code] at the end of your code block

Code:
 test
 
Top