After Laying out the circuit diagram and the connections to the various outputs, we needed small sections of programming routine so that when the programmer came to assemble the final developed program, small sections of code could be copied and pasted in.
Firstly, we had to devise a code to check that the motor were wired up correctly and that it would turn backwards and forward.
Main:
low 1 `Drive the motor forward
high 2
pause 5000 `Pause for 5 seconds
high 1 `Drive the motor backwards
low 2
pause 5000 `Pause for 5 seconds
goto main `loop to start
Once this was working, the code was copied and applied to 2 motors to make sure that they both worked;
This routine was called "goforward" (obviously)
`To Drive Motor Forwards
High 5 `Left Motor Fowards
Low 4 `Left Motor Forwards
High 6 `Right Motor Forwards
low 7 `Right Motor Forwards
(Note the change in Pins, as this code was run on the fully assembled buggy, whereas the first code was run during the lab sessions during the first couple of weeks)
Once we had this code and sub-system working, we were able to play around witht the outputs of the chip to create smaller subsections of programming that would enable the buggy to turn left and right. Here are the devised codes;
turnright:
`To Turn Right
High 5 `Left Motor Fowards
Low 4 `Left Motor Forwards
`Code To Turn right Motor Backwards
Low 6
High 7
return
And the code to turn left;
turnleft:
` To Turn Left
High 6 `Right Motor Forwards
low 7 `Right Motor Forwards
`Code to run Left Motor Backwards
Low 5
High 4
These blocks of text where then substituted in to the Alecs program.
Friday, 30 April 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment