I've hit a mental block and can't for the life of me work out how to get around a problem I have. Attached is the NXT-G program my Son and I have written. I did not include the MyBlock as it doesn't affect this issue. The program works really well so far to follow a line and correctly turn either left or right when it encounters a green square at a line junction. We've programmed it to read files we've saved to the NXT 2.0 brick and then use these values to set variables (black, white, 50% grey, and green). This is all running in a loop so far. There is a small parallel sequence running all the time that runs a small set of LED lights that we made by cutting the LEDS off a 8870-1 PF light and soldering it to a plug that fits into the NXT motor port. It's plugged into motor port A. We are using two light sensors to follow the line and using the LEDS mounted along-side the light sensors to eliminate variation due to fluctuating light levels. So far we've managed to get both sensors to always be within 1% of each other and give consistent results wether we calibrate it in the dark or in bright conditions.
What we're trying to do is get a touch sensor to stop the program at any stage of the line-follow loop and run an object avoidance routine which results in it regaining the line once it has manoeuvred around the object. Trouble is, if I put the touch sensor after the line following routine (within the main loop) it usually doesn't detect the object when the touch sensor is pressed because it does so midway through the actions in the loop then hits the object and stops so that it can't finish the actions. I tried putting identical switch blocks at various points to try and get it to detect the object with the touch sensor between actions but this didn't work either. Then I tried running a parallel sequence to the main one that detected when the touch sensor had been pressed and this kind of worked but because the line-follow loop was running in parallel it often interrupted the touch sensor routine causing it to stop. I tried getting the main loop to exit once the touch sensor had been pressed using a logic variable but this also didn't work.
Can anyone offer advice as to how we might go about running these two sequences at the same time but making it so that one does not interfere with the other?
Problem running two continuous processes
Problem running two continuous processes
- Attachments
-
- rescue2.rbt
- (1.95 MiB) Downloaded 393 times
Who is online
Users browsing this forum: No registered users and 2 guests