Running 3pi sample program on X2?

I’ve just received my X2 and wanted to start out with some code that I knew was good. I am just starting to learn programming, but wanted to at least get my bot moving under RC power, so I looked into the 3pi RC program. I changed a few values to match up with the different pin set up between the boards, built it up and sent it to the board. Everything looked to be going smooth with no errors, but the board is not seeming to respond to the RC inputs. Of course I started troubleshooting with hardware to ensure that my motors, receiver and transmitter were all working properly.

Some of the 3pi code sample specifically state that they cannot be run on the X2, but I did not see this statement on the 3pi RC project. Does anyone know if this program will work and if so, how would I modify it to work on the X2?

Thanks in advance!


Sorry, but the Pololu AVR Library currently does not support the Orangutan X2.

An easy way for you to get started with the X2 would be to download the Orangutan X2 test code from the Orangutan X2’s resource page. Try to compile it yourself and load it on to the X2 and get it to work. Then try making little modifications to it until it does what you want.

But if you really want to adapt the 3pi sample program, here’s what you need to know:

You are probably using the Pololu AVR Library when you compiled your 3pi sample program. This means that when you call any library function, such as “set_motors”, you are running code that was compiled for the ATmega 328 processor but you are running it on ATmega 644. This can definitely cause problems.

I recommend that you change your AVR Studio (or Makefile) compilation options so that you are not compiling the Pololu AVR Library (libpololu_atmega328p.a) in to your project, and remove the #include line at the top that includes “3pi.h”. Then you will get a bunch of compilation errors telling you which functions are missing. These are functions from the Pololu AVR Library that you can not call any more. Now you can write each of those functions yourself!

To help you accomplish this, you can download the Orangutan X2 SPI Wrapper functions from the Orangutan X2’s resource page. I haven’t looked at it carefully, but probably most of the functions you need are there, and you just need to copy them in to your program and call them.

You should also check your program for any lines of code that look like they only work on the 3pi’s hardware.

Let us know if you have specific questions about how to implement some function on the X2.



We should be releasing a new version of the Pololu AVR library in the next few weeks that will add support for the Orangutan X2. Until then, I suggest you start by looking at the SPI wrapper functions available to you, as David suggested, and the demo programs listed under the resources tab of the X2’s product page.

In its current state, the Pololu AVR library was written for a different microcontroller than is on the Orangutan X2 and for controller boards that have different hardware, so it really isn’t intended for the X2. You can port parts of it yourself if you know what you’re doing, but it’ll take some work, so it might be easiest to just wait for the new version of the library. We’ll make a post on the forum when it’s out.

- Ben

Great! Thanks for the information, guys. I will load the demo program and wait for the new library to be published. I think the task of rewriting parts of the code myself may be a bit over my head at this point.


Wondering if the updated library is published yet and, if not, what part of the forum specifically will this be announced on?


Unfortunately, it isn’t ready yet, and it’s probably still a few weeks away. We’ll post an announcement in the Announcement sub-forum when it’s out.

- Ben

Is the updated library available?

Thanks for the update.

Not quite yet; the project got put on the back burner for a while, but I have been working on it over the past few weeks now and the library modifications are just about done. The new version of the Pololu AVR library (with full Orangutan X2 support) should be available Monday or Tuesday if no major bugs are found as I finish testing it. Updating the library’s user’s guide and command reference will take a little longer. I will make a post n the Announcements forum when the new version is up.

- Ben