Home About Me Weekly Assigments Final Project


Output Devices

Fab Academy 2018


Week #11



During this week we have learned about many types of output devices and we asked to control at least one output. Firstly, I think it will be an easy and useful week, but unfortunately it was the most horrible week until now I destroyed my lovely laptop :( (Both CPU and GPU were burned)becuase of bad connection of stepper motor whith A4988 pololu driver!!!.

RGB LED

Just to simplify my life after the disaster I decided to start with the simple output device then move to harder ones. So I choosed RGB LED which is a cute LED with four legs, one is the common (ANODE or CATHODE) imagne the other 3 legs as RED, GREEN and blue separated LEDs. RGB lights like any pixel in your laptop screen. just give each LED a number from 0 to 255 send them together as (R,G,B) form ,ex. (0,0,255) it will give you pure blue. a (255,255,255) is a white color and (0,0,0) will off the LED. By selecting a combination of these three numbers you could produce any color for example (153,0,153) will give a purple color. There is many online color tables or software you just click your wanted color and it will automatically generate the color code for you.

The below picture shows the difference in connection between common ANODE and common CATHODE RGBs.


RGBconnection

I used a common ANODE and connect it with Arduino as shown:


rgb1

To write a code for a common ANODE RGB it is a little bit harder because it will be ON when the digital pin is LOW not HIGH as usual. So everything will be reversed in color code!!!. Because I used to deal with 0 as off and 255 as the full ON to not confuse I write the color code as it's and by the code it will subtract each given number from 255 before send it to RGB. In the first program I just make the RGB lights with six color sequential start with 3 pure colors. This is my code and each line explained by a comment beside it.


RGBcode1

Watch the viedo

I wrote a second simple code to generate a random color every second. This is my code:


RGBcoderandom

Watch the viedo



DC motor


To control a DC motor I shouldn't connect it directly to any microcntroller because motor needs more current than any MCU could provide usually each pin could give 40 milliamperes, also MCU may burn due to back EMF from the motor to MCU pin connected to it. So I used L2390D driver which has two H-bridges and allows speed and direction controlling for 2 motors. The pin out of the driver is shown below:


L293D

As the previous figure illustrates I connected all VCC and GND pins to external 5 V voltage source. Input 4 and 3 connects to MCU output two pins to control the rotation direction of the motor i.e when the output is 01 the motor will rotate in a direction, when it is 10 it will reverse the direction and when it is 00 it will stop. Output 3 and 4 connect to DC motor wires directly. Enable 3,4 connect to PWM pin in MCU to control the speed of the motor.

I controled a DC motor with my general purpose board I produced in Electronics Design week. This is my code which has two buttons when I press the first button the motor will rotate clockwise CW, and when I pressed the second it will reverse the direction. This is my code which explanation of each line.


DC

This video shows the connections and the implementation of the code :

Two stepper motor board


I want to use a stepper motor for my final project. To control the stepper motor I will use Pololu a4988 Driver. I need two motors so I designed a board to control two stepper motors and one ultrasonic sensor. I start with eagle schimatics:


DC
DC

By following the procuder of Electronics Design weeks I started to routing my board. I spend less time fixing my board comparing to last weeks. Then I checked my design to find if there any mistakes. My final desgin layout.


board

This picture presents the inside line milling process with 0.2mm cutting tool:


insideMill

This is the drilling job layout with 0.8mm End Mill cutting tool:


drill

The board after milling:


stepperBoard


Problems and Diffculties

This week was really a WEEK OF PROBLEMS I faced an uncountable number of problems and I delay all of this week work until the last. I will list as many problems as I remember:

Download My Codes and Boards