Go Down

Topic: checking stepper motor resistance using the arduino (Read 509 times) previous topic - next topic

PGT

i'm not sure how a stepper motor is wired, and without having a volt meter.
I wondered why not use the anolog read for it.

But i'm not sure if it is safe to do, might it damage the arduino ?.
i want to use the +5 volt of the arduino put the stepper in between and use a simple program to read out the anolog, the wires inside should give  resistance and that would give me an indication of how it is wired after some conection tests with the wiring.

i however have doubts of damaging the arduino itself, as for this i wont use a motor driving board but directly put current/voltage trough it

note that i wont try to do a running motor test but just try to figure out what wire is used for what.

johnwasser

As long as the power source is 5V you don't have to worry about it.

Put a known resistance (N Ohms) between the analog input pin and +5V.  Use something around 100 ohms.  If you have ten 1000 Ohm resistors you can put them all in parallel to get better accuracy.

Connect the stepper coil between analog input and Ground.  The voltage across the coil will be in the same ratio as the resistance.  For example if you read 512 (2.5v) then the drop across both resistors is the same and the coil is 100 Ohms (same as the fixed resistor).  If you read 256 (1.25v) then the drop across the coil is 1/4 and across the resistor is 3/4.  That means that the coil resistance is 1/3 the resistor or 33.3 Ohms.

Take the reading, divide it by (1024 - the reading) and multiply by the known resistance:

512 / (1024.0-512) = 1.0
256 / (1024.0-256) = 0.333
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

MarkT

Don't do that, its an inductive load and will kick back hard (100's of volts is possible) when disconnected.

You can do something similar but you will need to protect the input pin from over voltage - using a 4v7 zener between pin and ground and a 10k series resistor between pin and the test circuit perhaps.
[ I won't respond to messages, use the forum please ]

PGT

ehm its a tiny stepper motor not a large one, so would the kickback really be hundreds of volt ??,
it's a bit hard to imagine for me that i will create lightning sparks here :)

but it is what i wondered ..
i'm not sure what to now, do it or not (both of you are respected people here who know a lot of electronics, more then me)

zeropoint

You nEEd a multimeter, it will make understanding ohms law a lot easier.

MarkT is right about the spike in voltage from the coil in the motor, though short in time and low in current it has an extremely high voltage compared to the voltage you charged it with.

http://wiki.answers.com/Q/What_is_the_formula_for_transient_spike_computation_in_an_inductive_load

Also note that resistance in a coil changes under load.

PGT

well this is my setup,
I measured values  24 and 48, so i found and notated the wiring (as in the sketch below it).

And some fun, i often make use of my office stapler and its staples to make small connectors on the breadboard :)


Above sketch is like this, from the 5 volt pin a resistor 1000 ohm to analog pin 0  (i didnt had a 100 ohm)
From analog pin 0, i go to a wire of the stepper motor.
While with another wire connected to ground i check if there is a connection with one of the other stepper motor wires.
Then if there is connection, i read the analog value (the magnet wires will have some resistance, as they are long)

Below is my simple code it requires serial monitor to be active.
Code: [Select]
const int analog0 = A0;
const int led05   = 5;
void setup()
  {
  pinMode(led05, OUTPUT);
  //Initialize serial
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only,
      //i use an arduino demineuve so strictly i dont need this
     }
  Serial.println("start");
  }

int thisByte = 0;

void loop()
  {
  delay(600); // some delay, not to overload the serial comunication
  digitalWrite(led05,HIGH);
  thisByte = analogRead(analog0);
  Serial.println(thisByte);     
  digitalWrite(led05,LOW);
  delay(600);
  }



I am not sure about the resistor value calculation here of the stepper motor
It wasnt my first goal (wanted to know its inner wiring) but now i am curious
John Wasser could you please explain how these values relate (24 and 48), my main resistor was 1000 ohm
1000 = brown black red (gold tpye)

Tom Carpenter

It will be a unipolar stepper motor. If you sum two 24's you get the 48.

Coil1
o---CCCC---o---CCCC---o
W             O1              R

Coil 2
o---CCCC---o---CCCC---o
Y              O2              B

Where
--CCCC-- is a 24Ohm coil.
~Tom~

PGT

yes i found its uni-polar (dough i forgot how it was named), thanks.
as i'm not into electronics, rather into programming.
but i doubt its resistance is 24 ohm.. john showed a somewhat different calculation.

(also a side note all these extra wires go to a ledbank IC, i only use led 5), the led 5 blink is not even required, but rather i check for myself (wait for blink then notate the value)

wanderson

#8
Aug 01, 2012, 08:29 pm Last Edit: Aug 01, 2012, 10:58 pm by wanderson Reason: 1
   5V
    |
  1000 ohms
    |
    + -- > Analog pin
    |
 stepper coil
    |
  ground

Analog reading 1: 24 / 1024 * 5V = 0.1172V
Analog reading 2: 48 / 1024 * 5V = 0.2344V

So first use ohms law with the 1000 ohm resistor to determine the current flowing through it..

E = I * R

(5 - 0.1172) = I * 1000 ohms
I = 4.8828/1000 = 0.0049 A

Then use ohms law again to solve for the unknown resistance of the stepper coil

So across the coil, the resistance is

E = I * R
R = E/I
R = 0.1172V / 0.0049A ~ 23.9 ohms for the coil that gave you a measurement of 24 on analogRead

Repeat for other coil

P.S.  Even with low voltages and small coils, the voltage spike mentioned above can still be hundreds of volts.  Do a search of diode protection for such circuits, your Arduino will thank you.

EDITED to correct math error!
New true random number library available at: http://code.google.com/p/avr-hardware-random-number-generation/

Current version 1.0.1

PGT

Quote

Analog reading 1: 24 / 2048 * 5V = 0.0586V
Analog reading 2: 48 / 2048 * 5V = 0.1172V


ehm why 2048 ?,the arduino Anolog digital coder ACD?DCA has 1024 as a max value..

wanderson


Quote

Analog reading 1: 24 / 2048 * 5V = 0.0586V
Analog reading 2: 48 / 2048 * 5V = 0.1172V


ehm why 2048 ?,the arduino Anolog digital coder ACD?DCA has 1024 as a max value..


It should be 1024 (10 bit, but I wasn't paying enough attention...)
New true random number library available at: http://code.google.com/p/avr-hardware-random-number-generation/

Current version 1.0.1

johnwasser

This is how you would print out the resistance:
Code: [Select]

int thisByte = 0;

void loop()
  {
  delay(600); // some delay, not to overload the serial comunication
  digitalWrite(led05,HIGH);
  thisByte = analogRead(analog0);
  Serial.println(1000.0 * (thisByte / (1024.0-thisByte)));     
  digitalWrite(led05,LOW);
  delay(600);
  }
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Go Up