Showing posts with label Arnold Ngang. Show all posts
Showing posts with label Arnold Ngang. Show all posts

Wednesday, 28 April 2010

PICAXE Code - Line Following

This is the PICAXE code used for the buggy on the protoype testing day is shown below. It impliments the use of if....else command. Low's and High's are used to send outputs to the connected components such as the LED's and motors. It also uses sub-routines to keep the code neat and efficient as possible.



symbol switchstate = b0

main:

if switchstate = 0 then
debug switchstate ;used so we can see the state the swith b0 is in
goto program1


else
goto program2
endif

goto main


program1: ;used to follow the track

readadc 1, b1 ;reads and converts the analogue input from left LDR
debug b1 ;used to calibrate the left LDR
readadc 2, b2 ;reads and converts the analogue input from right LDR
debug b2 ;used to calibrate the right LDR


high 5 ;sends an output high to the two LED's
high 6

if b2 > 110 and b1 ;if the left LDR is on white and the right LDR on black

goto right
endif

if b2 <> 110 then ;if the left LDR is on black and the right LDR on white
goto left

else ;otherwise move forwards
goto straight

endif
goto main

program2: ;used to identify the symbols

readadc 1, b1 ;reads and converts the analogue input from left LDR
debug b1 ;used to calibrate the left LDR
readadc 2, b2 ;reads and converts the analogue input from right LDR
debug b2 ;used to calibrate the right LDR


high 5 ;sends an output high to the two LED's
high 6

if b2 > 110 and b1 > 110 then ;if the left LDR is on black and the right LDR on black
low 1 low 2 low 3 low 4 ;stay stationary for three seconds
pause 3000
endif

goto program2

if b2 > 110 and b1 ;if the left LDR is on white and the right LDR on black
goto left ;turn left for three seconds
endif

if b2 <> 110 then ;if the left LDR is on black and the right LDR on white
goto right ;turn right for three seconds

else ;otherwise move backwards
goto back
endif

goto main


straight:

low 1 high 2
low 3 high 4

goto main

right:


low 1 low 2 low 3 high 4
goto main

left:

low 1 high 2 low 3 low 4
goto main


back:

low 2 high 1 low 4 high 3
goto main

Tuesday, 27 April 2010

Buggy Following Magnetic Strip

This is a video preview of our buggy following the Magnetic Strip

Wednesday, 14 April 2010

Line following Problems

Over the last few days we've been experiencing problems getting the buggy to follow the line.
Mainly because we need to think about three scenarios.
1. When the left Ldr is above white paper
2. When the left Ldr is covered by the line
3. When the Right Ldr is above white paper
4. When the Right Ldr is covered by the line.

Due to the nature of the first program, we dont require any reversing of any wheels at any time although some groups have opted to reverse either one of the wheels if its relative LDR cross onto the black line, as a way of getting it to turn back into the path require.

We have opted for a simple 'stop' of the relative wheel. So for example, if the Ldr controlling the right wheel crossed onto the black line, this wheel would stop motion while the other wheel would continue to travel, effectively using the stopped wheel as a pivot for motion. This would bring the directed path of the buggy back to where we want it.

The four scenarios are all independent of eachother at this moment in time except for obviously both Ldrs being above white paper, where we have set a command of just going straight for this scenario. I'll upload the video of this pivoting in practise after this.

Tuesday, 23 March 2010

This is the program that was used to illumate the LED when testing the effects of using the magnetic strip. This is demonstrated in the videos that will follow
-------------------------------------------------------
symbol Motor = 2
symbol LDR = 1

Main:
gosub Light
gosub Spin

goto main

Light:
if pin1 = 1 then
low 1
else pin1 = 0
high 1
endif

return

Spin:
high Motor
pause 200
low Motor

return