Serial Servo (Replacement PCB works!)...
I've been wanting to have more control and feedback from hobby servos for a long time...
Attempted to use a PIC chip back in 2010 to control the servo and have serial comms back to Propeller.
But, that attempt failed miserably because the PIC and myself didn't have the skills to do it...
Fast forward to 2021 and it looks to be super easy now. The PIC capabilities have improved dramatically and so has their compiler. There's now a built in UART that I'm using.
Test setup (see image) seems to demonstrate it works. 14-pin PIC chip is talking to P2 over one cable. It's easy to switch one P2 pin from RX to TX mode. The comm wire goes directly to the RX pin on the PIC chip and then though a 10k resistor to the RX pin.
To start out, I'm making the circuit very simple by operating the motor and the PIC at +5V. This lets me connect PIC I/O pins to the drive mosfets without a buffer. The 10k on TX protects the P2 from the 5V. Powering with 4X rechargeable AA.
Was easy to read the POT value and drive the motors to a set position. Still need to figure out how to come to a complete stop once we get there though...
I've removed the microcontroller from the servo's board and connect PIC I/O pins through 100 Ohm resistors to the P and N mosfet driver chips. 100 Ohm is probably too big, but seems to be working OK anyway.
Lots of work to do, but I think it's going to work this time.
Update: It's working! Have 2-way communication between P2 and PIC over 1 wire.
Can give a variety of commands to the PIC.
Comments
Here is the 2010 attempt:
https://forums.parallax.com/discussion/124175/serial-servo-making-a-servo-more-intelligent
I started here with the Curiosity LPC board and switched the chip to a PIC16F15323.
But, I think that was a mistake after seeing the Curiosity Nano board.
Now, going to try switching to a PIC18F06Q41. It is faster, has more memory, and a 12-bit ADC...
Servo this time is the "TURNIGY™ TGY-S901D DS/MG ROBOT SERVO".
This one is nice because it has the protrusion on the axis on the the cover that should make it easier to use with robots. I think that's the only thing that makes it a "Robot Servo".
Bench testing is working! Now with PIC18F06Q41. All kinds of programming space left. Have 4 free I/O pins to do other stuff with.
My favorite thing is to tell it to go to an ADC value and then put on the brakes. This should make some robot things much steadier and quieter...
Got the replacement board for servo all drawn, using same I/O pin arrangement as bench test.
This board is same size as the one the servo comes with.
Had to use some 0402 resistors. Hope I can actually solder them by hand...
Plan is to harvest the mostfet driver chips from the original and transfer them to bottom side of this board.
Noticed there’s a serial bootloader for these PICs. This will help a lot. Can reprogram without taking servo apart.
Just got the boards today.
Will soon see if I can do 0402 soldering...
This look is like a really cool endeavor! I am excited to see how this turns out!
The replacement PCB works!
Was actually able to solder 0402 resistors by hand.
Did make a couple of mistakes though:
1. The two-3 pin headers are swapped, in each others place. That may prevent me from closing the lid, but maybe not...
2. Forgot or didn't know I needed a 10k pullup on the reset pin. Fixed that with a thru-hole resistor.
Think I might actually be able to pull this off this time...
The black, white, and brown wires are for programming. They'll be removed once the software is finished.
Found another issue... Seems can't have motor power be tied to MCU power or it resets when motor is on a lot...
But, simple fix is to insert a Schottky diode between +5V source and +5V MCU power.
All better now.
Here's the main loop in the Servo's code:
Nothing fancy yet... The ADC has a filtered mode, but haven't figured out how to use it yet... Probably should be doing some form of filtering on the pot's ADC reading though...
Got it buttoned up now, just to make sure it fits... It does, plenty of room inside too. Especially in the cap...
Drilled out the flange on the cap to bring out the programming wires.
Programming is a bit flaky, probably because of the long wires. It takes 2..5 tries before it takes...
Was hoping to use the much smaller Curiosity Nano with PIC18F16Q41 for programming, but that didn't work out because seems that device doesn't like to program any other PIC chips...
But, I did learn that I can program with the Nano LPC switched from 5V mode to 3.3V mode.
And, what's strange is that now it programs on the first try, all the time... Strange..