QTIs sensors
Khanh
Posts: 9
Im running four qtis on my boe bot and is it possible to make a counter where when it make certain amount of turns the qtis will stop and the robot will do another task?
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
case %0000 is refering to when the qti sensors are not detecting any line
If the former, you will need to send a known count of pulses to the 'bot and see how much turn you get for a given number of pulses, then you will have some real values that you can use to control the amount of turn.
For example:
Run the code, and measure how far your 'bot turns. Too much? Not enough? change the number till you get the desired turn amount.
Now lets say when you're done that 25 pulses gives you 1/4 turn, 55 pulses gives you a 180 degree turn, etc -- you can plug that number in for a desired turn amount:
There are more elegant ways to approach this, primarily by establishing some known pulse counts that correspond to units of useful measurement. Also my simple loop example much less ideal than a good state machine that sets final values for pulses and motor speeds, then allows execution of a single "set motor speed" routine.
See Andy Lindsay's writeup on "go to and find closest object" in the Stamps in Class forum. His experiments have you establish known pulse counts for turns by brads -- so you can feed an angled (in brads, not degrees) to the motor subroutines, which convert the brad turn amount to a pulsecount, then do that many pulses. So you can set your 'bot to turn 32 brads (45 degrees), 64 brads (90 degrees), etc., with some reliability.
And don't hesitate to post your own code
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
that's the whole code that im using.
notice at case %0000 i try to make it where if it turned more than 2 times, at the third turn, it will turn around, back up, and activate another servo. This code right now does that at the very 1st turn, i try to change value but it does not work at all.
thank you so much for trying to help, i know im not the best person when it comes to describing the problem
Given the behavior you are describing, is it possible that what you think is the EOL state (qtis = %0000) is actually another state? In other words, have double checked that the QTI readings you are getting are what you expect from your lines and that you entering the correct state in your SELECT/CASE choices?
Lastly, and this is probably unrelated, but you never know, you need to have some kind of pause in the main select/case loop so you don't overdrive the servos -- right now you only pause your 20ms in the for:next loops for the start and the eol case, e.g.:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
If you get no beeps, you are not hitting that state. You may need to increase/decrease freqout time and freq, and subsequent pause, to get the sound you want.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST