Check out the new projects site for A-i-S www.adventuresinsilicon.com

Monday, August 25, 2008

Separate the light from the dark....

Well I decided that it is high time my robot can see the world for what it is.....or at least for what 4 LDRs setup on voltage dividers can reduce to a voltage range picked up by the AVRs built in ADCs :P

Using LDRs that I think I got from Futurlec I soldered a 100k ohm resistor to one leg. Now if you apply 5V on the free leg of the resistor, zero (Ground) on the free leg of the LDR you can read a reliable 0.7V to 4.2V range from GND to the soldered leg of the LDR.

Now I am going to put them on a Servo facing away from each other. With 180 degrees of servo rotation, I can rotate sensors to calibrate from each other's readings (assuming the environment doesn't change the light conditions in between servo movements.

More tomorrow....

Thursday, August 14, 2008

When at first you don't succeed, try a thousand more times

Ok, so I am going quickly insane here.

I have a DS1307 (RTC) which has a perchant for I2C (TWI) and Packed BCD. I have set up a nice I2C routine to speak to it and receive back information such as time (hours, minutes, seconds etc).

All looks ok when you feed in 0,0,0 but when I feed in 0:59:30 and wait for it to hit one minute, it then wraps to 0:40:00 and counts up from there.

I have checked the data going in and out and have no idea....

Anyway I left that for a moment and decided to update the code that receives servo position commands on my MEga168V board on my robot. I implemented the cmdline demo from Procyon and it worked flawlessly.

Now I can send "servo 1 75" and it will send servo 1 to the 75% mark. All good I say.

Wednesday, August 13, 2008

Bestill my beating silicon heart

Ok, here is a neat C function for converting BCD to Binary:

uint16_t bcdtoi(uint16_t bcd_number)
{
uint16_t integer;

integer = ((bcd_number&0x000F) >> 0) * 1;
integer += ((bcd_number&0x00F0) >> 4) * 10;
integer += ((bcd_number&0x0F00) >> 8) * 100;
integer += ((bcd_number&0xF000) >> 12) * 1000;

return integer;
}
If you only want to deal with 8 bit numbers then feed in 8 bit variables and comment out the last two lines inside the body.

I have used this with the AVR Mega32 to ead in input from a DS1307

Tuesday, August 5, 2008

A moment in time

I've decided to use the Procyon wrappers of the TWI implementation.

I've struck an issue that the procyon code didn't compile once I linked in the i2c header. So now I am running a test project to ascertain a known good implementation to carry into my bot's code.

Monday, August 4, 2008

You take the high road, I'll take the side track

Well today I tried to get the DS1307 working but to no avail.

I was trying to reuse the code used to drive the IR sensors but it doesn't have everything TWI/I2C needs.

The solution? Implement the avrlibc version of twi and follow the examples. Hopefully I will be able to do this tomorrow night.

On a side track my Arduino does everything is says it could, very interesting and polished little performer.