CasualKilla Posted April 21, 2015 Posted April 21, 2015 I need to program a 4 wire stepper motor, problem is, there is no data sheet and no control circuit and i am completely lost. Can somebody please assist me with the ladder logic program to get it up and running? I have access to a decent PLC, and my only option is to hard code this, a control circuit is not an option.
Danijel Gorupec Posted April 21, 2015 Posted April 21, 2015 Hard. Without a control circuit (unless your PLC has some special outputs) you will only obtain poor results. 4-wire stepper motors should be bipolar-driven. Does your PLC have transistor outputs? Open-collector or driven (push-pull) outputs? Does it have PWM capability? Does it have quadrature outputs? Also, what is you know about the motor - what size it is, what is winding resistance, are there any markings on it?
Spyman Posted April 22, 2015 Posted April 22, 2015 I am not experienced with stepper motors, but from skimming the article at Wikipedia and a quick Google find, it seems doable if you don't want to spin the motor fast or with a smooth rotation and are more interested in positioning. It looks like a fun and interesting project! Do you already have schematics of how you want to connect the motor and data on the hardware? (Would also be nice if we could get a short backstory of the purpose with the motor control.)
CasualKilla Posted April 23, 2015 Author Posted April 23, 2015 (edited) I am not experienced with stepper motors, but from skimming the article at Wikipedia and a quick Google find, it seems doable if you don't want to spin the motor fast or with a smooth rotation and are more interested in positioning. It looks like a fun and interesting project! Do you already have schematics of how you want to connect the motor and data on the hardware? (Would also be nice if we could get a short backstory of the purpose with the motor control.) The winding resistance is 5ohm, I measured it today. Other than than I have no useful info on the motor. The plc is connected to "digital" outputs on the tutor board that short the two output ports when on, and open circuit the two output ports when off. I only really need one rotation direction, I need to rotate an object in steps of 45 degrees Will this circuit work for one direction rotation? (any tips on the voltage I should use would be appreciated) Edited April 23, 2015 by CasualKilla
Sensei Posted April 23, 2015 Posted April 23, 2015 (edited) I need to program a 4 wire stepper motor, problem is, there is no data sheet and no control circuit and i am completely lost. Can somebody please assist me with the ladder logic program to get it up and running? I have access to a decent PLC, and my only option is to hard code this, a control circuit is not an option. Do you mean something like this? It needs voltage peak appearing on right wire in right moment.. See video how he is reversing movement by reversing order. Search also YouTube for "arduino motor" or "arduino stepped motor". Computer program sends data to arduino, like "set pin X to high", "set pin X to low". Write simple C/C++ for-loop, setting and clearing them in right order: 1,0,0,0 0,1,0,0 0,0,1,0 0,0,0,1 Delay between instructions will control speed of rotation. Edited April 23, 2015 by Sensei
CasualKilla Posted April 23, 2015 Author Posted April 23, 2015 (edited) Do you mean something like this? It needs voltage peak appearing on right wire in right moment.. See video how he is reversing movement by reversing order. Search also YouTube for "arduino motor" or "arduino stepped motor". Computer program sends data to arduino, like "set pin X to high", "set pin X to low". Write simple C/C++ for-loop, setting and clearing them in right order: 1,0,0,0 0,1,0,0 0,0,1,0 0,0,0,1 Delay between instructions will control speed of rotation. Yes, I have been trying to create that output sequence, but my PLC makes that difficult, how would I set each pin to Ground or Vdd using my outputs (I would need to use 8 outputs)? Could you purpose a circuit that uses less outputs? (also that looks looks a 5 wire stepper, I have a 4 wire) How do I need to energize these coils to rotate the stepper in one direction? Edited April 23, 2015 by CasualKilla
Danijel Gorupec Posted April 23, 2015 Posted April 23, 2015 With 4-wire motor you must energize your motor windings in both polarities (bipolar). For example (wave drive): Step1: A1 is positive, A2 is negative, B1 & B2 are disconnected Step2: A1 & A2 are disconnected, B1 is positive, B2 is negative Step3: A1 is negative, A2 is positive, B1 & B2 are disconnected Step4: A1 & A2 are disconnected, B1 is negative, B2 is positive ... back to step1.... Full step drive is very similar, only both windings are always used simultaneously (for better torque). I don't know how to insert images so I cannot be of any better help.
CasualKilla Posted April 23, 2015 Author Posted April 23, 2015 (edited) With 4-wire motor you must energize your motor windings in both polarities (bipolar). For example (wave drive): Step1: A1 is positive, A2 is negative, B1 & B2 are disconnected Step2: A1 & A2 are disconnected, B1 is positive, B2 is negative Step3: A1 is negative, A2 is positive, B1 & B2 are disconnected Step4: A1 & A2 are disconnected, B1 is negative, B2 is positive ... back to step1.... Full step drive is very similar, only both windings are always used simultaneously (for better torque). I don't know how to insert images so I cannot be of any better help. Ah ok, so I NEED to be able to switch polarities. Unfortunate.. So I pretty much need a circuit that switches the polarity of the phase with a single output switch, that would solve all my problems.... Is it possible to modified the H bridge to work with one input, input = 1 A positive, B negative then input = 0 makes it the opposite? Edited April 23, 2015 by CasualKilla
Danijel Gorupec Posted April 23, 2015 Posted April 23, 2015 This is normally done wiht a H-bridge (read Wikipedia)... ask if you have questions about a H-bridge. There are maybe simpler ways than H-bridge, but are ridiculously inefficient.
CasualKilla Posted April 23, 2015 Author Posted April 23, 2015 (edited) This is normally done wiht a H-bridge (read Wikipedia)... ask if you have questions about a H-bridge. There are maybe simpler ways than H-bridge, but are ridiculously inefficient. I understand the H-bridge well, but it uses 4 inputs, I would like modify/add on to the H-bridge to use a single switch just to flip the motor polarity. So i can use one switch for each winding, then one switch to connect/disconnect the Vdd. Thus 3 total. That would be ideal. I thought of this idea, but I would need 2 voltage sources and I run the risk of shorting Vdd to -Vdd which sounds very unsafe. Edited April 23, 2015 by CasualKilla
Danijel Gorupec Posted April 23, 2015 Posted April 23, 2015 (edited) Hmm... if you use a more complex power supply (with +V, GND and -V) then you can permanently connect one end of a winding to GND and then use two switches to bring the other end of the same winding to either +V or -V.... This would be solution if you care not to have many switches (but the power supply is then more complex). Edit: I see now you have the same solution and I run the risk of shorting Vdd to -Vdd which sounds very unsafe. It would be the same with a H-birdge... This is a typical thing you have to consider when you build a bipolar drive. Your switch-timing must be carefully considered (when transistors are used, for example, care is taken to always close a transistor few nanoseconds before opening the other one). (Also, and we didn't talk about it yet, you will have to add some diodes to protect transistors/switches from high voltage generated by motor coil when it is switched off) Edited April 23, 2015 by Danijel Gorupec
CasualKilla Posted April 23, 2015 Author Posted April 23, 2015 (edited) (Also, and we didn't talk about it yet, you will have to add some diodes to protect transistors/switches from high voltage generated by motor coil when it is switched off) Hmm yes, the inductance of the coils, good point. I have come up with this solution, its a NPN H-Bridge modified to work with 2 inputs, but this seems to do the same job as ous previous idea. I guess I should check tomorrow if our DC supplies can do the V+ V- thing first. This is the final design, seems to work well, besides the diodes, are there any other components I should add, like capacitors? Edited April 23, 2015 by CasualKilla
Danijel Gorupec Posted April 24, 2015 Posted April 24, 2015 Yes, at first look your design seems ok. Basically, only diodes are needed (make sure you use faster ones). If your power supply is dynamically slow, you might add some capacitors in parallel to the power supply. Your resistors might overheat. I think you can safely double values for R1 and R2 and still had enough base current (modern transistors have high gain). Also place transistors on a heat sink (this is always the hardest part for me). Now... you use 12VDC power supply and 5ohm winding resistance. Do you expect your motor can work with 2A constant current or do you plan to use PWM?
Spyman Posted April 24, 2015 Posted April 24, 2015 (any tips on the voltage I should use would be appreciated)"Like other motors, stepper motors require more power than a microcontroller can give them, so youll need a separate power supply for it. Ideally youll know the voltage from the manufacturer, but if not, get a variable DC power supply, apply the minimum voltage (hopefully 3V or so), apply voltage across two wires of a coil (e.g. 1 to 2 or 3 to 4) and slowly raise the voltage until the motor is difficult to turn. It is possible to damage a motor this way, so dont go too far. Typical voltages for a stepper might be 5V, 9V, 12V, 24V. Higher than 24V is less common for small steppers, and frankly, above that level its best not to guess." http://www.tigoe.com/pcomp/code/circuits/motors/stepper-motors/
Danijel Gorupec Posted April 24, 2015 Posted April 24, 2015 "Like other motors, stepper motors require more power than a microcontroller can give them, so youll need a separate power supply for it. Ideally youll know the voltage from the manufacturer, but if not, get a variable DC power supply, apply the minimum voltage (hopefully 3V or so), apply voltage across two wires of a coil (e.g. 1 to 2 or 3 to 4) and slowly raise the voltage until the motor is difficult to turn. It is possible to damage a motor this way, so dont go too far. Typical voltages for a stepper might be 5V, 9V, 12V, 24V. Higher than 24V is less common for small steppers, and frankly, above that level its best not to guess." http://www.tigoe.com/pcomp/code/circuits/motors/stepper-motors/ Yes... and I can add: - you will want to know how hot gets your motor when its temperature stabilizes at some winding current (preferably through both windings simultaneously). It can be quite warm, but not so hot that you cannot hold it in your hand nor that it starts to smell funny (it is too late then). It takes loooong time for temperature to stabilize (say 15 minutes for larger motors) so take your time before you decide to increase the current further. - you will check other motors in catalogs that have the same physical size and construction and about the same winding resistance... this will give you a good estimation about the current your motor can use.
CasualKilla Posted April 24, 2015 Author Posted April 24, 2015 (edited) Yes, at first look your design seems ok. Basically, only diodes are needed (make sure you use faster ones). If your power supply is dynamically slow, you might add some capacitors in parallel to the power supply. Your resistors might overheat. I think you can safely double values for R1 and R2 and still had enough base current (modern transistors have high gain). Also place transistors on a heat sink (this is always the hardest part for me). Now... you use 12VDC power supply and 5ohm winding resistance. Do you expect your motor can work with 2A constant current or do you plan to use PWM? Yes, I have just test my 100 ohm resistor at 12V and indeed it does burnout after some time, this is a real issue... (using a 200 ohm resistor at 12V heats up alot, but its still going as we speak) I plan to use constant DC pulses, something like this: (the other winding will have its own circuit, this is just for one of the windings) Edited April 24, 2015 by CasualKilla
Danijel Gorupec Posted April 24, 2015 Posted April 24, 2015 If you can decrease your 24VDC power supply to, say, 15VDC (and re-calculate resistor values accordingly) you should decrease resistor heating a lot. Or you can keep as it is, and use more powerful resistors (or use parallel/serial combinations of several resistors). Or you can program your PLC never to keep single output switched on for a long time (when motor is stopped, switch output on/off with, say, 50% duty cycle, as fast as you can).
Sensei Posted April 24, 2015 Posted April 24, 2015 Yes, I have just test my 100 ohm resistor at 12V and indeed it does burnout after some time, this is a real issue... You probably have 1 Watt 100 ohm resistor. Try replacing it by 2 W 100 ohm resistor.
Spyman Posted April 24, 2015 Posted April 24, 2015 If you can decrease your 24VDC power supply to, say, 15VDC (and re-calculate resistor values accordingly) you should decrease resistor heating a lot. Or you can keep as it is, and use more powerful resistors (or use parallel/serial combinations of several resistors). Or you can program your PLC never to keep single output switched on for a long time (when motor is stopped, switch output on/off with, say, 50% duty cycle, as fast as you can). If the PLC have relay outputs with individual terminals, then the 12 VDC power supply could be used to control the transistors. Relay outputs have a mechanical lifetime to consider -> faster switching = broken sooner. If the turning object don't need the motor to keep holding it still when stopped, it's probably better to turn off all power to the motor completely. Or alternatively if it needs a brake to have a second circuit with limited current for the brake feature.
CasualKilla Posted April 24, 2015 Author Posted April 24, 2015 If you can decrease your 24VDC power supply to, say, 15VDC (and re-calculate resistor values accordingly) you should decrease resistor heating a lot. Or you can keep as it is, and use more powerful resistors (or use parallel/serial combinations of several resistors). Or you can program your PLC never to keep single output switched on for a long time (when motor is stopped, switch output on/off with, say, 50% duty cycle, as fast as you can). I designed my circuit for a particular base current to force saturation (hfe = 30 from datasheet). But you are right, smaller Resistance should lead to less heating I^2 * R. Anybody know what kind of max current these std resistors can handle?
Spyman Posted April 24, 2015 Posted April 24, 2015 (edited) Anybody know what kind of max current these std resistors can handle? Resistor Wattage Ratings: The photo below shows various styles and wattage resistors. From left to right, the wattage ratings are: 5 watt, 3 watt, 2 watt, 1 watt, 1/2 watt, 1/4 watt and a 1/6 watt. http://www.bcae1.com/resistrs.htm The link also have a calculator for power dissipation in resistors. Edited April 24, 2015 by Spyman
CasualKilla Posted April 24, 2015 Author Posted April 24, 2015 (edited) Resistor Wattage Ratings: The photo below shows various styles and wattage resistors. From left to right, the wattage ratings are: 5 watt, 3 watt, 2 watt, 1 watt, 1/2 watt, 1/4 watt and a 1/6 watt. http://www.bcae1.com/resistrs.htm The link also have a calculator for power dissipation in resistors. Thank you for that post, I believe I was using a 1/4 W resistor . In terms of the diode, do I need to find a Schottky that can handle more than 3A? Also can anybody explain the current spike in R1 (also happen in R2, but much smaller). Is it perhaps due to my lack of diodes? Edited April 24, 2015 by CasualKilla
Sensei Posted April 24, 2015 Posted April 24, 2015 (edited) Anybody know what kind of max current these std resistors can handle? That depends on voltage. I=U/R = 12 V / 100 ohm = 0.12 A P=U*I=U^2/R=I^2*R=12 V * 0.12 A = 12V^2/100 ohm = 0.12A^2*100 = 1.44 W Whatever method you calculate it's 1.44 Watts = 1.44 Joules per second of energy released by electrons.. They increase temperature of element. If you have some clever method of cooling and will consume energy faster than it arrives (liquid nitrogen? heat sink, fan ) then in theory element should survive much more current than in normal environment. With 1 Watt resistor, and 12 V, you can have up to 83 mA. 1 W / 12 V = 0.08333 A With 5 V, 1 W resistor should survive 0.2 A continuous current. Some suggests that you should have double wattage than typical usage. http://www.robogaia.com/how-to-calculate-resistor-wattage.html Edited April 24, 2015 by Sensei
CasualKilla Posted April 24, 2015 Author Posted April 24, 2015 (edited) That depends on voltage. I=U/R = 12 V / 100 ohm = 0.12 A P=U*I=U^2/R=I^2*R=12 V * 0.12 A = 12V^2/100 ohm = 0.12A^2*100 = 1.44 W Whatever method you calculate it's 1.44 Watts = 1.44 Joules per second of energy released by electrons.. They increase temperature of element. If you have some clever method of cooling and will consume energy faster than it arrives (liquid nitrogen? heat sink, fan ) then in theory element should survive much more current than in normal environment. With 1 Watt resistor, and 12 V, you can have up to 83 mA. 1 W / 12 V = 0.08333 A With 5 V, 1 W resistor should survive 0.2 A continuous current. Some suggests that you should have double wattage than typical usage. http://www.robogaia.com/how-to-calculate-resistor-wattage.html I see, I can handle the math though . It is just not always clear what the wattage spec is. We just have shelves of the cheapies here in the lab. New POST I may not have access to BJT, but I can get N-channel MOSFET's (60W). Could I use a circuit like this? Also, if mosfets will work, how do I drive mosfets "hard-on". For BJTs I just designed the base current to be large enough to break the minimum Ic = hfe * Ib ratio given in the datasheet, which makes it saturated with very low C-E drop. I assume there is also a maximum Vgs I must avoid for mosfets? Edited April 24, 2015 by CasualKilla
Danijel Gorupec Posted April 24, 2015 Posted April 24, 2015 As Spyman nicely showed, resistors come in various standard power ratings. Most often you will find 1/4W and 1/2W (every electronics store)... It is also good practice, as Sensei mentioned, to have some power margin (not necessarily double, but some 50% would be nice). For your simple drive circuit you don't need Schottky diodes... just use some that are faster than typical diodes used in 50/60Hz rectifiers. (If you made a high performance PWM driver then Schottky might be recommended, but in your case is probably overkill).... Anyway diodes are must and if you don't have them you risk damaging your transistors (even motor insulation, maybe). I am not sure what kind of current spike do you see on R1 (during switch-on or during switch-off)? Do you use oscilloscope to see these spikes? BTW, if you don't use diodes all kind of spikes are possible, but I cannot tell for sure if this is the reason.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now