Step 4The Microcontroller
The development board also has a integrated proto-board which allowed easy mounting of our motor controllers.
The code on the PSoC brings everything together. It waits to receive a serial command. This is formatted as a single line of 0 and 1s that indicate to print or not for each pixel. The code then loops through each pixel, starting the drive motor. A edge-sensitive interrupt on the input from the black/white sensor triggers an evaluation of weather or not to print at each pixel. If a pixel is on, the brake output is driven high a timer is started. An interrupt on the timer waits for .5 seconds then drives the dispenser output high, causing the transistor to turn on and the drill bit to spin, the timer counter is reset. After another half second, an interrupt triggers the motor to stop and the drive motor to move again. When the condition to print is false, simply nothing happens until the encoder reads another black to white edge. This allows the head to move smoothly until it needs to stop to print.
When the end of a line is reached ("\r\n") a "\n" is sent on the serial port to indicate to the PC it is ready for a new line. The direction control on the H-bridge is also reversed. The Create is sent the signal to move forward 5mm. This is done via another digital output connected to a digital input on the Create's DSub25 connector. Both devices use standard 5V TTL logic, so a full serial interface is unnecessary.
| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|











































