Subject:
|
Re: Optical card reader for the RCX
|
Newsgroups:
|
lugnet.robotics
|
Date:
|
Sun, 1 Oct 2000 23:54:12 GMT
|
Viewed:
|
1024 times
|
| |
| |
"Giacomo" <lego-robotics@crynwr.com> wrote in message
news:NDBBIEKBGLHLJPCLAJBJOENBCEAA.camp0s@libero.it...
> Hello ! ,
>
> I'm trying to do a optical card reader using the light sensor of the RCX.
>
> I put on a 8x6 board different 2x1 smooth piecies of varios colors ,then i
> slice them near to the light sensor and i got different value depending of
> which color the sensor is seeing.
> I found that:
>
> black ones gives 31 to 34
> yellow and whithe ones gives 46-49
> blu ones 37-39
>
> and when there is nothing the value drops to 28-29.
>
> Now, i'm a bit in difficult way, because i could'nt find a way to correctly
> read the "card" : I'm using two main value, if the sensor reads more than
> 47, then it's a 1, if the value is under 47, it's a 0.
>
> Here is how it should work (but it did'nt):
>
> :loop
>
> if light>30 (if>30 there is a black piece before all the others ,it's a
> start bit)
> THEN
> wait 80 (100 = 1 second)
> read light--->V1 ( V1,V2,V3 are the variables in which I store data)
> wait 80
> read light--->V2
> wait 08
> read light--->V3
>
> end loop
>
> Then it checks and replace the value in the 3 variables,
>
> if V1>46 then put 1, else a 0
> if V2>46 then put 10, else a 0
> if V3>46 then put 100, else a 0
>
> After it adds the tree variables in TOTAL:
> TOTAL=V1+V2+V3 and i get somethings like that: 000, 001, 101,..... .
> Then it checks for the value in TOTAL and then do the respective command.
>
> I put the Wait 80 to have enought time to move the card in front of the
> sensor (by hand).
>
> Schematics of the card: ( "==" is a 1x2 smooth piecie)
>
> OOOOOOOO
> OOOOOOOO
> OOOOOOOO
> OOOOOOOO
> OOOOOOOO
> ========
> 1° is Black _| | | |_ 4° is the 3 color
> 2° is the 1 color _| |
> |_ 3° is the 2 color
>
>
>
>
> I think it's a sincronization problem, on not ?
I read Steve sugestions and they are great. So here comes another option:
You can avoid the sync problem by avoiding the timing technique to read the
card. You could choose a color as a bit separator. Choose one extreme color
for that, for example black. Then choose other 2 colors for 0 and 1 bits,
for example, yellow and blue.
There is still one problem already mentioned by Steve. When your sensor is
between the bricks it will read an intermediate value so you may read a
"blue" when you are between "black" and "yellow". You can solve it by making
many reads and storing the lower value. Since the separator color is an
extreme color black, you always know when you just left reading or just
started reading one. Just compare the lowest value in between and you you
will know if that is yellow or blue.
Another suggestion: Bricks are not always the best materials for this kind
of thing. Most reflective surfaces aren't because they have some big
variation from the value read depending of the exact angle of reflection.
Even the black brick has some reflection. If you are willing to use non-lego
cards, try to use something like paper painted by diferent pen colors. You
will notice you will have more steady values.
good luck,
Mauro Vianna
|
|
Message is in Reply To:
| | Optical card reader for the RCX
|
| Hello ! , I'm trying to do a optical card reader using the light sensor of the RCX. I put on a 8x6 board different 2x1 smooth piecies of varios colors ,then i slice them near to the light sensor and i got different value depending of which color the (...) (24 years ago, 28-Sep-00, to lugnet.robotics)
|
3 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|