After a little more debugging this morning I’m coming to the conclusion that I may have been a little harsh on the Arduino’s software serial port.
More when I know more, but I think it’s more of a flow control issue with my data transmission from the PC.
Tonight I took a look at the ‘software serial’ support in the Arduino. I can’t say I’m that impressed…
The Arduino has a built in hardware UART (a hardware serial port) which works as expected. It allows you to talk to external serial devices but there’s only one of it so if you want to have an external device talk to you via a serial port and then you want to talk to something else via another serial port then you’re out of luck.
I’ve been testing the new leg with one power supply for the servos and one for the electronics and all is working well. I expect that all would be working well if I were using a single power supply for both, as long as I was using the new one I soldered up and not the old one…
I decided that since I would be using a 5v power supply for most of the bits of this project that I’d grab and old mains transformer and wire up a 5v regulator and run from the mains rather than batteries.
So far I’ve bought three AVR programming books. AVR: An Introductory Course, Programming and Customizing the AVR Microcontroller and Atmel AVR Microcontroller Primer: Programming and Interfacing (Synthesis Lectures on Digital Circuits and Systems).
They are three quite different books and each has a distinct focus.
I read AVR: An Introductory Course first. It’s a slim volume that teaches you how to program the AVR family of micros with assembly language. It’s a good book and the focus is very much on learning how to program the various facilities available and how to use the various programming constructs to get work done.
Having decided that the graduated servo positioning method was the way to go to allow for leg sensors to work correctly I started thinking about leg sensors.
Here’s a new lower leg with three switches, one on the foot, one to the inside of the leg and one to the outside of the leg.
ProtoLegv02-1.png ProtoLegv02-2.png Ideally the front and back switches would be extended with thin metal bars running the length of the leg and fixed just above the ankle.
I adjusted my quick and dirty servo controller program to calculate the number of moves required for the servo that needed to move furthest and then spread the movement of the other servos across the same number of moves. So, given that the servo controller works in terms on a position from 0 - 254 where 0 is full left and 254 is full right and we have three servos that make up the leg I look at the differences between where the three servos are now and where they will be at the end of the move and then build a sequence of moves to get from here to there.
This week I managed to scrape together some time to play with some of the non prototype bits and pieces that I purchased for this project. First off was breadboarding a MAX232 chip so that I could talk via my PCs serial port to my ATtiny2313 microcontroller. The MAX232 does the required level shifting and talks RS232 signals on one side and TTL signals on the other. The result is that it makes it possible to connect a microcontroller’s internal UART to a PC.
The prototype leg has some fairly major failings from a mechanical point of view. The only part that may eventually find its way into a weight bearing leg is the lower leg where the cut out around the knee servo provides ample support for the servo itself and also a suitable mounting point for the servo. The hip servos need much more support before they could be used to form a weight bearing leg either in the form of metal brackets or more complexly cut board.
I spent a little time at the weekend putting together my three servos into a prototype leg. The idea is that this very quick and very dirty little experiment should give me some more avenues to explore; and something to show people.
I had originally planned to build the leg out of wood, perhaps thin plywood, but I didn’t have any laying around so instead I used some plastic window board which is relatively light and strong.
My package from Cool Components arrived this morning. My choice of prototyping equipment was quickly validated when I plugged together the Arduino and the Pololu servo controller board, plugged in the servos and servo power supply, connected the lot to the pc via a usb cable and had three servos twitching back and forth under the control of the Arduino is no time. The idea is that I can now begin fabricating a leg, connect up the servos and then experiment with leg movement without needing to get the soldering iron out.