{ Fab Academy 2015 : Koichi Shiraishi }
{ Home } { Final project } { Class } { Fab Academy }
- Week 11: Output Devices -
Weekly Assignment
- add an output device to a microcontroller board you've designed and program it to do something
Making stepper board
I made “hello stepper bord(bipora)”. I traced the neil’s board. I attach a trace data below.
After testing, I made original bord.(added FTDI connector) Making circuit process is the same as before.
1,Engraved by fiber laser
2,Squeezed cream solder
3,Reflow by hot plate
4,Added pins
I found a mistake that IC regulator was not connected to GND, when I checked the circuit had been complete soldering. therefore I connected these by jump wire.
(The following files are fixed a problem.)
Output files
Hello stepper.c Test
To burn the “hello_stepper.c” by “AVR ISP”. It worked smoothly.
Serial connection test 01
I developed a code print direction in serial monitor by Arduino IDE. AT tiny 44 do not support “Serial,” therefore I wrote “Softwareserial.” I test by 9 port(RX) and 8 port(TX). To become inverted FTDI port(RX,TX).
It worked smoothly
Tested code
#include
#include
const int rx=8;
const int tx=9;
SoftwareSerial mySerial(rx,tx);
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 0 through 4 except 2:
Stepper myStepper(stepsPerRevolution, 0, 1, 3, 4);
void setup() {
// set the speed at 60 rpm:
myStepper.setSpeed(60);
pinMode(rx,INPUT);
pinMode(tx,OUTPUT);
mySerial.begin(9600);
}
void loop() {
// step one revolution in one direction:
mySerial.println("clockwise");
myStepper.step(stepsPerRevolution);
delay(500);
// step one revolution in the other direction:
mySerial.println("counterclockwise");
myStepper.step(-stepsPerRevolution);
delay(500);
}
Direction control test with Processing & Arduino IDE.
I developed two codes. The first one is sending simple protocol by “Processing.” The other is receiving protocol by “Arduino IDE.”
Protocol
Right = 0 Left = 1
It had problem. The 8 port did not work. I changed the port number, and checked it. After burning a new code, It worked.
The code was not fault. I guess It was broke when I soldered wire.
Tested codes
1: Processing
import processing.serial.*;
Serial myPort; // The serial port
String command = "";
void setup() {
// List all the available serial ports
println(Serial.list());
// Open the port you are using at the rate you want:
myPort = new Serial(this, Serial.list()[5], 9600);
}
void draw() {
text(command, width/2, height/2);
}
void keyPressed() {
if (key == CODED) {
if (keyCode == RIGHT) {
command = "Clockwise";
println("Clockwise");
myPort.write(0);
} else if (keyCode == LEFT) {
command = "Counter clockwise";
println("Counter clockwise");
myPort.write(1);
}
}
}
2: Arduino IDE
#include
#include
const int rx=9;
const int tx=8;
int rotate = 0;
SoftwareSerial mySerial(rx,tx);
const int stepsPerRevolution = 25; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 0 through 4 except 2:
Stepper myStepper(stepsPerRevolution, 0, 1, 3, 4);
void setup() {
// set the speed at 60 rpm:
myStepper.setSpeed(60);
pinMode(rx,INPUT);
pinMode(tx,OUTPUT);
mySerial.begin(9600);
}
void loop() {
if (mySerial.available() > 0){
rotate = mySerial.read();
if (rotate == 0){
myStepper.step(stepsPerRevolution);
delay(15);
}else if (rotate == 1){
myStepper.step(-stepsPerRevolution);
delay(15);
}
}
}