Taking shape, at last…

I’ve posted about issues I was having with I2C and about mucking about with pull-up resistor values to try and get over the noise problem. Nothing worked for more than a very short time. It was hiding the problem for a bit, rather than fixing it.

I decided to lose I2C from anywhere near the motors. I was controlling two Pololu Baby Orangutan boards with it (some of the time, anyway) so it had been a crucial part of my “design”. After lots of googling for solutions to noise and I2C I decided on the “bollocks!” strategy. Rip it out and replace with something else. Some digging led me to the Arduino SoftwareSerial and I’ve gone with that using just one wire to each BabyO – they only need to “RX” so that’s enough.

There’s still “noise” but it’s much less and easier to overcome. I send each motor driver (left or right) just 4 bytes: a “*”, high byte of motor speed, low byte of motor speed and a checksum which is just the motor speed bytes XOR’d together (yes, it’s crude, but it seems to work). I’m not happy with the way I have the BabyO’s programmed – it could be more efficient and I could use EEPROM to store baud rates to let me faff about with optimise that aspect of it. I’ve got hard wired delays of 10’s of ms for LEDs, that I can’t actually see, left in there too. That’s easy to fix but the good news is this:

This is all driven from a simple Python script, with the robot as an “object”, as is the stepper. On startup I reset the “Arduino”, set the LED (BlinkM clone) to indicate “off” (a faint blue flash).

Then the LED indicates “idle” – which is a green fade in/out and the stepper motor is run to the stops to figure out what angle it can scan and how fast it’s doing it.

Once that’s determined, the LED goes into “amber” mode – a flashing orange light, obvously, and the robot does a 360, pinging for distance and recording headings from the compass.

It all works reliably now. It’s repeatable behaviour, at last.

Now I just need to figure out what to do with the data and start writing the software to let the thing move autonomously without killing the cat, or SWMBO 🙂 I shall persevere with Python, need to learn it anyway and there’s no such thing as a computer language, or OS, that isn’t a bit cack in some way…

All code will end up on GitHub at some point soon. My next target it just to get a picture out of what the ultrasonic sensor is “seeing”, that should be a laugh.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *