Problem programming in PBASIC
Hey, I need to send a voltage out on pin 7 , then record the output from pin 3, the input needs to be an analogue signal, so I am trying to use the RCTIME function in PBASIC but I'm getting an error, here's my code,
'{$STAMP BS2}
'{$PBASIC 2.5}
MyByte VAR Byte
DO
HIGH 7: PAUSE 1: RCTIME 3, MyByte: INPUT 7
DEBUG HOME, byte MyByte
PAUSE 100
LOOP
I get the error, Expected ',' after the variable MyByte. Thanks in advance
'{$STAMP BS2}
'{$PBASIC 2.5}
MyByte VAR Byte
DO
HIGH 7: PAUSE 1: RCTIME 3, MyByte: INPUT 7
DEBUG HOME, byte MyByte
PAUSE 100
LOOP
I get the error, Expected ',' after the variable MyByte. Thanks in advance
Comments
' {$STAMP BS2}
' {$PBASIC 2.5}
MyByte VAR Byte
DO
HIGH 7: PAUSE 1: RCTIME 3,1,MyByte: INPUT 7
DEBUG HOME, DEC MyByte
PAUSE 100
LOOP
The output is always varying !!!! It never stays the same value for one colour, what m I doing wrong ?
Post Edited (rusty009) : 1/13/2009 5:13:13 PM GMT
DO
HIGH 7
HIGH 3
RCTIME 3, 1, MyByte
DEBUG CLS, DEC DEC MyByte
PAUSE 100
LOOP
Keep in mind, the value for MyByte will be the time it takes for the capacitor in the QTI to charge so that it's delta V has caused Pin 3 to drop below 1.4V.
1. How do you have the QTI mounted compared to the test panel?
I've found that very small movements can have a significant effect on the amount of IR reflected back to the sensor.
2. What is the room like - you may have other IR sources that could be affecting the reading.
3. How much is the variation in the reading - it may not be significant with the accuracy of these devices. Remeber, the QTI was developed to detect the white edge of a black sumobot circle, so it is not an accurate color meter. If it gives a reading that can tell the difference between black and white it is meeting it's original design.
Post Edited (MSDTech) : 1/14/2009 1:45:54 PM GMT
I have A Boe-Bot robot with a BASIC Stamp II installed. My boe-bot is required to start at a random distance from a white line, then drive forward and when the boe-bot passes the white line, it needs to stop moving. The white line will be on a carpet which will either be red or blue depending what room we are in, so my robot has to detect white and white alone, no other colour.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.
It isnt just the QTI sensor either, I have just tried with a photoresistor and it does exactly the same. I move the wire around and the value from RCTIME changes ! Even if there is nothing connected between 7 and 3, the RCTIME is changing, what can I do ?
edit: Do i need to put a capacitor on the circuit myself?
Post Edited (rusty009) : 1/14/2009 5:26:08 PM GMT
http://www.parallax.com/Portals/0/Downloads/docs/prod/robo/28108-QTILineFollower-v1.1.pdf
You only need one of the modules - the first shown is using the same pins you are, so all you would need to add is the resistor. This does not use RCTIME. The output becomes digital with 0 = white and 1 = everything else.
If the carpet is IR reflective, you will probably need to use the RCTIME to see if there are specific ranges that can be used to detect the white line as was recommended by Andy. This method will probably have a lot of noise (the values will jump around) but hopefully they will cluster enough that you can say "A reading below x is white, so stop the robot."
Let's make sure one QTI is working right. Get well away of sunlight streaming in from windows and incandescent lights and then try page 2 of the link that MSDTech posted. Test it with a white piece of paper with black vinyl electrical tape. (Since some printers with black ink still reflect IR about as well as white, black vinyl electrical tape is a more reliable test.) Also, make sure the surface is only 1/16 to 1/4 inch away from the sensor. The decay time measurements should be fairly small when the paper reflects IR back to the sensor and fairly large in comparison when the black electrical tape is in front of the sensor abaorbing the IR. If you take the paper away, the measurements will depend on ambient infrared. If you are well away from IR sources such as incandescent lights and sunny windows, the measurements should be fairly large when no surface is in front of the sensor.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.