The following is the final program:
Showing posts with label Program Design Process. Show all posts
Showing posts with label Program Design Process. Show all posts
Thursday, 29 April 2010
Final Program
The chief programmer presented the initial final program to the group the day before the final test, though on occasion the buggy would stop when it lost the posistion of the track. As a result the project manager suggested a feed back reversing system whenever the central track relation sensor recorded a white background. This was then installed to produce the final program, which was then calibrated by the programmer.
The following is the final program:


The following is the final program:
Labels:
Mark Hawkins,
Program Design Process,
Sandra Donohoe
Monday, 26 April 2010
New code for motor directions and buggy program
Once the final assembly was carried out the final changes were made into the program:
Motor directions

Pen-ultimate program (ready to be assessed by the group and approved by the project manager)


Motor directions
Pen-ultimate program (ready to be assessed by the group and approved by the project manager)
Labels:
Program Design Process,
Sandra Donohoe
Program roadsymbols part
The roadsymbols section of the program was altered in order to allow the buggy to read specific signals and carry out a strict task depending on which sensor is activated.
It follows the same principle as the linefollowing section where the program checks accordingly innitially if the middle sensor has been placed above a dark surface and then whether any of the other conditions were met.
i.e it follows the magnetic strip then at the end of the symbol reads the final stage then depending on which sensors are also showing signs of being positioned over a dark strip will carry out 1 of three tasks. (saves memory space)

It follows the same principle as the linefollowing section where the program checks accordingly innitially if the middle sensor has been placed above a dark surface and then whether any of the other conditions were met.
i.e it follows the magnetic strip then at the end of the symbol reads the final stage then depending on which sensors are also showing signs of being positioned over a dark strip will carry out 1 of three tasks. (saves memory space)
Labels:
Program Design Process,
Sandra Donohoe
Threshold levels
The following thresholds required changing when it was tested (it will be applied to the current program)

Important Note: these will require recalibration as:
- these tests are specifically designed for the prototype. To obtain the final thresholds we would need to wait until the final completed assembly as currently the circuit board is not low enough to show the likely threshold levels (and at its present height the sensors can react to shadows).
- Depending on where the buggy will be placed (floor or table) and the time of day the light intensity will vary. This will need to be accounted for and adjusted appropriately.
-time delaysd would also require calibration for turning 90 deg and linefollowing
Important Note: these will require recalibration as:
- these tests are specifically designed for the prototype. To obtain the final thresholds we would need to wait until the final completed assembly as currently the circuit board is not low enough to show the likely threshold levels (and at its present height the sensors can react to shadows).
- Depending on where the buggy will be placed (floor or table) and the time of day the light intensity will vary. This will need to be accounted for and adjusted appropriately.
-time delaysd would also require calibration for turning 90 deg and linefollowing
Labels:
Program Design Process,
Sandra Donohoe
Code for motor directions
Whilst testing the prototype other noticeable issues were found and have lead to the following changes.
The original outputs to the motor drive (to turn the wheels in a specific direction) were noticed to have caused the buggy to have turned and followed a different root to what was intended by the project brief.
This was noticed particularly when testing the symbols code (particularly the middle symbol as it was found to go forwards and turn right rather than go forwards and then reverse):

I then changed the program to take into account of the new conditions:
The original outputs to the motor drive (to turn the wheels in a specific direction) were noticed to have caused the buggy to have turned and followed a different root to what was intended by the project brief.
This was noticed particularly when testing the symbols code (particularly the middle symbol as it was found to go forwards and turn right rather than go forwards and then reverse):
I then changed the program to take into account of the new conditions:
Labels:
Program Design Process,
Sandra Donohoe
Sunday, 25 April 2010
tested prototype buggy
As Anand finished the holes for the acrylic layers, I made a prototype buggy to test some of the capabilities and properties the final design would have (where there could be issues and how could they be solved) as well as getting an opportunity to test the code to sort out the main issues before calibration can begin for the final model.
My findings show:
The test clearly shows that due to the light weight properties of the buggy, it is travelling at much faster speed than anticipated (a section would need changing in the program to compensate).
Another factor requiring attention was the possibility that all three sensors would find themselves on a dark line (the buggy would carry on moving in a random fashion as this situation was not accounted for in the first program).
Therefore program 1 was changed to list the the most plausible actions which the buggy could undertake should the middle sensor shows dark levels.
A double "if...then \ elseif...then \ else \ endif" statements was imposed.
The main statement was to check if the conditions showed b2 as being over a dark strip (which would lead into the next statement) else it would stop (assume under light conditions). This eliminated not only the condition should all the sensors be found over a dark strip but allowed the side sensors to be checked every cycle to reduce the chances that the buggy does not find itself under the "pause" condition while reading the b2 sensor and miss the side side sensor going bellow the threshold level as it comes across a turn.

The 4 plausible combinations when b2 is on are: all on, middle and left, middle and right and only middle sensor activated.

I designed the program as the team initially interpreted from the brief for a toggle switch (which would be sourced or an elastic band could be tied round the provided push switch to mimic the behaviour of a toggle switch).

Another factor which would need changing are the threshold light levels that the LDRs react to, the motor directions and delay timings.
Prototype movies :
Proudly sponsored by Kleenex and by Jaws the revenge
My findings show:
The test clearly shows that due to the light weight properties of the buggy, it is travelling at much faster speed than anticipated (a section would need changing in the program to compensate).
Another factor requiring attention was the possibility that all three sensors would find themselves on a dark line (the buggy would carry on moving in a random fashion as this situation was not accounted for in the first program).
Therefore program 1 was changed to list the the most plausible actions which the buggy could undertake should the middle sensor shows dark levels.
A double "if...then \ elseif...then \ else \ endif" statements was imposed.
The main statement was to check if the conditions showed b2 as being over a dark strip (which would lead into the next statement) else it would stop (assume under light conditions). This eliminated not only the condition should all the sensors be found over a dark strip but allowed the side sensors to be checked every cycle to reduce the chances that the buggy does not find itself under the "pause" condition while reading the b2 sensor and miss the side side sensor going bellow the threshold level as it comes across a turn.
The 4 plausible combinations when b2 is on are: all on, middle and left, middle and right and only middle sensor activated.
I designed the program as the team initially interpreted from the brief for a toggle switch (which would be sourced or an elastic band could be tied round the provided push switch to mimic the behaviour of a toggle switch).
Another factor which would need changing are the threshold light levels that the LDRs react to, the motor directions and delay timings.
Prototype movies :
Proudly sponsored by Kleenex and by Jaws the revenge
Labels:
Program Design Process,
Sandra Donohoe
Monday, 12 April 2010
System principle
The following images illustrate the general connection system used by most line following robots:

The sensor board will be set up using the following template design:

As in our design we have opted to use 3 LEDs along with their paired LDR. The middle is mainly used as a reference to ensure the buggy does not lose track of the line.
An alternative is the use of a 2 LED and sensor system:

In this case the program is used to follow the line by tracking which sensor reads a decrease in light intensity and then moving the motors accordingly to avoid going off course. This scenario is achievable for the line-following section of the program however will have issues with the symbol reading section.
I had therefore opted and discussed with the team that it would be best to retain the middle sensor and LED to use as a guide in the line-following section and initially for the symbol reading.
Scope of Program
During the period that the program is running, 3 LED’s will remain turned on and analogue readings will be taken and processed from the LDRs.
Depending on the surface the LEDs are placed over i.e. dark strip or light floor, the amount of light reflected from the ground and picked up by the LDRs will vary.

The image shows light reflection trends depending on which surface the LED has been positioned over.
If the dark strip is underneath the sensor and little/no light from the LED is reflected back to the paired LDR while if the LED shines light above the white floor then more light will be reflected back to the sensor causing the LDR to produce different analogue readings.
This is beneficial to the PicAxe controller and the program as these will cause analogue variations (using 3 ADC) that can be measured and execute the program in a particular format.
The majority of the program is designed to use the dark strip area as a reference guide for the buggy’s location.
If certain conditions are met (i.e. side sensor finds itself above a dark strip/curve) then the buggy turns right or left by changing the direction of the motor, otherwise it maintains its forward course. The other section of the program focuses on the middle sensor following the line and depending on the conditions at the end of the symbol (on each mat) it carries out a specific function.
The following is an image of a typical buggy design:

http://www.fastcharged.org/robotics/firstrobot
http://www.micahcarrick.com/files/failurebot5/complete.jpg
http://www.robotgames.net/robotgames/Event_Rules/2002_line_follower.htm
http://www.ermicro.com/blog
http://www.esskayinstitute.com/LFROBOBLK.jpg
http://www.robotroom.com/NumberTwo9.html
http://www.leang.com/robotics/info/articles/linesen/pcb1.jpg
The sensor board will be set up using the following template design:
As in our design we have opted to use 3 LEDs along with their paired LDR. The middle is mainly used as a reference to ensure the buggy does not lose track of the line.
An alternative is the use of a 2 LED and sensor system:
In this case the program is used to follow the line by tracking which sensor reads a decrease in light intensity and then moving the motors accordingly to avoid going off course. This scenario is achievable for the line-following section of the program however will have issues with the symbol reading section.
I had therefore opted and discussed with the team that it would be best to retain the middle sensor and LED to use as a guide in the line-following section and initially for the symbol reading.
Scope of Program
During the period that the program is running, 3 LED’s will remain turned on and analogue readings will be taken and processed from the LDRs.
Depending on the surface the LEDs are placed over i.e. dark strip or light floor, the amount of light reflected from the ground and picked up by the LDRs will vary.
The image shows light reflection trends depending on which surface the LED has been positioned over.
If the dark strip is underneath the sensor and little/no light from the LED is reflected back to the paired LDR while if the LED shines light above the white floor then more light will be reflected back to the sensor causing the LDR to produce different analogue readings.
This is beneficial to the PicAxe controller and the program as these will cause analogue variations (using 3 ADC) that can be measured and execute the program in a particular format.
The majority of the program is designed to use the dark strip area as a reference guide for the buggy’s location.
If certain conditions are met (i.e. side sensor finds itself above a dark strip/curve) then the buggy turns right or left by changing the direction of the motor, otherwise it maintains its forward course. The other section of the program focuses on the middle sensor following the line and depending on the conditions at the end of the symbol (on each mat) it carries out a specific function.
The following is an image of a typical buggy design:
http://www.fastcharged.org/robotics/firstrobot
http://www.micahcarrick.com/files/failurebot5/complete.jpg
http://www.robotgames.net/robotgames/Event_Rules/2002_line_follower.htm
http://www.ermicro.com/blog
http://www.esskayinstitute.com/LFROBOBLK.jpg
http://www.robotroom.com/NumberTwo9.html
http://www.leang.com/robotics/info/articles/linesen/pcb1.jpg
Labels:
Program Design Process,
Sandra Donohoe
Tuesday, 23 March 2010
Program
Based on work in the lab the group has opted to use and modify the second program to obtain the following:
______________________________________________________________________
high 0
high 1
high 2 'switchon LEDs
Main: 'switchstatement
If pin7 =0 then
'if pin7 (switch) =0 then carry out linefollowing program
Goto linefollowing
Else 'if pin7 (switch) =1 then carry out roadsymbol program
Goto roadsymbols
Endif
Goto main
linefollowing:
readadc 0, b1 'Sensor LEFT
readadc 1, b2 'Sensor MIDDLE
readadc 2, b3 'Sensor RIGHT
'keep checking the state of each of the analogue sensors before carrying on with the program to avoid unwanted loops
if b2 <= 20 then 'if b2 is above the magnetic strip then carry out the program
high 4
low 5
high 6
low 7
'time delay?
if b1 <= 20 and b2 <= 20 and b3 > 20 then
' Calibrate - if b1 and b2 are above the magnetic strip and b3 is not then turn left
high 4
low 5
low 6
high 7
pause 1000 'turn delay
goto linefollowing 'goto linefollowing and move forwards
elseif b1 > 20 and b2 <= 20 and b3 <= 20 then
' Calibrate - if b2 and b3 are above the magnetic strip and b1 is not then turn right
low 4
high 5
high 6
low 7
pause 1000 'turn delay -low to avoid missing the turn
goto linefollowing 'goto linefollowing and move forwards
endif
else 'if b2 is not on the magnetic strip motors don't run forwards and goes back to switchstatement (main)
low 4
low 5
low 6
low 7
goto main
endif
goto linefollowing
roadsymbols:
readadc 0, b1 'Sensor LEFT
readadc 1, b2 'Sensor MIDDLE
readadc 2, b3 'Sensor RIGHT
debug
'keep checking the state of each of the analogue sensors before carrying on with the program to avoid unwanted loops
if b2 <= 20 then ' middle sensor must be placed over magnetic strip line for the program to be executed or it returns to switchstatement
high 4
low 5
high 6
low 7
pause 500 'moves forward to read symbol
if b1 <= 20 and b2 <= 20 and b3 > 20 then ' Calibrate - if b1 and b2 are above the magnetic strip and b3 is not then carry out the following
high 4
low 5
high 6
low 7
pause 3000 'forward
low 4
high 5
high 6
low 7
pause 2000 ' 90deg left
high 4
low 5
high 6
low 7
pause 3000 'forward
goto stationary 'end symbolread and go back to switchstatement
elseif b1 <= 20 and b2 <= 20 and b3 <= 20 then ' Calibrate - if b1 and b2 and b3 are all above the magnetic strip then carry out the following
high 4
low 5
high 6
low 7
pause 3000 'forward
low 4
low 5
low 6
low 7
pause 2000 'stop
low 4
high 5
low 6
high 7
pause 3000 'reverse back to start
goto stationary 'end symbolread and go back to switchstatement
elseif b1 > 20 and b2 <= 20 and b3 <= 20 then ' Calibrate - if b2 and b3 are above the magnetic strip and b1 is not then carry out the following
high 4
low 5
high 6
low 7
pause 3000'forward
high 4
low 5
low 6
high 7
pause 2000 '90deg right
high 4
low 5
high 6
low 7
pause 3000 'forward
goto stationary 'end symbolread and go back to switchstatement
endif
else
goto stationary
endif
goto roadsymbols
stationary:
low 4
low 5
low 6
low 7
goto main
______________________________________________________________________
high 0
high 1
high 2 'switchon LEDs
Main: 'switchstatement
If pin7 =0 then
'if pin7 (switch) =0 then carry out linefollowing program
Goto linefollowing
Else 'if pin7 (switch) =1 then carry out roadsymbol program
Goto roadsymbols
Endif
Goto main
linefollowing:
readadc 0, b1 'Sensor LEFT
readadc 1, b2 'Sensor MIDDLE
readadc 2, b3 'Sensor RIGHT
'keep checking the state of each of the analogue sensors before carrying on with the program to avoid unwanted loops
if b2 <= 20 then 'if b2 is above the magnetic strip then carry out the program
high 4
low 5
high 6
low 7
'time delay?
if b1 <= 20 and b2 <= 20 and b3 > 20 then
' Calibrate - if b1 and b2 are above the magnetic strip and b3 is not then turn left
high 4
low 5
low 6
high 7
pause 1000 'turn delay
goto linefollowing 'goto linefollowing and move forwards
elseif b1 > 20 and b2 <= 20 and b3 <= 20 then
' Calibrate - if b2 and b3 are above the magnetic strip and b1 is not then turn right
low 4
high 5
high 6
low 7
pause 1000 'turn delay -low to avoid missing the turn
goto linefollowing 'goto linefollowing and move forwards
endif
else 'if b2 is not on the magnetic strip motors don't run forwards and goes back to switchstatement (main)
low 4
low 5
low 6
low 7
goto main
endif
goto linefollowing
roadsymbols:
readadc 0, b1 'Sensor LEFT
readadc 1, b2 'Sensor MIDDLE
readadc 2, b3 'Sensor RIGHT
debug
'keep checking the state of each of the analogue sensors before carrying on with the program to avoid unwanted loops
if b2 <= 20 then ' middle sensor must be placed over magnetic strip line for the program to be executed or it returns to switchstatement
high 4
low 5
high 6
low 7
pause 500 'moves forward to read symbol
if b1 <= 20 and b2 <= 20 and b3 > 20 then ' Calibrate - if b1 and b2 are above the magnetic strip and b3 is not then carry out the following
high 4
low 5
high 6
low 7
pause 3000 'forward
low 4
high 5
high 6
low 7
pause 2000 ' 90deg left
high 4
low 5
high 6
low 7
pause 3000 'forward
goto stationary 'end symbolread and go back to switchstatement
elseif b1 <= 20 and b2 <= 20 and b3 <= 20 then ' Calibrate - if b1 and b2 and b3 are all above the magnetic strip then carry out the following
high 4
low 5
high 6
low 7
pause 3000 'forward
low 4
low 5
low 6
low 7
pause 2000 'stop
low 4
high 5
low 6
high 7
pause 3000 'reverse back to start
goto stationary 'end symbolread and go back to switchstatement
elseif b1 > 20 and b2 <= 20 and b3 <= 20 then ' Calibrate - if b2 and b3 are above the magnetic strip and b1 is not then carry out the following
high 4
low 5
high 6
low 7
pause 3000'forward
high 4
low 5
low 6
high 7
pause 2000 '90deg right
high 4
low 5
high 6
low 7
pause 3000 'forward
goto stationary 'end symbolread and go back to switchstatement
endif
else
goto stationary
endif
goto roadsymbols
stationary:
low 4
low 5
low 6
low 7
goto main
Labels:
Program Design Process,
Sandra Donohoe
Program ideas
Along with being assigned the role of Lead Programmer I was asked by the Project Manager to create an initial program design in order to begin testing as soon as the circuit board had been built.
The following is the experimental program which will be tested for the buggy project
_____________________________________________________________
Main: 'switchstatement
If pin7 =0 then 'if pin7 (switch) =0 then carry out linefollowing program
Goto linefollowing
Else 'if pin7 (switch) =1 then carry out roadsymbol program
Goto roadsymbols
Endif
Goto main
linefollowing:
readadc 0, b1 'Sensor LEFT
readadc 1, b2 'Sensor MIDDLE
readadc 2, b3 'Sensor RIGHT
'keep checking the state of each of the analogue sensors before carrying on with the program to avoid unwanted loops
if b2 > 50 then 'if b2 is above the magnetic strip then carry out the program
high 1
low 2
high 3
low 4
'time delay?
goto sideresleft 'first check to see if left sesor has become activated
else
low 1
low 2
low 3
low 4
goto main
'if b2 is not on the magnetic strip motors don't run forwards and goes back to switchstatement (main)
endif
goto linefollowing 'repeat
sideresleft:
if b1 > 50 and b2 > 50 and b3 < 50 then
' Calibrate - if b1 and b2 are above the magnetic strip and b3 is not then turn left
high 1
low 2
low 3
high 4
pause 1000 'turn delay
goto linefollowing 'goto linefollowing and move forwards
else
goto sideresright
' if conditions are not met left sensor is not above the magnetic strip therefore move to check if the right sensor has moved above the magnetic strip before returning to the linefollowing program
endif
sideresright:
if b1 < 50 and b2 > 50 and b3 > 50 then
' Calibrate - if b2 and b3 are above the magnetic strip and b1 is not then turn right
low 1
high 2
high 3
low 4
pause 1000 'turn delay -low to avoid missing the turn
goto linefollowing 'goto linefollowing and move forwards
else
goto linefollowing
'if conditions are not met return to linefollowing program and carry on forwards
endif
roadsymbols:
readadc 0, b1 'Sensor LEFT
readadc 1, b2 'Sensor MIDDLE
readadc 2, b3 'Sensor RIGHT
'keep checking the state of each of the analogue sensors before carrying on with the program to avoid unwanted loops
if b2 >= 50 then
' middle sensor must be placed over magnetic strip line for the program to be executed or it returns to switchstatement
high 1
low 2
high 3
low 4
pause 500 'moves forward to read symbol
if b1 >= 50 and b2 >= 50 and b3 < 50 then
' Calibrate - if b1 and b2 are above the magnetic strip and b3 is not then carry out the following
high 1
low 2
high 3
low 4
pause 1000 'forward
low 1
high 2
high 3
low 4
pause 300 ' 90deg left
high 1
low 2
high 3
low 4
pause 1000 'forward
goto stationary 'end symbolread and go back to switchstatement
elseif b1 >= 50 and b2 >= 50 and b3 >= 50 then
' Calibrate - if b1 and b2 and b3 are all above the magnetic strip then carry out the following
high 1
low 2
high 3
low 4
pause 1000 'forward
low 1
low 2
low 3
low 4
pause 1000 'stop
low 1
high 2
low 3
high 4
pause 1000 'reverse back to start
goto stationary 'end symbolread and go back to switchstatement
elseif b1 < 50 and b2 >= 50 and b3 >= 50 then
' Calibrate - if b2 and b3 are above the magnetic strip and b1 is not then carry out the following
high 1
low 2
high 3
low 4
pause 1000'forward
high 1
low 2
low 3
high 4
pause 300 '90deg right
high 1
low 2
high 3
low 4
pause 1000 'forward
goto stationary 'end symbolread and go back to switchstatement
endif
else
goto stationary
endif
goto roadsymbols
stationary:
low 1
low 2
low 3
low 4
goto main
___________________________________________________________
Posted by Sandra Donohoe
The following is the experimental program which will be tested for the buggy project
_____________________________________________________________
Main: 'switchstatement
If pin7 =0 then 'if pin7 (switch) =0 then carry out linefollowing program
Goto linefollowing
Else 'if pin7 (switch) =1 then carry out roadsymbol program
Goto roadsymbols
Endif
Goto main
linefollowing:
readadc 0, b1 'Sensor LEFT
readadc 1, b2 'Sensor MIDDLE
readadc 2, b3 'Sensor RIGHT
'keep checking the state of each of the analogue sensors before carrying on with the program to avoid unwanted loops
if b2 > 50 then 'if b2 is above the magnetic strip then carry out the program
high 1
low 2
high 3
low 4
'time delay?
goto sideresleft 'first check to see if left sesor has become activated
else
low 1
low 2
low 3
low 4
goto main
'if b2 is not on the magnetic strip motors don't run forwards and goes back to switchstatement (main)
endif
goto linefollowing 'repeat
sideresleft:
if b1 > 50 and b2 > 50 and b3 < 50 then
' Calibrate - if b1 and b2 are above the magnetic strip and b3 is not then turn left
high 1
low 2
low 3
high 4
pause 1000 'turn delay
goto linefollowing 'goto linefollowing and move forwards
else
goto sideresright
' if conditions are not met left sensor is not above the magnetic strip therefore move to check if the right sensor has moved above the magnetic strip before returning to the linefollowing program
endif
sideresright:
if b1 < 50 and b2 > 50 and b3 > 50 then
' Calibrate - if b2 and b3 are above the magnetic strip and b1 is not then turn right
low 1
high 2
high 3
low 4
pause 1000 'turn delay -low to avoid missing the turn
goto linefollowing 'goto linefollowing and move forwards
else
goto linefollowing
'if conditions are not met return to linefollowing program and carry on forwards
endif
roadsymbols:
readadc 0, b1 'Sensor LEFT
readadc 1, b2 'Sensor MIDDLE
readadc 2, b3 'Sensor RIGHT
'keep checking the state of each of the analogue sensors before carrying on with the program to avoid unwanted loops
if b2 >= 50 then
' middle sensor must be placed over magnetic strip line for the program to be executed or it returns to switchstatement
high 1
low 2
high 3
low 4
pause 500 'moves forward to read symbol
if b1 >= 50 and b2 >= 50 and b3 < 50 then
' Calibrate - if b1 and b2 are above the magnetic strip and b3 is not then carry out the following
high 1
low 2
high 3
low 4
pause 1000 'forward
low 1
high 2
high 3
low 4
pause 300 ' 90deg left
high 1
low 2
high 3
low 4
pause 1000 'forward
goto stationary 'end symbolread and go back to switchstatement
elseif b1 >= 50 and b2 >= 50 and b3 >= 50 then
' Calibrate - if b1 and b2 and b3 are all above the magnetic strip then carry out the following
high 1
low 2
high 3
low 4
pause 1000 'forward
low 1
low 2
low 3
low 4
pause 1000 'stop
low 1
high 2
low 3
high 4
pause 1000 'reverse back to start
goto stationary 'end symbolread and go back to switchstatement
elseif b1 < 50 and b2 >= 50 and b3 >= 50 then
' Calibrate - if b2 and b3 are above the magnetic strip and b1 is not then carry out the following
high 1
low 2
high 3
low 4
pause 1000'forward
high 1
low 2
low 3
high 4
pause 300 '90deg right
high 1
low 2
high 3
low 4
pause 1000 'forward
goto stationary 'end symbolread and go back to switchstatement
endif
else
goto stationary
endif
goto roadsymbols
stationary:
low 1
low 2
low 3
low 4
goto main
___________________________________________________________
Posted by Sandra Donohoe
Labels:
Program Design Process,
Sandra Donohoe
Program Ideas
Here is the first experimental code written for this project
___________________________________________________
'For the mode toggle switch
main:
if pin7 = 1 then 'when pin7 is high
if b0 = 0 then 'if bo is low then...
b0 = 1 'make it high
else
b0 = 0 'otherwise make it low
endif
endif
pause 100 'pause to account for human reactions when pressing the switch
'Sensor Encoding
main1:
readadc 1, b1 'Sensor LEFT to b1
readadc 2, b2 'Sensor MIDDLE to b2
readadc 3, b3 'Sensor RIGHT to b3
'Line follow mode
if b0 = 0 then 'Move forward initially
high 1
low 2
high 3
low 4
do while b1 > 20 'Calibrate - turn RIGHT when right sensor activated
high 1
low 2
low 3
high 4
goto main1
loop
do while b3 > 20 'Calibrate - turn LEFT when right sensor activated
low 1
high 2
high 3
low 4
goto main1
loop
endif
'Symbol read mode
if b0 = 1 then 'Move forward initially
high 1
low 2
high 3
low 4
'Move Forward RIGHT Forward
if b1 > 20 then 'Calibrate
high 1
low 2
high 3
low 4
pause 1000
low 1
high 2
high 3
low 4
pause 300 'Calibrate
high 1
low 2
high 3
low 4
pause 1000
endif
'Move Forward STOP Backwards
if b2 > 20 then 'Calibrate
high 1
low 2
high 3
low 4
pause 1000
low 1
low 2
low 3
low 4
pause 1000
low 1
high 2
low 3
high 4
pause 1000
endif
'Move Forward LEFT Forward
if b3 > 20 then 'Calibrate
high 1
low 2
high 3
low 4
pause 1000
high 1
low 2
low 3
high 4
pause 300 'Calibrate
low 2
high 3
low 4
pause 1000
endif
endif
goto main
___________________________________________________
Posted by Mark Hawkins
___________________________________________________
'For the mode toggle switch
main:
if pin7 = 1 then 'when pin7 is high
if b0 = 0 then 'if bo is low then...
b0 = 1 'make it high
else
b0 = 0 'otherwise make it low
endif
endif
pause 100 'pause to account for human reactions when pressing the switch
'Sensor Encoding
main1:
readadc 1, b1 'Sensor LEFT to b1
readadc 2, b2 'Sensor MIDDLE to b2
readadc 3, b3 'Sensor RIGHT to b3
'Line follow mode
if b0 = 0 then 'Move forward initially
high 1
low 2
high 3
low 4
do while b1 > 20 'Calibrate - turn RIGHT when right sensor activated
high 1
low 2
low 3
high 4
goto main1
loop
do while b3 > 20 'Calibrate - turn LEFT when right sensor activated
low 1
high 2
high 3
low 4
goto main1
loop
endif
'Symbol read mode
if b0 = 1 then 'Move forward initially
high 1
low 2
high 3
low 4
'Move Forward RIGHT Forward
if b1 > 20 then 'Calibrate
high 1
low 2
high 3
low 4
pause 1000
low 1
high 2
high 3
low 4
pause 300 'Calibrate
high 1
low 2
high 3
low 4
pause 1000
endif
'Move Forward STOP Backwards
if b2 > 20 then 'Calibrate
high 1
low 2
high 3
low 4
pause 1000
low 1
low 2
low 3
low 4
pause 1000
low 1
high 2
low 3
high 4
pause 1000
endif
'Move Forward LEFT Forward
if b3 > 20 then 'Calibrate
high 1
low 2
high 3
low 4
pause 1000
high 1
low 2
low 3
high 4
pause 300 'Calibrate
low 2
high 3
low 4
pause 1000
endif
endif
goto main
___________________________________________________
Posted by Mark Hawkins
Labels:
Mark Hawkins,
Program Design Process
Subscribe to:
Posts (Atom)