Pete is half finished robot that uses some basic 2d mapping...

My robotics project is named Pete.  I was learning while I wrote it, and I'm not very experienced, so take what you can from it.  There are lots of comments and notes to self I wrote while I made the code.  The main 2d mapping loop uses an algorithm that I see now has some major room for improvement.  Basically from what I understand now, the easiest way to map is to pick delays that leave enough time for the sensor to gather it's data and the servo to move.  Then let your servo run and experimentally or with some clever math skills find out the frequency or rate it takes for the servo to move from one side to another.  Then just save the data independent of where the servo is going, and store the data instead according to the frequency you have discovered.  This approach seemed to give me better results.  If I recall I left the project where I was just making a scan or two then sending the data to my computer.  I  was able to get the scan frequencies from my computer and get everything working pretty well, but I'm not sure exactly what stage this version was left in.  There may be some debug code I got from Dave Hylands in the project.  I'm not totally sure, but in any case I learned a lot from his work.  I hope this code is useful.

The project includes code that I tried to keep encapsulated and simple.  I found when I tried to write libraries that supported all the features possible it was too complicated and actually harder to use.  I found it easiest to look up the settings I wanted in the AVR specs, and have a basic skeleton of code I could just plug these settings into.  Hopefully people can just copy and paste the code they need, and look up any settings they may want to change.  There are some sections that are left over from my earlier bloated and less effective code.  Note that the files Oar.c and Oar.h are the main driver, why I named it Oar I don't know.

The project was done with AVR Studio using the GNU Win AVRcompiler.  It was written for the ATMega 128 chip.  If your looking for simple code to do:

  • PulseWidth Modulation (I think I used phase and frequency correct PWM)
  • Servo Control w/ PWM
  • Simple timer generated interrupts
  • Serial (uart) interface
  • Trig table (needs some testing I only know it works for the little I've done with it)

Here are links to the project and some other files: