encoding of LED

Thread Starter

bokkamaanus

Joined Feb 9, 2009
5
So I am trying to make a bi-color LED blink a code such that it could be decoded by a camera (I am using this for robot tracking purposes). I am using an attiny85V microcontroller and an avrisp mkII programmer. For compiling, I am using AVR studio 4. I am hoping to encode the LED with a Manchester code. Can anyone please give me any ideas/resources/few lines of code to help me get stated. I am able to blink the LED and make it toggle between the two colors. Please keep in mind that I am a newbie. Thanks a lot!
 

Thread Starter

bokkamaanus

Joined Feb 9, 2009
5
well, I want to make the LED blink in a pattern that could be decoded by a camera. for example, it could blink a number a binary that can identified and decoded by a camera. a possible method would be to make the LED blink a code using manchester encoding technique. SO MY QUESTION IS: how to program the attiny85 to make an LED connected to it blink such a pattern. Thanks
 

thatoneguy

Joined Feb 19, 2009
6,359
For a Red/Yellow/Green (Bi-Color) LED to show up on a camera:

Green is Anode +
Red is Anode -
Yellow is AC (+/- > 200Hz for camera to 'see yellow')

Pin1 = Anode
Pin2 = Kathode/Cathode

Green:
Pin1 = High
Pin2 = Low
Pause xx (2 frames on camera)

Red:
Pin1 = Low
Pin2 = High
Pause xx (2 frames on camera)

Yellow:
Pin1=High
Pin2=Low
Pause x (very very short time)
Pin1=Low
Pin2=High
Pause x (very very short time)
Goto Yellow: (at least 50 times per frame)


I'm not sure why 3 colors are needed, but the above is how to "make" the colors, timing is very dependent on camera for max data rate.

If using a camera, why not use 9 single color LEDs and send data in parallel? 8 data, one for clock.
 

beenthere

Joined Apr 20, 2004
15,819
This is how it's done - http://en.wikipedia.org/wiki/Manchester_code.

The camera, of course, is not the decoder. The video feed has to go to a computer for that function. Be careful about data rate, as the camera probably has a 30 or 60 Hz scan. It can only respond to one LED coming on once per frame. If the LED goes dark, it will not register until the next frame.

I might try something less timing critical, like individual Morse characters, with a bit rate about 1/2 the camera frame rate.
 

Thread Starter

bokkamaanus

Joined Feb 9, 2009
5
this is something I am aiming for:
For example the number 5 in binary would be 0000 0101. Using Manchester encoding (01 for 0 and 10 for 1) the encoding would be 01010101 01100110 (the number 5).
So I want to make the LED have a unique ID like a barcode, i.e, it blinks a 2 or 3 digit number that could be read by the camera.
I don't really see how the color of the LED would matter or how the bi-color property could be used to make it blink a number.
do i use like a delay function or alternate on/off function for the LED?
 

efox

Joined Aug 8, 2006
11
I dont know the avr (though would like to learn)

you would need to create a function to encode the data

you nee to create a int16 variable, say int16 encode

read the LSB of your data, and if its 1, add 0x8000 to encode. If its a 0, add 0x4000 to encode. Then shift data left once. Shift encode twice left.

If data was 0000 0101
Then the LSB is 1 so add 0x8000 to encode
encode = 1000 0000 0000 0000

Shift data left once 0000 0010
shift encode twice 0010 0000 0000 0000

repeat...test LSB and add to encode whatever...

once you get your encode completed, you can do something similar and test every other bit, and do something, delay for a certain time period, and then shift twice...

That should give u a start on how to do it. You can figure out better, efficient or other ways to do it.
 
Top