Stepper proto-board up and running

Posted in Uncategorized on November 17, 2009 by echamber

Here’s som pics and my updated code for running three stepper motors off of pins 4, 5, 7, 8, 10 and 11.

 

 

here’s the updated code for three motors

 

 

int dirpin1 = 4;
int steppin1 = 5;
int dirpin2 = 7;
int steppin2 = 8;
int dirpin3 = 10;
int steppin3 = 11;
int x = 0;
int step1Position = 0;
int step2Position = 0;
int step3Position = 0;
int stepper1Flag;
int stepper2Flag;
int stepper3Flag;
long stepper1EventTime = 0;
long stepper2EventTime = 0;
long stepper3EventTime = 0;
void setup() {
Serial.begin(9600);
pinMode(dirpin1, OUTPUT);
pinMode(steppin1, OUTPUT);
pinMode(dirpin2, OUTPUT);
pinMode(steppin2, OUTPUT);
pinMode(dirpin3, OUTPUT);
pinMode(steppin3, OUTPUT);
}
void loop() {
if (stepper1Flag == 0 && x==0)
{
stepper1Flag= 1;
digitalWrite(dirpin1, LOW);
digitalWrite(steppin1, LOW);
digitalWrite(steppin1, HIGH);
step1Position++;
stepper1EventTime= millis() + (1/16);
};
if (stepper1Flag == 1 && stepper1EventTime < millis())
{
digitalWrite(steppin1, LOW);
digitalWrite(steppin1, HIGH);
step1Position++;
stepper1EventTime= millis() + (1/16);
if (step1Position > 22499) {
stepper1Flag = 0;
x=1;
};
};
if (stepper2Flag == 0 && x==0)
{
stepper2Flag= 1;
digitalWrite(dirpin2, LOW);
digitalWrite(steppin2, LOW);
digitalWrite(steppin2, HIGH);
step2Position++;
stepper2EventTime= millis() +(1/16);
};
if (stepper2Flag == 1 && stepper2EventTime < millis())
{
digitalWrite(steppin2, LOW);
digitalWrite(steppin2, HIGH);
step2Position++;
stepper2EventTime= millis() + (1/16);
if (step2Position > 6999) {
stepper2Flag = 0;
x=1;
};
};
if (stepper3Flag == 0 && x==0)
{
stepper3Flag= 1;
digitalWrite(dirpin1, LOW);
digitalWrite(steppin1, LOW);
digitalWrite(steppin1, HIGH);
step3Position++;
stepper3EventTime= millis() + (1/16);
};
if (stepper3Flag == 1 && stepper3EventTime < millis())
{
digitalWrite(steppin3, LOW);
digitalWrite(steppin3, HIGH);
step3Position++;
stepper3EventTime= millis() + (1/16);
if (step3Position > 22499) {
stepper3Flag = 0;
x=1;
};
};
}

int dirpin1 = 4;int steppin1 = 5;int dirpin2 = 7;int steppin2 = 8;int dirpin3 = 10;int steppin3 = 11;int x = 0;int step1Position = 0;int step2Position = 0;int step3Position = 0;
int stepper1Flag;int stepper2Flag;int stepper3Flag;
long stepper1EventTime = 0;long stepper2EventTime = 0;long stepper3EventTime = 0;
void setup() {  Serial.begin(9600);
pinMode(dirpin1, OUTPUT);  pinMode(steppin1, OUTPUT);  pinMode(dirpin2, OUTPUT);  pinMode(steppin2, OUTPUT);  pinMode(dirpin3, OUTPUT);  pinMode(steppin3, OUTPUT);

}
void loop() {
if (stepper1Flag == 0 && x==0)  {     stepper1Flag= 1;    digitalWrite(dirpin1, LOW);    digitalWrite(steppin1, LOW);    digitalWrite(steppin1, HIGH);
step1Position++;

stepper1EventTime= millis() + (1/16);  };
if (stepper1Flag == 1 && stepper1EventTime < millis())  {    digitalWrite(steppin1, LOW);    digitalWrite(steppin1, HIGH);
step1Position++;
stepper1EventTime= millis() + (1/16);    if (step1Position > 22499) {       stepper1Flag = 0;       x=1;     };
};
if (stepper2Flag == 0 && x==0)  {     stepper2Flag= 1;    digitalWrite(dirpin2, LOW);    digitalWrite(steppin2, LOW);    digitalWrite(steppin2, HIGH);
step2Position++;

stepper2EventTime= millis() +(1/16);  };
if (stepper2Flag == 1 && stepper2EventTime < millis())  {    digitalWrite(steppin2, LOW);    digitalWrite(steppin2, HIGH);
step2Position++;
stepper2EventTime= millis() + (1/16);    if (step2Position > 6999) {       stepper2Flag = 0;       x=1;     };
};
if (stepper3Flag == 0 && x==0)  {     stepper3Flag= 1;    digitalWrite(dirpin1, LOW);    digitalWrite(steppin1, LOW);    digitalWrite(steppin1, HIGH);
step3Position++;

stepper3EventTime= millis() + (1/16);  };
if (stepper3Flag == 1 && stepper3EventTime < millis())  {    digitalWrite(steppin3, LOW);    digitalWrite(steppin3, HIGH);
step3Position++;
stepper3EventTime= millis() + (1/16);    if (step3Position > 22499) {       stepper3Flag = 0;       x=1;     };
};

}

 

Controlling Steppers.

Posted in Uncategorized on November 3, 2009 by echamber

I made a sketch in arduino for getting continuous control of two steppers without software delays . The steppers are connected to two Easy Driver Stepper controllers, Here is da code.

int dirpin1 = 4;
int steppin1 = 5;
int dirpin2 = 7;
int steppin2 = 8;
int x = 0;
int step1Position = 0;
int step2Position = 0;
int stepper1Flag;
int stepper2Flag;
long stepper1EventTime = 0;
long stepper2EventTime = 0;
void setup() {
Serial.begin(9600);
pinMode(dirpin1, OUTPUT);
pinMode(steppin1, OUTPUT);
pinMode(dirpin2, OUTPUT);
pinMode(steppin2, OUTPUT);
}
void loop() {
if (stepper1Flag == 0 && x==0)
{
stepper1Flag= 1;
digitalWrite(dirpin1, LOW);
digitalWrite(steppin1, LOW);
digitalWrite(steppin1, HIGH);
step1Position++;
stepper1EventTime= millis() + (1/16);
};
if (stepper1Flag == 1 && stepper1EventTime < millis())
{
digitalWrite(steppin1, LOW);
digitalWrite(steppin1, HIGH);
step1Position++;
stepper1EventTime= millis() + (1/16);
if (step1Position > 22499) {
stepper1Flag = 0;
x=1;
};
};
if (stepper2Flag == 0 && x==0)
{
stepper2Flag= 1;
digitalWrite(dirpin2, LOW);
digitalWrite(steppin2, LOW);
digitalWrite(steppin2, HIGH);
step2Position++;
stepper2EventTime= millis() +(1/16);
};
if (stepper2Flag == 1 && stepper2EventTime < millis())
{
digitalWrite(steppin2, LOW);
digitalWrite(steppin2, HIGH);
step2Position++;
stepper2EventTime= millis() + (1/16);
if (step2Position > 6999) {
stepper2Flag = 0;
x=1;
};
};
}

 

Robotic Sorting Arm

Posted in Uncategorized on November 3, 2009 by echamber

I’m working on trying to make a stepper controlled robotic grabber claw that will move around a 4ft by 4ft square. My hope by the end of the project is that I’ll have a device that will carry out a clunky sort of binary sorting of object that I place inside the square.

Task List

- get control of two stepper motors on a 12v circuit that will move the arm along the X and Y axis from the ceiling.

- build a claw and figure out how to mechanically get it to open an close appropriately.

- mount the claw on a track

- get some type of visual information to feed into arduino and be used to recognize objects on a white background.

- sort em up

Xbee notes

Posted in Uncategorized on July 1, 2009 by echamber

Xbee Radios

-small, low power radios

-based on the 802.15.4 ZigBee wireless protocol

- Inexpensive, easy to configure

- Part # XB24-AWI-001

-They work on a digital protocol so that can only communicate with other Xbee radios

-you can serial print from an arduino to a computer and from a computer to an arduino.

To be able to use the radios you must get a breakout board with a usb to connect it to you computer and you’ll need another radio and a breakout board to connect into you.

Terminal Software

- for a mac you need to download the Zterm software

- for windows you need Hyperterminal

- “Screen” command from the Mac terminal, ex. screen /dev/tty.usbserial-XXXX

- Xbee Terminal Program in Processing

to close something in the MAC terminal you need to hit

ctrl + A

ctrl + \

to get two arduinos to talk back and forth you need to specify what network your on, what your xbee is and the destination address

* Network (PAN ID) atid 4444 BEEF

* Xbee Address atid  1

* Destination Address atdl  2

- make sure to write your commands to the Xbee memory with the command atwr

- saving command = atwr

USB to TTL adapter

the best idea is for you to pick a network name that you think nobody will ever use.

Duplex Configuration of Two XBee radios

Radio #1 Radio #2

+++OK +++OK

atre atre

OK OK

atmy 1111 atmy 1111

OK OK

atid 1 atid 2

OK OK

atid 2 atdl 1

OK OK

atwr atwr

OK OK

above code  means that…….

-you enter your network name as atmy 1111

- you enter your first radio’s address as 1

- you enter your second radio’s address as 2

- you hit save to keep the settings as atwr

Notes on batteries

Two AA batteries in a series meaning you connect two batteries end to end you will take the voltage of each and add them together. So two batteries in parallel will equal 1.5v + 1.5v = 3 v

Two batteries in parallel means that if you put the like terminals together you get the same voltage of one of the battery. Th average AA battery has about 2500 miliAmp Hours and you would add that miliAmp hours of each battery in parallel to get the full miliapm hours of you circut.

* the capacity of a battery is sometimes absent on the label so finding out the time period that the battery will last can involve looking up the miliAmp hour rating online.  1 A * 1 H = 1 AH

Voltage (v)

- depending on how wide the range of the object that your trying to power, you can use a voltage regulator or just supply about a volt above what you need or a volt below.

- use a regulator to regulate the lower voltage

- use a step down DC-DC converter, keep in mind they are expensive

- if you need more voltage you can make a step- up which will take a power supply with less voltage and boost it up.

the best way to know what you going to get out of battery life it to know capacity in (AH or mAH)

- capability (c, Coulombs)

NiMH ( NIckle Metal Hydride) batteries are very nice for projects because they are rechargeable and quick to recharge

Li-ion Lithium-Ion or lithium polymer are great and can be recharged many times and they have a high power density. Be really careful not to short the out because they can explode easily.

http://www.powerstream.com is a good place to buy batteries

DC-DC converters

Serial communication notes

Posted in Uncategorized on July 1, 2009 by echamber

Document your work and make sure that you have a way to get it working before the class.

- use powerpoint, pictures or anything that you can use to explain your project.

- we have 20 minutes to use

give explanation of what it does,

how it was built

why you wanted to make it

demo it

when you want to send serial data use serial.print

ASCII table.com is a good resource for looking stuff up

Serial.print(123, DEC);

ascii table for each character is sent when you are sending out data as a DEC.

you can only fit up to 255 in a byte

if you send data as a byte you will see the ASCII character on the other end of the process that represents the number that you sent.

if your sending data as DATA you can fit numbers larger than 255, yet you sacrifice performance in your program because each character is being represented as a byte taking up much more space than you would by sending one byte.

ASCII versus Binary

ASCII

{ human readable

understanding of text

less efficient (more data)

easier to send large #’s

easy to transmit text

}

Binary {

machine readable

understanding of binary

more efficient (less data)

trickier to send larger numbers

tricker to transmit text

consistent size

}

How to get multiple values with a sensor and learning to pay attention to the order in which you send data.

- use delimiters, or headers

delimiters are a sequence of one or more characters used to specify the boundary between separate independent regions in plain text or other data streams.

123  349  1023

three different sensor values.

123, 345, 1023 <line feed>

123, 367, 1023 <line feed>

111, 320, 0 <line feed>

123, 345, 0 <line feed>

122, 325, 1023 <line feed>

this sequence of data uses a comma as a delimiter and is a way of specifying what the beginnings and ends of numbers are.

BYTE

if your using delimiters with bytes you need to map your number readings to 0-254 so that you can use 255 as a delimiter that won’t show up in the code.

(0 – 253)

123 255 120 255 60 254 (0101001)

delimiter- 255 254

if you want to make sure that your data is in order you might want to send a header so that it tells your program that there will be data to interpret coming after it.

header might be 255

4 % 2 = 0

3 % 2 = 1

the % symbol is used to make sure that the data you use is within the readable range

Call and Response -letting arduino and processing talk back and forth

talking

Handshake – both programs initialize and make sure that both are listening

taking to something like a radio is good for this because it makes sure that both devices are talking to each other

int Serial.available()

-everything you send to arduino will appear in the buffer so calling Serial.available will show you what is in the que.

characters can be represented bye by bye so there is no possibility of being able to write

Midterm Music Maker

Posted in Uncategorized on July 1, 2009 by echamber
the bells and gongs

the bells and gongs

Breadboard setup with four speakers playing square waves.

Breadboard setup with four speakers playing square waves.

close up of the doorbell ringer

close up of the doorbell ringer

This spinner powered by a small dc motor makes a really annoying sound

This spinner powered by a small dc motor makes a really annoying sound

We tried to make a synth that would make analog and digital sounds depending on where you put it. We ended up with a noise maker that changed its beat and frequency depending on pressure, light and heat values.

motors

Posted in Uncategorized on July 1, 2009 by echamber
running a hobby motor

running a hobby motor

The hobby motor was really easy to setup, the code seemed pretty self explanatory and I tried playing around with the rotation and the interval speed for some extra experimentation.

Here’s my notes on motors relays and transistors

An electromagnetic field is what get created when you run current through a wire creating an electromagnetic filed around the wire.

This magnetic field is commonly referred to as an electromagnetic field.

http://www.lessemf.com

faraday cage – a weird device that protects you from emf.  By coiling wire you ca leverage the power and direction of the magnetic force traveling down the length of the wire to make one stronger magnetic field.

By understanding how a this works you can figure out how a motor works. Two polarities of a magnet will spin a axle with wires coiled around it that is being fed electricity to make the axle into an electromagnet.

DC motor

- speed (with potentiometer)

-direction

- on off (with a HIGH or LOW pulse)

H BRIDGE CHIPS

the direction of motors can be regulated with an H-Bridge chip.

It will switch small semiconductors traveling with two connections from the ground and two from the positive lead and switch from sending power through the two terminals of the motors switching the direction of the current and switching the direction that the motor spins.

__________

1,2,EN     –   |             | Vcc1

| |

1A           –   |             | 4A

| |

1Y           –   |            | 4Y

|     |

heat sink  –   |             | Heat sink &

| |

ground    -    |              | ground

| |

2Y          –   |               | 3Y

|                    |

2A           –   |               |       3A

| |

Vcc2        -  |__________|      3,4EN

Gear Head Motor

Gear head motors are a subset of DC motors. They have a box on top of a motor containing aa series of gears that slow the rotation speed but increase the torque or rotation power.

Useful when you don’t need speed but you need power.

arduino can only supply about 40 miliamps

motors will give you three readings that tell you how much power you need to run it.

5VDC, 50mA free running, 400 mA stalled

- when a stall amp rating is listed that tells you how much power that your motor will need to work while it is being stalled by gears and other attachments.

these motors are called hobby motors and can be found at radioshack and other places. there are a lot of interesting motors that you can use but most of them will require more power than your arduino can provide.

- electromagnetism- is electricity flowing through a conductor, a small circular magnetic field is created.

when you coil a wire in a loop you can have a magnetic field around each one that creates unified poles.

A relay is an electronic switch.

By sending a small current through a coil we create a magnetic field that pulls one contact of a switch either against or away from the other.

- rotary solenoids will give you an electromagnetic turn that

-electricity flows form negative to positive and so power is coming from the ground and returning to the battery through the positive lead.

Relay diagram

—–(+ coil)

—– (sw)                         —– (sw)

—– (-coil)

the downside to a relay is that it can take a long time to switch stuff on an off and because it’s mechanical so there is room for failure or parts to be able to break.

Transistor

a semiconductor with three leads that is often used for switching or amplification.

a very small current applied to flow  between the other two. Somethings require higher power and must be connected fast so they must be controlled with semiconductors.

There are two kinds of semiconductors NPN and PNP

_______________

|     +     |  – |              |

emitter —|———|—|———-|——

|______|__|_______|

Collector

BASE                         Not pointing in

Emitter

NPN transistors conduct electricity when they are HIGH relative to the emitter.

(always read the data sheets for every transistor so that you know how it works.)

PNP Transistor

Collector

BASE                        Pointing in

Emitter

NPN transistors conduct electricity when its base is LOW relative to the emitter.

diodes will only allow electricity to flow in one direction. They are necessary for controlling motors with arduino so that you don’t

forrest mims “getting started in electronics” great reference book for getting to know electronics.

How to use a transistor to control a motor.

Getting a power source that can be used on an arduino board is a difficult proposition.

Whenever an arduino resets pin 13 will blink.

If you forget to put in a diode if could cause a micro-controller.

Follow

Get every new post delivered to your Inbox.