let w0 = 1
readadc 0,b0
readadc 1,b1
readadc 2,b2
pause 2000
Let b3 = b1
Let b4 = b2
main:
readadc 0,b0
readadc 1,b1
readadc 2,b2
if w0 = 0 then
goto main2
endif ; First part of program
high 5
debug b1
debug b2
if b3 < b1 then
b5 = b1 - b3
else b5 = b3 - b1
endif
if b4 < b2 then
b6 = b2 - b4
else b6 = b4-b2
endif
if b5 > 15 then
high 3
else low 3
endif
if b6 > 10 then
high 1
else low 1
endif
goto main
This is my latest attempt on tackling the problems we get from having constant limits to work with.
In this one we assign a value to b3 and b4 which equal initial b1 and b2 (LDR values). Then we compare the new b1 and b2 with their inital values b3 and b4 deciding whether to stop on motor or not.
the program was working fine, it detected the black line and stopped the correct motor accordingly.
But there was another problem, the time it takes to detect and react to the change is taking too long. By the time one of the LDR's have detected the black line, almost an entire second goes by before the motor switches off. And during that time both LDR's swould have left the line going off track.
solution would probably be in the use of interrupts.
Tuesday, 27 April 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment