Sunday, April 09, 2006

Asuro line following sensor test

So far, so good. The Asuro's line sensors work well, and give a different enough reading when travelling over black and white to be usable.

Transmitting information back to the PC for analysis was a bit of a pain - the line sensor information is stored in an unsigned int array. The serial connection can only send characters, so I had to find a way to convert between the two.

This is not easy. In the end, I had to include the AVR stdio library, and use the function sprintf() to convert the data into a string which I could read in a Python program for capture and formatting. This doubled the size of the flash, which means less space for my programs in the future.

It also seems that the odometry data is pretty useless for counting wheel revolutions. I'm going to try to shield the two photoresistors from external light to enhance the readings.


Anonymous shadow_slicer said...

If your using a program to read the data on the PC side anyway, there's no reason to convert it to a string. An "unsigned char" is just a byte. And (so long as your serial port is set to 8 bit mode) it can send any 8-bit value. To send a 16bit value just send half of it at a time.

This method is a bit more difficult to debug (since you can no longer `cat' the serial port or use `minicom' to see what's going on), but should keep you from needing sprintf...
unsigned int data[2];
SerWrite((unsigned char *) data,2);
Then you have to use the binary read and write routines on the PC to get the data (in C it would be fread instead of fgets).
Also you probably will need to swap the Endianness of the data when it gets to the PC.

As for the odometry data, how are you counting the revolutions?

Hint: Note that sending data out the serial port is not interrupt driven, so every time you send data, you will miss a few revolutions [depending on speed].

1:52 AM  
Blogger Matt said...


Yeah - that's the way to do it. I had a bit of a blonde moment while I was figuring this out. This is also my first attempt at serial communications.

Thanks for the post!

4:11 PM  

Post a Comment

<< Home