Extending the 3pi RC example

Hi tim, thanks for the compliments.

The reason the 3pi RC example says that it would be easy to add a third channel on a port B pin is because you could devote an entirely separate interrupt to processing that channel. Pin-change interrupts on the ATmega328 are grouped based on their ports; all the pins on port B will trigger the same pin-change interrupt when the state of any one of them changes (assuming the PCI has been enabled for all of them). This means that you need to spend time in the ISR determining which pin has changed before you can act, which complicates things. The 3pi RC example is fairly simple; adding another channel on port C or D will make it more complicated.

Note that now the Pololu AVR library has an OrangutanPulseIn library that makes it simple to read RC channels (it handles all of the pin-change interrupt code for you). This portion of the library isn’t yet documented in the user’s guide or command reference, but I wrote a forum thread about it that might help you learn how to use it:

I will be documenting it soon, and, if I can find some time, I’d like to create a version of the Pololu 3pi RC example that uses it.

Note, however, that there really aren’t a lot of available I/O lines on the 3pi, so you won’t easily be able to connect more RC channels without removing the LCD. I recommend against using PD1 because the red LED on that line acts as a strong pull-down that can make the RC signals unreliable or even undetectable (depending on how strongly your RC receiver can drive its outputs). You can try it and see if you get pulses with a high enough voltage to detect, but if you have trouble with signals on PD1, you’ll know why.

I have no experience with wireless control of the 3pi, but it should be pretty easy with a wireless module that outputs TTL (5V) serial (see our serial slave sample program for the 3pi). One of our LV Bots members (Byon) made a wirelessly controllable 3pi, so you might be able to email him and get some pointers (or email him and ask him to reply to this thread, which would benefit everyone who wants to add wireless to the 3pi). You could also try posting to the LV Bots yahoo group.

Good luck with your projects, and please share them with us as they progress!

- Ben