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.
Showing posts with label Circuit/System. Show all posts
Showing posts with label Circuit/System. Show all posts
Friday, 30 April 2010
Friday, 9 April 2010
Proposed Pin Out diagram
This is the proposed pin-out of the actual PIC circuit board;
Output Pins 0-4 are used to control motor 1 or 2. ( 1 being the left hand motor, 2 being the right hand motor respectively looking at the buggy from the front). The Combinations shown are those to drive the motors forward ( i.e the combination of pin0 being high and pin 1 being low will drive the left hand motor forward, while reversing to Pin0 low and pin1 high will drive the left hand motor backwards.)
The sensor posistions are shown are indicated as if looking at the buggy from the front.
Pin 7 turns on a transistor that activates 5 LEDS mounted above the LDR sensors.
Its pretty flexible so if anyone needs anything moved to make their section a bit easier then give me a shout and ill see if it works and if so ill update the diagram.
Subscribe to:
Posts (Atom)