Output devices

In this week we have to add an output device to a microcontroller board we've designed and program it to do something.

To clear this assignment I need to firstly decide which output device I'm going to control then make the board and finally program it.

DC motor

DC motor will be my output device. The first step was designing the board.

Firstly, I started with Neil's board for DC motor. I went to the output devices page. And I downloaded hello.H-bridge.44.cad here is a picture of the board:

I wanted to use the same board for networking so I modified it using kokopelli, as I did in Electronics design week. What I did is I added (Rx, Tx, GND, VCC) pins to make serial communications between it and the other board I'm going to make.

Also, I added an LED to help me to debug it when I'm going to program it also the LED will be controlled by another board in the networking assignment. Here is the modified board:

Then, I milled the board and started stuffing the components:

The regulator is heating up

After milling the board and putting all the components. I connected the board to the ISP and the regulator started heating up.

Obviously I left the board connected too long to the ISP and here is what happened.

So yes the regulator was heating because it gets current in its out pin, to slove this problem I added a diode by removing part of the copper and then soldering it. Here is a picture of the board after adding the diode:

Programming the DC motor

I wanted to program the DC motor to rotate clock-wise for 1 second, then stop for 1 second, then counter clock-wise for 1 second.

To start programming the board I opened the data sheet of the H-bridge.

Here is the control truth table:

So I wrote this program with comments describing what I did:

// Ahmed Abobaker - Fab Academy 2017
// 16 April 2017  
// MIT License

#define F_CPU 1000000UL
#include <avr/io.h>
#include <util/delay.h>

int main (void) {

DDRA |= (1 << PA2); //Setting PA2 as output
DDRA |= (1 << PA3); //Setting PA3 as output

while(1) {

PORTA &= ~(1 << PA3); //turn off
PORTA |= (1 << PA2); //turn on


PORTA &= ~(1 << PA2); //turn off


PORTA &= ~(1 << PA2); //turn off
PORTA |= (1 << PA3); //turn on


PORTA &= ~(1 << PA3); //turn off



Here is the video, of the motor working:

Here it is in slow motion:

Servo motor

I worked on servo motor as part of my final project. I used hello.servo.44.cad but I added to the board two things. Soil moisture sensor, and an LED to debug.

I stuffed the board with the components, but then I realized that there was a problem with the traces but fixed it with a cutter.

To control servo motor I needed to read about it first in this page, and I quote from that page. "Servo motor can be rotated from 0 to 180 degree, but it can go up to 210 degree, depending on the manufacturing. This degree of rotation can be controlled by applying the Electrical Pulse of proper width, to its Control pin. Servo checks the pulse in every 20 milliseconds. Pulse of 1 ms (1 millisecond) width can rotate servo to 0 degree, 1.5ms can rotate to 90 degree (neutral position) and 2 ms pulse can rotate it to 180 degree."

So to program it I needed first to set the clock divider and the timer, and then change the value of OCR1A to control the pulses the microcontroller sends to the servo motor.

What I did is, I started with the program I made for input devices week. In that week I made the LED turn on when the soil moisture reaches certain value. But now what I want is to move the servo motor to a certain position when the sensor feels moist or it feels dry. Before uploading the program with sudo make program I need to burn the fuses to use the external clock with sudo make fuses

One of the very first trials was this

Here is one of the projects prototypes

The final project program