Week 10: Output Devices
Outputs Week Overview:
(1) I created a board to drive a step motor with the press of a button!
(2) I then created the board and mechanical design for a servo-motor to drive the motion of my UFO-Buoy probe.
(3) I vinyl cut charlie-plexed LEDs
Step Motor:
TRY 1
I am using the Step-Motor 28BYJ-48. Link to motor.
In solidworks I used the DesignTools feature to make my gear and rack for moving the UFO light (aka sensor housing) up and down. I will 3D print this when my motor driver is functioning:
There are two types of stepper motors, bipolar and unipolar. The motor I have is bipolar unipolar [!! When I designed my first board I thought that my motor was bipolar which was incorrect. The following process shows me working on the bipolar set up, but I will correct my mistake down the line]. Bipolar motors use reverse current and unipolar do not. This requires more complicated motor driving with H-bridges! Two H-bridges are needed to drive the two solinoids in the motor.
This diagram shows the wiring of the step motor I am using. This shows that the motor is a 5-wire UNIPOLAR motor, not bipolar!
Here is a block diagram of the motor driver (under the false assumption this motor is bipolar) I am using that shows how it has internal H-bridges that will drive the two solonoids of the motor:
To make a stepper motor board there are a couple required components:
1. The stepper Motor
2. A microcontroller
3. An ISP (in-system programming) header
4. A motor driver
5. Power Supply & corresponding connection pins
6. 5V Regulator
When I initially checked the stock of the EECS electronics I could only find the IC MOTOR DRIVER PAR 24TSSOP (A4982) motor driver. I read its datasheet and began setting up a schematic for it. I also found this fab academy page that used it.
My work flow for making my circuit schematic with the A4982 driver:
I referenced the A4982 datasheet to help setup my circuit:
My schematic starting coming together and I learned a lot about the different pins and what their required configurations were. However, I became worried about how involved this board was compared to the example Neil had on his site. It had so many more components and I also wouldn't have starter code for it (the fab-academy example I found used an external controller for their MS1 and MS2 pins that I didn't completely understand). I revisited the EECS lab and found that they actually had the A4953 motor driver. I reluctanly decided to change my design to using these drivers rather than continue with all the work I'd already done for the other driver. I felt more comfortable using these simpler drivers. Here is the new simpler schematic:
Next I made my PCB layout. I referenced Neil's layout since I already did so much independent layout work for my initial design:
I changed the thickness of the VMOTOR and GND traces to 0.5 mm.
I checked the design of my PCB by using print-preview to make sure none of the traces were too close or not suited for milling.
I almost forgot to add a button to toggle the motor on and off (in my final project I will have two buttons, one for up and one for down)
Next I milled my board on the OterMill, but accidently set the end mill to 1/32" conservative. I thought this was the method a TA had showed me but it was defintiely not the correct route!
TRY 2
Still under the incorrect assumption that my motor was bipolar
The next day I got up early and milled a slightly revised board on the Roland mill in the arch shop, this went well except that the edge cuts were only identified by the mods on the left and top sides, so the bottom and right side edges were cut less deep.
I found "Jaun Garcia's page and he used the same motor as me and programmed it with Arduino ISP.
Based on his schematic I reflected that I really should have included LEDs to help me trouble shoot programming my board.
In all my research I was really lost on what to do with the red wire of the 28BYJ-48 motor... It seems in Jaun's set up that he doesn't use it, and the motor Neil uses also doesn't have one! Then I learned that some 5-wire unipolar motors can be Hybrid, meaning they can also function as bipolar motors.
Now I realized that I was programming and making boards for a bipolar motor, when I actally have a unipolar motor. This is not great and also pretty embarrassing.
I went it and tested the motor and saw it drawing .2 amps when the common wire was energized and .4 amps when another coil was.
Now that I know my motor is unipolar and I have a better understanding of the wiring... I'm making another board, third tries the charm (hopefully).
TRY THREE
Circuit Design
Now I refernced Neil's unipolar board and added a button for controlling the motor and an LED for testing.
This unipolar motor board works by energizing the coils in the motor in steps. The AtTiny44 has four motor pin outputs which connect to N-type Mosfets that feed to the motor wires. The fifth motor wire is power.
My final circuit schematic:
My final PCB layout:
Final Bill of Materials for Motor set up:
1. The Stepper Motor (28BYJ-48)
2. AtTiny44 microcontroller
3. ISP header
4. Two A4953 motor driver chips
5. Two 10 nF Capacitor
6. Three 1 uF Capacitor
7. Two 10k Ohm Resistor
8. Button Switch- (B3SN-3012P)
Milling the board
I milled this board on the OtherMill in the EECS shop.
The 1/32" end mill was damaged on one of the flutes, giving me this rough cut on my traces. It ended up being fine for populating my board, so I did not redo it, however for my final project boards I want to ensure that I used undamaged endmills.
Programming the board
To control this motor's stepping I will start with Neil's C-code and make file to make sure it works:
Programming the board:
I started with Neil's C code. The process of programming is the same as what I documented for week 5, I've pasted the work flow here:
(1) Open terminal in directory w/ the C and make file
(2) Comile & make hex file make -f hello.stepper.44.full.c.make
(3) Send the file to the board: make -f hello.stepper.44.full.c.make program-ice
I used the Atmel ICE to program my board, that is why I have "program-ice" at the end of my code. If you open the MakeFile, you'll see the different programmer options it is made for and you can type the corret one for you set up.
Here is the board hooked up to the Atmel-ICE via and ISP connection. Note that the board must also be powered to be programmed, I connected the VCC and GND pins of the FTDI cable to the power pins of my board.
Here is the amazing message you see when the board has be uploaded with your code!!
Now that I had Neil's code working I set about making my own code that controlled the motor with a button and had an indicator LED to let me know if the button press was being registered.
Programming an ATTiny44 with an Aurduino UNO
Use the tool settings I have selected in the image below to program an AtTiny44 with an Atmel-ICE:
I wrote the code below based on David Cuartielles' work and added my pin assignments and button and LED feature:
Final code:
/* Stepper Copal
* -------------
*
* Program to drive a stepper motor coming from a 5'25 disk drive
* according to the documentation I found, this stepper: "[...] motor
* made by Copal Electronics, with 1.8 degrees per step and 96 ohms
* per winding, with center taps brought out to separate leads [...]"
* [http://www.cs.uiowa.edu/~jones/step/example.html]
*
* It is a unipolar stepper motor with 5 wires:
*
* - red: power connector, I have it at 5V and works fine
* - orange and black: coil 1
* - brown and yellow: coil 2
*
* (cleft) 2005 DojoDave for K3
* http://www.0j0.org | http://arduino.berlios.de
*
* @author: David Cuartielles
* @date: 20 Oct. 2005
*/
int motorPin1 = A0;
int motorPin2 = A1;
int motorPin3 = A2;
int motorPin4 = A3;
int delayTime = 10;
int button=10;
int led=A7;
void setup()
{
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
pinMode(button, INPUT);
pinMode(led, OUTPUT);
}
void loop()
{
if (digitalRead(button)==LOW){
digitalWrite(led, HIGH);
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
}
else
digitalWrite(led, LOW);
}
Key Lessons Learned:
Research and double check all your details before you dive into designing and milling and building!! I have a bad habit of jumping into things too quickly.
FINAL MATERIALS:
Circuit schematic for unipolar motor controlled by button.
PCB layout.
PCB traces.
Arduino Code for motor control with button.
Making Servo-Motor:
After realizing the step motor wasn't the bext for my project, I turned to the servo. Because a lot of this rode on the mechanical desing, I started with simply milling Neil's board.
Programming Board:
3D-printed parts:
Rack and pinion idea....
Using solidworks design tools:
Vinyl Cut Charlieplex
I designed the following charlie plexing circuit with the idea that it would be incorporated into my UFO final design:
I ended up not pursuing this desing further but loved learning how to tune the vinyl cutter to give good copper cuts for circuit boards.