3x08M2.bas (2771Bytes)
Hello! I'm a complete Picaxe n00b, but I have read quite a bit online, so hopefully my ideas here are not entirely inane.
I have been playing around with a Raspberry Pi as the brain for a small two-wheeled differential drive robot. It's very simple, but it more or less works.
One feature that seems near impossible with just the Pi itself is to drive the motors at different rates. I'd need two different PWM signals for that, and the Pi only has one PWM output. I've been looking for workarounds, and there are a few, but they don't seem terribly elegant. It seems there would be a few ways to do this with one or more Picaxe chips as peripherals taking simple instructions from the Pi. Originally, I thought I'd just be able to connect up a Picaxe to the Pi over I2C, but it seems it's not that simple. Many of the Picaxe chips can only be I2C masters, not slaves, so that's not going to work. Then I got quite confused trying to figure out the multiple PWM clocks on the 28X2. This being my first Picaxe project ever, I need to simplify.
Then I saw a few projects that used multiple smaller Picaxes to do discrete functions. I think I can handle that. So here is my plan:
- The Pi will still have the high-level logic for the robot.
- To control the motors, the Pi will send a simple command over plain serial to a primary 08M2.
- That primary 08M2 will in turn have simple serial connections to two more 08M2s -- one for each motor -- and will forward the command to the appropriate secondary 08M2.
- The secondary 08M2s will then each drive one half of an L293D. They'll send a high or low to the 1A and 2A (or 3A and 4A) pins, and a PWM signal to the 12EN (or 34EN) pin to control speed.
Questions: Will this work? Have I missed anything obvious?
I even wrote up some code. I have no idea if it will work, but I welcome comments.
Thanks!