Output

1. 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

2. Aim

  • Use Attiny 44 to control stepper motor;
  • Use LED to show the current;

3. Basic introduce stepper motor

Stepper motor rotors are made up of two or four layers of iron, each with some number of small teeth. Magnets in between the layers polarize these layers into North South pairs. The stator's coil are then polarized in an alternating sequence (similar to brushless motors) in order to 'step' the rotor's teeth about, as they align to form lower reluctance flux paths with the energized coil teeth. More detail on the following page: Guide from sparkfun speed_torquecurve

4. Design and process

4.1 BOM

Name quantity value
ATtiny44 1 U1
resistors 1 10kΩ
resistors 2 499 Ω
capacitor 1 (1uF)
capacitor 2 (0.1uF)
capacitor 12 (0.1uF)
LED(red) 1
LED(green) 1
Double needle 2 2X2
Double needle 1 2X3
A4953-H-BRIDGE-MOTOR-DRIVER 2
Voltage regulator 1 5V 100ma

4.2 Schematic and layout

I design it according the rule in electronics design The following is the result

Switch to layout ,and adjust the position of components, I get the following layout after auto optimize the layout Then export the fileExport - Image. Open the layout data in PS and invert the black ,white( image-adjustments-invert ).

4.3 Process

In FAB module,output machine data(rml)reference detail on electronics production With the help of my Instructor Saverio, I get the board I sold the component according to design.

5. Code and test

Connect Laptop, arduino,servo motor board, servo motor, power

5.1 test1

int Pin0 = 9;
int Pin1 = 10;
int Pin2 = 12;
int Pin3 = 13;
int _step = 0;
boolean dir = true;// gre
void setup()
{
 pinMode(Pin0, OUTPUT);
 pinMode(Pin1, OUTPUT);
 pinMode(Pin2, OUTPUT);
 pinMode(Pin3, OUTPUT);
}
 void loop()
{
 switch(_step){
 case 0:
 digitalWrite(Pin0, LOW);
 digitalWrite(Pin1, LOW);
 digitalWrite(Pin2, LOW);
 digitalWrite(Pin3, HIGH);
 break;
 case 1:
 digitalWrite(Pin0, LOW);
 digitalWrite(Pin1, LOW);
 digitalWrite(Pin2, HIGH);
 digitalWrite(Pin3, HIGH);
 break;
 case 2:
 digitalWrite(Pin0, LOW);
 digitalWrite(Pin1, LOW);
 digitalWrite(Pin2, HIGH);
 digitalWrite(Pin3, LOW);
 break;
 case 3:
 digitalWrite(Pin0, LOW);
 digitalWrite(Pin1, HIGH);
 digitalWrite(Pin2, HIGH);
 digitalWrite(Pin3, LOW);
 break;
 case 4:
 digitalWrite(Pin0, LOW);
 digitalWrite(Pin1, HIGH);
 digitalWrite(Pin2, LOW);
 digitalWrite(Pin3, LOW);
 break;
 case 5:
 digitalWrite(Pin0, HIGH);
 digitalWrite(Pin1, HIGH);
 digitalWrite(Pin2, LOW);

 digitalWrite(Pin3, LOW);
 break;
 case 6:
 digitalWrite(Pin0, HIGH);
 digitalWrite(Pin1, LOW);
 digitalWrite(Pin2, LOW);
 digitalWrite(Pin3, LOW);
 break;
 case 7:
 digitalWrite(Pin0, HIGH);
 digitalWrite(Pin1, LOW);
 digitalWrite(Pin2, LOW);
 digitalWrite(Pin3, HIGH);
 break;
 default:
 digitalWrite(Pin0, LOW);
 digitalWrite(Pin1, LOW);
 digitalWrite(Pin2, LOW);
 digitalWrite(Pin3, LOW);
 break;
 }
 if(dir){
 _step++;
 }
 else{ _step--;
 }
 if(_step>7){
 _step=0;
 }
 if(_step<0){
 _step=7;
 }
 delay(1);
}

But there is some noise and no action

6. Problem

the chip(A4953-H-BRIDGE-MOTOR-DRIVER) is very heat

7. Test on Aduino

I give advice and use atmel 328 to make a new board(this board can used in finial porject. reference the detail in this page

7.1Test stepper motor on arduino

According to the above guide , I connect Arduino, A4988and stepper motor. Please note: we need to connect 0.1uf(100nf) capacitance VMOT and GND

7.2 A4988

A4988(A4988 stepper motor driver carriers is a microstepping bipolar stepper motor driver. It has current limiting, over-current and over-temperature protection.) More information about A4988 in this link

7.3 Program

int x;   
void setup()  
{  
  pinMode(6,OUTPUT); // Enable  
  pinMode(5,OUTPUT); // Step  
  pinMode(4,OUTPUT); // Dir  
  digitalWrite(6,LOW); // Set Enable low  
}  
void loop()  
{   
  digitalWrite(4,HIGH); // Set Dir high  

  for(x = 0; x < 200; x++) // Loop 200 times  
  {  
      digitalWrite(5,HIGH); // Output high  
      delayMicroseconds(800); // Wait 1/2 a ms  
      digitalWrite(5,LOW); // Output low  
      delayMicroseconds(800); // Wait 1/2 a ms  
    }  
  delay(1000); // pause one second  

  digitalWrite(4,LOW); // Set Dir low  
  for(x = 0; x < 200; x++) // Loop 2000 times  
  {  
      digitalWrite(5,HIGH); // Output high  
      delayMicroseconds(800); // Wait 1/2 a ms  
      digitalWrite(5,LOW); // Output low  
      delayMicroseconds(800); // Wait 1/2 a ms  
    }  
    delay(1000); // pause one second

Then the stepper motor can run as the following video

The test for stepper motor in Arduino is OK.

8. Eagle design and manufacture

8.1 Design basic circuit

I'm not familiar with atmel 328 ,so with the help of my instructor Silli Saverio. I design my board and learn from Daniele Ingrassia's Satshakit In the meantime atmel 328 is the chip of Arduino , so I can take the following picture for reference In Satshakit's board, the left part is the same. So I delete the right pin and keep the left part of the board.And design another function in eagle. This is the basic of the PCB board. I would use FTDI cable to program the board. So I design connect FTDI to Atmel 328 in the following picture

8.2. Design step motor(Output)

According to the test in "2.2 Test stepper motor", I add the following components(Green LED, 499ohm resistor,100 uf capacitance)

8.3 Other design

I add led,relay,NTC,etc

8.4 layout and Manufacture

After design all of the board, I check with the schematic to confirm there is no mistake. Then we can go to the next stepI use the command Generate/Switch to make the board The detail in layout can referene the WEEK 7: ELECTRONIC DESIGN-eagle practice-part5,it show the detail about creat basic board,creat a DRC design rule,move and rotate,output data. At last I got the following result For the wire in the red array there is a wire I have to use jumper to connect. Then I output 2files( trace.png ,hole.png) Then I use SRM-20 Desktop Milling Machine to milling the board and solder the board.

9. Program

9.1 Bootloader

This board is referenced from Arduino, I need to upload Arduino bootloader. Here is the connection of my board with Arduino: In this time I find a problem, I forget that there is no pin for bootloader. So I have to solder new wire on the chip Then operate as following:

  • Open Arduino IDE;
  • Select proper programmer by click on Tool->Programmer
  • Select Arduino UNO as Tool->Board
  • Click on Tools->Burn Bootloader It is OK.

  • To avoid the problem and make sure it is stable

  • In the meantime, during I do the test in stepper motor , there is an explosion (The Electrolytic capacitor has the requirment in positive and negative.But I connect reverse VCC12POWER and GND12POWER )

    I update it to the following

9.2. Test Step motor

In this test , I need to add 12 v power to drive the motor. So I connect the board as following:

The first time I connect reverse pin (VCC and GND), the capacitor exploded Please check it carefully before test it.

Then use Stepper motor arduino code and updateit . The motor is running well. We must make sure the power connect the right position,or there would be problem. For example last timeI connect reverse VCC12POWER and GND12POWER.Then the Electrolytic capacitor has the requirment in positive and negative.

10.Attachment:

results matching ""

    No results matching ""