Programming the ATTINY2313 w/ Olimex AVR P-20

First I’m going to tell you my objectives for this project I’m working on. The main idea is to find out how fast an RC car is moving. To do this I’m using an IR beacon which will send out an impulse to the microcontroller when the IR signal hits a “black area” of a disc placed on the inside of a wheel that is alternating black to white every few 0.25" in rotation. The microcontroller will compute how fast the car is moving and then send the number to the RS232 connection where it will be wirelessly transmitted to a PC using bluetooth.

I’m just starting to program C for the first time and I’m kind of lost. I’m coding in AVR Studio 4 and using ponyprog2000 to program my mC. I’ve been trying to find some example code to run to see if everything works alright but I’m kind of stuck. I’ve read I have to somehow set the internal oscillator but Atmel only has instructions for well known programmers and not for pongprog. So how do I set the internal oscillator? Can you recommend any books to me for microcontroller programming and/or C programming? Thanks for any help offered. I’m also going to post something over at AVRFreaks.

suggestions:

use an IR beam that passes through a hole (or multiple holes evenly spaced on 360 degrees) in the disk rather than reflective.

Have the IR beam be a 38KHz square wave and have the IR sensor be one of those small $4 IR receivers intended for remote controls. That 38KHz carrier and the receiver’s bandpass filter will improve the signal to noise immensely.

Hall effect sensors with ferrous material or small magnets are another way to do this.

beware wheel slippage errors; might be large.

wireless: If you haven’t already purchased, the MaxStream XBee modules are better/easier/cheaper than bluetooth.

programming: look at the resources listed on avrfreaks.net. Lots of free help there too.

Thanks for the reply.

I like the hole suggestion, I’ll try it out.

The bluetooth stuff has already been ordered so no go on zigbee, not my choice =\

For setting the oscillators, you need to figure out what the fuse settings have to be (there are 16 bits of fuses on the '2313) and give them to ponyprog. Make sure to double and triple check these values; putting bad fuse values in can put the mcu in a state where the programmer can’t talk to it any more, and you’re stuck. A good sanity check is to read the current fuse settings and compare them with the datasheet to make sure they make sense to you.

(They’re called fuses for historical reasons, they’re really just a couple of bytes of Flash with special meanings.)