Week 12

Output Devices

Assignment

Individual assignment:
Add an output device to a microcontroller board you've designed, and program it to do something
Group assignment:
Measure the power consumption of an output device

Files

Motor control:
Motor_control_board
Motor_control_schematic
Motor_control_png
Outline_Motor_control_png
Motor_control_svg

Arduino board:
Arduino_board_board
Arduino_board_schematic
Motor_control_png
Outline_Motor_control_png

Stepper motor:
Stepper_moter_board
Stepper_moter_schematic
Motor_control_png
Outline_Motor_control_png
(Note: the stepper motor outline is not correct)

Arduino code:
Motor_control_board
Clay board

Motor controlling board

I am making a motor controller board. This board shall be modified into my final project.
We don't have SMD compotnents so the solution was to work with what I have.

This is the motor I used: Jameco 2138812



We have the standard unipolar stepper motor that has 5 wires. But in our purpose we only used 4 wires.

I started with making the design for an H bridge but had to figure out the distance between the legs. This was a bit hard and I failed in the first try. I also did something wrong with the outline and the holes, so the holes were misplaced.



I made some changes and is now using the L293D for the motor. This was in the library so I made the traces and connections.




Then I milled the board and soldered.



Afterwards I found out that I needed the other row as well. So I then added a 8 row female pin on the backside and soldered it onto the H bridge. I could only do this because the legs of the H bridge went throug the board.



Wiring and schematic

This is how I connected the motor to the H-bridge and the Arduino.




I then connected the moter to the board, and the Arduino to the bread board. And on the bread board, a 9V battery.



Arduino code

I then uploaded this code (see the original code in the tutorial):



Code for Motor controlling board

First include the stepper motor to Arduino.
512: Number of "slices" you can devide the steps in on the jameco motor.
The stepper motor is called myStepper.
On line 7 it is here defined which of the pins on the H-bridge that the motor is connected to.
The H-bridge is connected to the Arduino this is why by default that they have the same number system.
The stepCount is 0 = no movement until it recieves some information.
void setup: it is here vritten how the motor moves. It's the speed of bits per second. From arduino to the computer.
In the end there is a delay on 500 before the process begins again.

The motor is rotating slowly, this is a succes!



I got inspiration by following this tutorial:
Motor tutorial

Clay Board


The board of my final project is working, see more on the Project development page.

This is the finished CLay board without the pololu.
A pololu and a 100uF capacitor is added.
I had to adjust a pololu as seen on the third picture.



Wired up with labels so it is easier to navigate between the different wires. The wires are connected to the Arduino board.



On my final video shown below you can see the motor rotating both while testing and also with the spiral on.



This is a slower video with the arduino code that are used below the video.

Arduino code for clay board

This is some of the Arduino code used for controlling the clay board.

The include command (line 14-15) is to include some information to the Arduino.
From line number 18-27 here it is defined which of the pins on the arduino that should be used.
On line 35 you can control the speed of the motor.
Line 38 - there is used a debounce. This is because sometimes when you press a button it can recieve multiple signals even though this is not the intention. This can be avoided with debouncing. Then it will read the first signal and then wait a bit and then read again.
The bolean holds one of two values, true or false.
AccelStepper: provides an object-oriented interface for 2, 3 or 4 pin stepper motors and motor drivers.
Bounce: It is a library for Arduino and it helps debounce digital inputs and more.
The direction of the motor is set.



From 56-60 the pins is defined as either input or output.
Input = recieving information
Output = giving information back
HIGH is 1. LOW is 0.
From 71-73: Motor settings.
94-97: The values of the buttons are read.
99-: Compared to what information the board is given it will: stop, on, back. This is the action of the motor.




Arduino Board

I am following this board for making the Arduino: Fabkit

I made the schematic and followed the guide
.


When I had to make the traces in Eagle I ran into a small problem. Because we don’t currently have the 0.10 bit that is normally used for the ATMega, so I had to try with the 1/64 bit that we normally use for traces.
I had to make some tries when putting it in FabModules to see if it would make the traces. Then I moved some of the lines a tiny bit.
I then “cheated” in FabModules with the tool diameter. Instead of saying it is 0.4 I tried with both 0.35 and 0.3. This was helping with the last lines.

I used Inkscape to make the holes and the frame in the same file. First I made the frame so it would be easier to keep the holes in the same place.
To make the holes I put the traces in inkscape and then made a circle in the same size of the holes, but a different color. I then manually placed each of the holes on the holes in the traces.
Afterwards I would remove the trace and combine the holes and the frame so they would stay in place if I moved it.

I milled one board and found the components for it. I then started with the ATMega and had soldered tre of the sides on. I then look at it and see that some of the traces for the ATMega are stuck together. This was not good. I then tried to solder the ATMega off, but this was not super easy. I ended up accidentially pulling some of the trace loose from the plate. Then I got the tip that you could use the heat gun and then easily pull the ATMega off.
I tried cutting the places that were stuck together, but the already loose trace fell of.

I then modified the Eagle file and put it into FabModules again. This time I checked all the places that were problems from earlier before starting the milling job.
When I was happy with the traces I started the milling job. It took a while because of the many traces.

I had a tiny problem when soldering the ATMega on. Somehow two of the legs on the Mega got fused together with solder and this was hard to get off. When I fixed this problem there was no further problems with soldering.






The Latest upgrade I made to the board was to add female pin headers to the two sides so I could also use theese pins.

I burned the bootloader - succes.

I've been having some problems with my arduino board. Even though it worked with burning the bootloader. I now doedn't work when I have connected it to my motor controller board, the motor, bread board and the fabISP. It can't upload the code on the arduino.
I just had everything else working with a real arduino, So there must be something wrong somewhere. Even though the Schematic and Board looks fine. It is also weird that I could burn the bootloader, but now it can't upload code. I also tried burning the bootloader again, this didn't help and the same error occured.

Stepper motor

I followed the hello.stepper board to make this board that can control stepper motors. I made one change, I added four pins to the not used pins on the ATtiny44.

I sometimes had some troubles in Eagle when I had to place some of the lines between the components. It always mooved to much at a time. I then found out that you could change this in the grid settings. This really helped me further on.


I made several tries to get the pin header to be at the edge. I wanted to add the pin so I could connect it to the not used pins on the ATtiny44.


I then found out that this was the easiest way to make the traces.



What I didn't nottice before I milled the board was that the row on the right was still connected.
I also found out later that one of the pins of the Attiny44 is connected to a wrong pin. This might be the reson for previously troubles with this board.


I cut the lines that needed to be cut and then soldered the small components on.