Servo help

John F

Member
I've been using the servo and servopos commands to drive electronic speed controllers. This has worked well. But a couple of days ago it stopped working! Now I can't get even the most simple of code to work on my Axe 023 motor driver boards. For example, I did a very simple test program
Code:
let dirs = %00010111
servo 2, 150
pause 1000 'let ESCs boot up
servopos 2, 180
high 0
The light on port 0 comes on, indicating the program has reached that point, but not a twitch from the servo connected to port 2.

Does anyone have any ideas of what is wrong?
 

erco

Senior Member
Try brand new batteries. Test your servo. Something tiny but important changed. Is your servo getting power? Does it twitch on powerup?

BTW your demo program just ends and IIRC that stops servo pulsouts. Add this loop to the end and retry:

do
pause 100
loop
 

Goeytex

Senior Member
If it stopped working with no changes on your part then there has been a failure unrelated to the code. If you changed something then revert the change and retest.

Assuming that nothing was changed, the first thing I would check is the power to the servo. Measure the voltage across the servo power connectors. Is it good ? What is the Voltage ?

If the power is good then check the signal to the servo. Do you have pulses @ ~50 Hz ?

Be sure to add the do : loop to the test code as erco suggested.
 

John F

Member
Hi All, Thanks for the suggestions. I have tested the servo and it works. How do I test the signal to the servo? What I expect is a PWM signal but other than seeing if the servo moves, I don't know to test for it. Erco - are you suggesting I change the test code to read:

Code:
let dirs = %00010111
servo 2, 150
pause 1000 'let ESCs boot up
servopos 2, 180
high 0
do
pause 100
loop
with the servo on port 2 and an indicator light on port 0.
 

erco

Senior Member
Yes, that's the right way to end you program, with a do loop. Without that, the program just ends and terminates the servo pulsouts.

Now what is an ESC doing connected to a servo? It's interfering, the servo's white/yellow/orange wire should go directly to the Picaxe output pin.

An ESC would use SERVO-style commands to control the speed of a DC motor, not a servo.

Assuming you have a real servo, you can test it with one of these cheap & handy gadgets: https://www.ebay.com/itm/363385929755

Wow, electronics prices have doubled during COVID. I used to buy these for a dollar all day long, with free shipping.

Usually the
let dirs = %00010111
command is not needed when using SERVO & HIGH commands, as they will automatically make that pin an output.

Is there more to your code and circuit that you can share? Something else may be the problem.
 
Last edited:

John F

Member
I'm not connecting an ESC to a servo. Since ESC's and servos both use PWM for control, when the picaxe failed to drive the ESC, I substituted a servo to try and detect the signal. I have also tested the servo using a RC transmitter and receiver and know it is working.
 

erco

Senior Member
Can you post a photo of your setup? Might be something else going on.

Of course you are aware that the program you posted simply moves a standard servo to a fixed position. If it's already there, you won't see any motion other than some possible glitching on powerup. If you try to move it manually you'll feel the growl.

If you have a continuous rotation servo, you should see it rotating at servopos 2, 180
 

John F

Member
I have a continuous rotation servo but it is not rotating. When I program the same Axe 023 board to set pin 2 high it does so and drives a small relay.
 

erco

Senior Member
Try a different output pin on the off chance pin 2 was damaged.

Rare, but it's slightly possible that your CR servo is nulled at servopos 2, 180 . Try servopos 2, 225. Go big or go home! :)
 

John F

Member
Any thoughts on how pin 2 could be damaged to the extent it can't support PWM but is still able to support high and low?
 

erco

Senior Member
Not offhand but it's quick enough to try another pin... or another Picaxe if you have one handy. Something hinky is afoot, because servo & servopos are fairly bulletproof and quite straightforward to use.

Anything else going on in your program that you haven't shown us? For instance, you can't use SERVO and PWM simultaneously in most cases AFAIK.
 

John F

Member
Have tried another Picaxe and another 08M2 in this one. Thanks for all your advice which I greatly appreciate.
Am going to knock off now and go to bed. Will continue tomorrow.
 

AllyCat

Senior Member
Hi,

A problem is that I don't think there's a published schematic diagram for the AXE023, so something might not be "as expected". First, the board carries a L293D driver chip which is "unnecessary" for driving a servo motor and may be doing something "undesirable". In particular, that chip has a pair of "Enable" inputs which requires at least one to be held High to pass any input pulse on to the output terminal.

Finding the "fault" is really just a matter of checking whether all the circuit voltages are "correct", in particular the servo pulse and the presence of ALL the required voltage levels, at a sufficiently low source impedance. The method will depend on what "tools" are available, an oscilloscope is ideal, but a Multimeter is sufficient for most purposes, or even a LED with a series resistor and a couple of wires/probes may be sufficient.

First ensure that the supply voltage AND Earth connections are reaching all the required components, then follow the Servo pulse through from the PICaxe pin to the servo motor connector. The servo pulse is more difficult to detect, however a multimeter (on DC range) should measure about 8% of the full supply voltage (or 92% down from the supply), or a LED should shine less brightly, but still clearly. If the basic hardware seems to be operating correctly, then adjust the software, for example the Pulse Duty Cycle or the pin number, to check that all the drive signals change as expected. If you can identify something "wrong" or unexplained, then perhaps we can find a reason.

Cheers, Alan.
 

John F

Member
Hi Guys,

I may never find out why two of my Axe 023 boards failed to drive the servo, despite having done so in the past. But I used an 08m prototyping board to run the servo directly from the chip and that worked fine. An unbuffered chip will be perfectly ok for my project [an autonomous robot] so problem solved. Thanks so much to all of you for your help.

All the Best

John
 
Top