Please, Help with RCTIME!!
Eduard
Posts: 21
Hi!
I want to differ between three cubes of differents colors (Black, Purple and Yellow) using a LDR.
I've three different LEDs (blue, green and red) to create three differents values in the LDR for each color of the cube.
I do this :
Boe-Bot always says "This cube is yellow","This cube is purple","This cube is black" at the same time.
When I DEBUG the RCTIME value, I often see that the value is more bigger (have mor decimals) than the value that I can put in the program, so I've to quit the three last decimals.
What I'm doing wrong ?
Sorry if my English isn't very good.
Regards from Barcelona!
I want to differ between three cubes of differents colors (Black, Purple and Yellow) using a LDR.
I've three different LEDs (blue, green and red) to create three differents values in the LDR for each color of the cube.
I do this :
'Sensor '{$STAMP BS2} '{$PORT COM1} '{$PBASIC 2.5} ' -----[noparse][[/noparse] Programa ]---------------------------------------------------- Green VAR Word Red VAR Word Blue VAR Word leds: HIGH 4 PAUSE 3000 HIGH 7 PAUSE 1 RCTIME 7, 1, Green DEBUG HOME, DEC5 ? Green LOW 4 HIGH 2 PAUSE 3000 HIGH 7 PAUSE 1 RCTIME 7, 1, Red DEBUG HOME, DEC5 ? Red LOW 2 HIGH 0 PAUSE 3000 HIGH 7 PAUSE 1 RCTIME 7, 1, Blue DEBUG HOME, DEC5 ? Blue LOW 0 IF Green >10000 <13000 AND Red <00030 >00002 AND Blue >14000 <15500 THEN GOTO yellow: IF Green <19500 >17500 AND Red <00029 >00002 AND Blue <14000 >12000 THEN GOTO purple: IF Green >50000 AND Red <17000 AND Blue >50000 THEN GOTO black: yellow: DEBUG "This cube is yellow" purple: DEBUG "This cube is purple" black: DEBUG "This cube is black" GOTO leds END
Boe-Bot always says "This cube is yellow","This cube is purple","This cube is black" at the same time.
When I DEBUG the RCTIME value, I often see that the value is more bigger (have mor decimals) than the value that I can put in the program, so I've to quit the three last decimals.
What I'm doing wrong ?
Sorry if my English isn't very good.
Regards from Barcelona!
Comments
I've done this:
But still doesn't work.
It always says yellow.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Smile ... It increases your face value!
needs to be re-written:
IF Green>10000 AND Green<13000 AND Red>2 AND Red<30 AND Blue>14000 AND Blue<15500 THEN GOSUB Yellow
Likewise the other IF...THEN statements
I think that GOSUB...RETURN isn't the way to go.· You should GOTO the Yellow, Purple, Black subroutines and end each with "GOTO Leds" --
black:
DEBUG·"This·cube·is·black"
GOTO Leds
Post Edit -- attached slightly updated .BS2
Post Edited (PJ Allen) : 2/8/2009 10:42:49 PM GMT
If I put a "END" after the last IF and before yellow, it always says "purple". [noparse]:([/noparse]
Thanks a lot!!, but still doesn't work.
With eduard.bs2 it says that the cube is always black.
With eduard_2.bs2 it says that the test failed or that the cube is black.
Post Edit, attached some photos of the Debug Terminal.
When the DEBUG terminal shows the LDR value, it shows this:
But I can't introduce the same numbers that the DEBUG Terminal says because they're too big (like the Red value).
Can be there , the problem ?
Post Edited (Eduard) : 2/8/2009 11:01:36 PM GMT
Are the DEBUG values coming back from the RCTIME routines within the ranges?·
What if you plugged in values for Red, Green, Black (with the RCTIME routines commented out)?
img23.imageshack.us/my.php?image=85447161rc9.jpg
img23.imageshack.us/my.php?image=66842695rl1.jpg
img22.imageshack.us/my.php?image=91424587av0.jpg
But I can't introduce the same numbers that the DEBUG Terminal says because they're too big (like the Red value).
Can be there , the problem ?
I haven't understand this :
I have attached a version of your program with values appropriate for Yellow and it responds with "This cube is Yellow"
Try changing the R,G,B values yourself.
I've tested your new file, and it always says "This cube is yellow" and the leds doesn't work.
If I change the Plug-in Values it says "This test failed".
What do you mean with changing the RGB values ? Am I putting well in the programm the LDR values that the DEBUG Terminal shows me?
Sorry, but I don't know why is not working. Months ago it was working perfectly in another place and conditions; the LEDS, the LDR, the Boe... all components were the same, and it was working with a program that was quite similar as the first program that I posted here in this post. You can see a video of it:
www.youtube.com/watch?v=R3nCRU3TwCg
What do you mean with changing the RGB values ?"
Well, it is a simulation.· The LEDs do not turn on.· I made it so that it has Red, Green, and Blue (R.G.B) values appropriate for a "Yellow" result, to test the validity of Color Test ranges / arguments.· I made a similar test, attached, that tests all 3.· So, that seems right.·
You need to look at your RCTIME results·and·check that they are within the ranges given for Yellow or Purple or Black.
Thanks again for the test!
I don't know how to put the good RCTIME value in the program.
When I see the DEBUG Terminal it says, with every colour, the RCTIME value.
But I don't know well how to put these values in the program.
These are the RCTIME results that I see on the Debug Terminal:
Yellow cube:
Green = 10638
Red = 0204919
Blue = 144745
Purple Cube:
Green = 19137
Red = 0290655
Blue = 164388
Black cube:
Green = 00000
Red = 1547200
Blue = 00000
For example, when I want to put in the program the Red value of the Black cube (Red=1547200), I can't. It says me that "Constant exeeds 16 bits", so I've to quit the last two zeros, like this: 15472.
I supose that there's the problem, but how I can resolve it ?
I think you need to get that sensor situation right.· Optimize your sensor or change your color testing ranges to accomodate.
In the test, the values are Words, so nothing > 65,535.
In general, all Red values are lower tha the Red and Blue ones... but they're constant.
I don't know how to put well in the program the RCTIME data:
Please run the attached program and post a screen-shot of the Results.
Post Edit -- typo.
Post Edited (PJ Allen) : 2/11/2009 12:42:42 AM GMT
Some Numbr = 1234
…then printed…
Results = 98
…your display could look like:
Results = 981234 because you didn’t erase to the end of line. After printing the value add the following to your DEBUG…
DEBUG “Results = “, DEC value, CLREOL
I hope this helps. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
Thanks a lot again.
I've screen-shoted the results of the new attached program.
These are the results for the Yellow Cube:
These are the results for the Purple Cube:
And these are the results for the Black Cube:
It works SOMETIMES. With BLACK works OK, but sometimes confuses purple and yellow.
It continues confusing YELLOW and PURPLE. What can I do to solve this ?
I'm feeding the Boe-Bot with a simple homemade power supply (4 diodes, 2 condensators and a 7806). Can this be a problem for the Boe-Bot?
Post Edit:
Hi again! I've changed some values of the program. There's no Red color check in the detection of the Yellow Cube.
It seems that it works better, saying good the color of the cube the 95% of times.
Post Edited (Eduard) : 2/11/2009 8:35:45 PM GMT
It seems like you're on the right track.·
Thanks to all, specially to PJ Allen !
You can see a video of the project here:
Thanks again!!!