Serial Servo: Making a servo more intelligent
I don't post in this forum, but I wanted to share a project I'm working on...
My goal is to improve the servos for my robot.
I'm taking a low cost digital, all-metal servo and reprogramming the onboard PIC16F676 microcontroller.
This will allow bi-directional digitial communications between the servo and Propeller (brain of my robot).
I'm having to learn how to program PICs, but I'm getting there...
The original plan was to remove the PIC and run 5 wires to a Propeller to control the servo.· But, this way
is a lot more convenient.· But, I discussed my original plans and servo details in this Propeller thread:
http://forums.parallax.com/showthread.php?p=907089
Here's some features that "Serial Servos" will have:
1.· Digital bi-directional communications
2.· Servo can transmit it's position to host controller
3.· You can limit the power of·a servo or even let it free
4.· You can use "motor braking" to maintain position without using any power
5.· Bus operation so that several servos can use the same 3 wires
There are also a few extra I/O pins that aren't being used on the PIC, so I'm toying with the idea of adding buttons or LEDs to the servo....
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Apps:· http://www.rayslogic.com/propeller/Programming/Programming.htm
My Prop Info: ·http://www.rayslogic.com/propeller/propeller.htm
My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm
Post Edited (Rayman) : 7/25/2010 2:12:59 PM GMT
My goal is to improve the servos for my robot.
I'm taking a low cost digital, all-metal servo and reprogramming the onboard PIC16F676 microcontroller.
This will allow bi-directional digitial communications between the servo and Propeller (brain of my robot).
I'm having to learn how to program PICs, but I'm getting there...
The original plan was to remove the PIC and run 5 wires to a Propeller to control the servo.· But, this way
is a lot more convenient.· But, I discussed my original plans and servo details in this Propeller thread:
http://forums.parallax.com/showthread.php?p=907089
Here's some features that "Serial Servos" will have:
1.· Digital bi-directional communications
2.· Servo can transmit it's position to host controller
3.· You can limit the power of·a servo or even let it free
4.· You can use "motor braking" to maintain position without using any power
5.· Bus operation so that several servos can use the same 3 wires
There are also a few extra I/O pins that aren't being used on the PIC, so I'm toying with the idea of adding buttons or LEDs to the servo....
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Apps:· http://www.rayslogic.com/propeller/Programming/Programming.htm
My Prop Info: ·http://www.rayslogic.com/propeller/propeller.htm
My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm
Post Edited (Rayman) : 7/25/2010 2:12:59 PM GMT
Comments
Here's a photo of my test setup:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Apps:· http://www.rayslogic.com/propeller/Programming/Programming.htm
My Prop Info: ·http://www.rayslogic.com/propeller/propeller.htm
My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm
The ability to know a servo's position will be really handy. Wheen using them for positioning something large, you have to park it, so that during the next power up the servo is at a known position. Otherwise at the next power up you'll get a major jerk when the first servo pulses are applied.
Position feedback to the main controller avoids that problem, plus helps with stall detection.
Please keep on posting here, very informative stuff.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
when I heard that "digital" servos were coming in the RC world I was hopeing SO bad for a Bi Dir comms on them .
Ends up there the same PPM system IN but there smarter on the inside ..
Peter KG6LSE
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Carpe Ducktum" "seize the tape!!"
peterthethinker.com/tesla/Venom/Venom.html
Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway. —Tanenbaum, Andrew S.
LOL
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
···································Fix it, if it ain't broke!
D Rat
Dave Ratcliff N6YEE
The biggest advantage is being able to read the servo position, speed, torque, etc, at any instant. It would be really nice to get rid of the servo jump on startup, and also to get good feedback on actual maximum movement rates under load in controlling the walk cycles.
It would be nice to get the original code off the HX12K, to re-burn the PIC back to the original code if it doesn't work, but often the PIC is read-protected against this.
Another nice feature would be to implement a serial protocol that was auto-detecting. If a normal pulse-width is given, it can use this to drive the servo. Alternatively, if it detects a serial message, it could detect that and switch to serial mode. There's the best of both worlds, and wouldn't require any hardware changes. Ideally, a one-wire serial protocol would be implemented, as this would permit the existing hardware to be used without any modification. Unfortunately the more standard SPI and I2C require extra wires for bi-direction communication. Perhaps the clock can be combined with the power line - this would require some extra circuitry at both ends to drive a high-current clock signal, and smooth it out again at the servo end. [noparse]:([/noparse]
Perhaps it's better to just add the extra digital control lines that are required. In the end, I2C on an independent connection is probably a good choice, with the option of running the power through the original analogue connection or the new digital connection. This would allow a lot of flexibility, and it looks like there's room above the circuit board to add a new pin-header. Unfortunately, the 16F676 doesn't have hardware support for SPI or I2C, so this means implementing them in software, or possibly swapping the 676 out for a newer 14-pin PIC with SPI/I2C support, such as 16F1823. PICs themselves are cheap - it's the board that seems to add most of the cost, so if the same board can support another chip, then that's still an economical option.
Anyway, I'll be watching with interest to see how you go.
I kinda like the auto-sensing idea so that it would revert back to a regular servo...
The hardware change I made was to remove the input transistor and replace it with just a 1k series resistor directly to the PIC input pin. The PIC operates at 4.4 V, but it has TTL input and CMOS output. So, I think it should work fine with a Propeller at 3.3V. It may not work with a Basic Stamp, I don't know...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Apps:· http://www.rayslogic.com/propeller/Programming/Programming.htm
My Prop Info: ·http://www.rayslogic.com/propeller/propeller.htm
My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
···································Fix it, if it ain't broke!
D Rat
Dave Ratcliff N6YEE
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Apps:· http://www.rayslogic.com/propeller/Programming/Programming.htm
My Prop Info: ·http://www.rayslogic.com/propeller/propeller.htm
My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm
http://openservo.com/
But that approach involves replacing the servo's circuit board...
This way uses the same board and just reprograms the existing controller chip, which I think will be a whole lot cheaper and easier...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Apps:· http://www.rayslogic.com/propeller/Programming/Programming.htm
My Prop Info: ·http://www.rayslogic.com/propeller/propeller.htm
My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm
You've made great progress - congrat's.
When you're ready; I wonder if you'd give us a "dummies guide" to re-programming the PIC? I have a PIC programmer (I came to the Propeller after a yaer of frustration with PICs and their (cringe) interrupts) so would be able to do this, but how did you interface the programmer to the PIC?
Keep up the good work.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
www.norfolkhelicopterclub.com
Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.
I'm pretty sure that the DIP version of the PIC16F676 could just plug into that demo board and be programmed.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Apps:· http://www.rayslogic.com/propeller/Programming/Programming.htm
My Prop Info: ·http://www.rayslogic.com/propeller/propeller.htm
My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Apps:· http://www.rayslogic.com/propeller/Programming/Programming.htm
My Prop Info: ·http://www.rayslogic.com/propeller/propeller.htm
My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm
Update: nevermind I just noticed the earlier discussion of open servo.
Post Edited (Martin_H) : 8/4/2010 2:31:59 AM GMT
I've now learned enough PIC code to make the servo act like a servo and move to any hard-coded position and hold it. It still needs tweaking, but it works good enough and I can control how much power the servo uses to move and hold position.
Now, I just have to code up a communication protocol...
I think I'll have the servo act as a slave and have the data line trigger an interrupt whenever it detects the start of a serial command...
Great job on getting this far. It's superb to know that these servos can indeed be reprogrammed. I've found a few different servos that are based on the PIC chip, so there's a range available, just waiting to be reprogrammed.
Fortunately, a new line of PIC chips with UART that are drop-in replacements are coming out in November. I'm just going to wait for them now, because they will make things so much simpler and better...
If you or anybody else is a PIC programmer, let me know and I'll share my code...
PIC16F1823
This one is a drop in replacement that will allow me to add a UART on some of the free pins. I could also up the clock speed using the internal oscillator...
Got a couple free samples coming in a few days, so should know soon if this will work or not...
The UART will make things much, much simpler for me...
Can you make your Intelligent Servo able to go into sleep mode at a few uAmps?
and able to wake up when a pulse (or any uart signal) is sent to it?
It should also auto sleep if idle for more than 30 seconds.
This is important as a normal servo wastes a few milli amps when idle, draining AA batteries within 2-3 days even when not doing anything.
I know this setup will allow a great deal of power savings, but don't know exactly how much....
It worked especially well with brushless motors and in my trials has worked fairly well with brushed. YMMV and for what it's worth, I've not tried it on a motor tiny as what's in a servo.
Are you going with a similar setup as AX12+ (half-duplex) or full?
I know what you're saying. But, believe me, it works. The servo is almost impossible to move when the brakes are on.
MaxTuxLin,
There's only 1 wire, so it's tough to do any kind of 2-way comms without conflict. My current plan is to have the servo only respond with it's position when asked....
Yes, using UART is a lot better then PWM.