control for stepper motor

Discussion in 'General Electronics Chat' started by gregcoll, Oct 11, 2009.

  1. gregcoll

    Thread Starter New Member

    Oct 11, 2009
    21
    0
    Hi

    I have a small stepper motor for which I am trying to build a controller. I have constructed various separate mini circuits that will be assembled for the final project and all have worked except for my memory portion. I am using a 555 timer for the pulse to clock a CD4042BE quad clocked d latch. First off, it should be obvious that I don't really have any idea what I am doing, I usually just play around while learning (and usually buying new parts), I don't even know if the final assembly will work together. The timer uses a capacitor with a fixed charge resistor and an adjustable discharge resistor to hopefully allow speed control of the motor. Anyway, the part that is giving me problems is the clocked d latch. I have gone through the basics of how and why it works but cannot get it to clock and latch. Possibly I have damaged this device. I have Vdd (5V+)and Vss and am getting 5V out of Q with nothing at D (that is, no wires attached). If I apply a signal (I used 5V) to D nothing changes which is backwards from the tutorials I have read. If I apply ground to D I get a switch of Q and Qbar but if I apply a signal to the clock (again 5V and also tried ground) it will not stay latched, the outputs stay switched for about 5 seconds then switch back. So, basically after all this explanation, my question is: What is meant by a signal to clock? (i.e. + or - voltage, current limits, ???) And is there a requirement for pulse length? (the data sheet indicates that there is not) I need to save the last state of the motor to allow for selection of the next stator winding otherwise I would not mess with this except to learn how it works for fun. Thanks for help with my errors.
     
  2. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    OK, first thing is you really should post a schematic of your circuit as it's currently configured, as that cuts out a lot of Q & A's back and fourth.

    CMOS inputs must not be left "floating"; they must have a current path to either Vdd or Vss (ground), either directly connected w/wire, connected via resistors (10k is typical) or supplied by another CMOS device that provides a non-ambiguous input.

    Each CMOS IC should have a 0.1uF capacitor across it's Vdd and Vss pins.
    The 555 timer is a special case; it should have a 220uF and an 0.1uF cap across it's power supply pins (Vcc and GND) otherwise it will wreak havoc on your other logic ICs.

    Pin 5 of the 4042 is the clock input, pin 6 is the polarity input. If you want the data to be latched in when the clock goes high, then tie the polarity input to Vdd. If you want the data to be latched in when the clock is low, then tie the polarity input to ground/Vss.

    Your 4042 IC will not be able to source or sink enough current to drive your steper motor. You'll need something like a ULN2004 Darlington driver to sink current (if it's a unipolar stepper) or a bipolar driver/dual H-bridge if it's a bipolar stepper.

    A signal to clock means a valid CMOS logic level. Your input signal should be either close to Vdd or close to Vss. A signal 1/2 the way between the two would be ambiguous. A "floating" input would be unpredictable.

    It only takes a tiny amount of current to charge/discharge the input of a 4000-series CMOS IC to a logic level.

    You might want to go to ONSemi's site and download the datasheet for an MC14042B; that's the same as a CD4042B.
     
  3. gregcoll

    Thread Starter New Member

    Oct 11, 2009
    21
    0
    Hi
    Thanks for the information! I can post a circuit diagram given some time to try to make it but you really don't want to see it I assure you. I am using some 1 amp npn switching transistors to then operate some small relays for the stator excitation part and am using some LED's right now for testing purposes. My plan is to use the d latch to operate the transistors. The d latch is operating the transistors with LED's with no apparent problem, just not in a clocked fashion. So, I should put polarity to ground (I want this function) and switch the clock between Vss and Vdd to get it to clock and use similar signals for the data input if I have understood your explanation. My only question at the moment is if the 555 switching will be fast enough so as to avoid non-ambiguous inputs. I guess I can connect them with your suggestions and see what happens. Thanks again.
     
  4. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    We've all made some awful looking circuits in our time. ;)
    I hope that you are using resistors (3k or higher) between the output of the 4042 and the bases of the transistors; otherwise the outputs would be very overloaded. You might be better off using logic-level MOSFETs. The relays will operate far too slowly to get any kind of RPM's out of the stepper motor.
    If polarity is held high, then while the clock is low, the latched data will be on Q.
    When the clock is high, the data input will be on Q. When the clock returns low, the last data input is latched.

    If you want to be sure of having non-ambiguous data on the inputs, you will need to use a Schmitt-trigger gate to condition the input.
    http://en.wikipedia.org/wiki/Schmitt_trigger

    A 4093 is a quad Schmitt-trigger NAND gate. A 40106 is a hex Schmitt-trigger inverter. There are not many 4000-series logic ICs that have Schmitt-trigger inputs. However, you can create the functionality of any other logic gate using just NAND gates.
    http://en.wikipedia.org/wiki/NAND_logic
    To make a pure Schmitt-trigger without inverting, wire two of them together to create an AND gate, and then tie the two inputs together.
     
  5. gregcoll

    Thread Starter New Member

    Oct 11, 2009
    21
    0
    Many thanks once again.
    Actually, I put an in-line resistor from my regulator into Vdd and was relying on that (I told you that looking at my creation would be a bad thing). I see that I have much reworking to do. I will also look into this Schmitt trigger and see how much trouble I can get into trying to make it work. Actually, I only want maybe 10 or 15 rpm max with most of its use being slower but the logic MOSFET's will probably give more reliability and help clean up my circuit board. But first to see if I can get this thing to latch the data. So, here's to blind luck (along with some good advice) and I will see tomorrow if I can make any progress. Thanks!
     
  6. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Having a resistor to limit current to a load isn't completely a bad thing. However, TTL and CMOS devices won't work very well if you have a power source with high impedance/resistance.

    OK.
    Some things that you need to know about relays (and coils in motors, too);
    When you energize a relay coil by sending current through it, a magnetic field is established around the coil. When current is suddenly stopped, the magnetic field collapses and tries to keep the current flowing in the same direction. This causes the voltage across the coil to reverse in polarity, and become very high for a brief moment. This can fry components attached to the relay's coil. To take care of this reverse-EMF, a diode should be connected across the terminals of the coil, with the cathode (end with the stripe) pointing towards the more positive supply voltage.

    You can use a 1N914 or 1N4148 switching diode across the relay's coil.

    A stepper motor needs similar protection. Find a datasheet for an L297 driver; it shows connections for an L297, L298 and stepper motor with eight protection diodes. A 1N914 or 1N4148 diode won't carry enough current for the stepper motor protection diodes; you'd need to go to something like a 1N4004.

    Relays contacts will "bounce" when they change states. So do switches. The bounce time seems extremely short to us humans, but in electronics terms, the bouncing goes on for a seeming eternity. While the contacts are in "flight" during a bounce, they don't conduct electricity. It's OK to use them for very low-speed testing/experimenting, but don't expect to get any speed out of it.

    Relay contacts can take quite a while to change from one position to another; anything between 20mS to 200mS. That's just for the initial switching; the bouncing can go on longer. Depending on your motor's step angle, it could take a couple hundred switching operations just to make one complete revolution.
     
  7. gregcoll

    Thread Starter New Member

    Oct 11, 2009
    21
    0
    Hi again

    The data sheet says that there should be a max of 10 mA at any input so this was my reasoning behind the power input to Vdd having a resistor.

    Actually I was using 1N4004 diodes for the inductance in the relays and the stepper motor windings. Is this overkill? I was assuming (and hoping) that the diodes were not too leaky(?) for the relays (which I will most likely replace with the logic MOSFET's when I can make it to the store). I was planning on putting some small capacitors across the diode also just to make sure. I am a physics grad student and so have taken several EM classes and so I kind of understand how these things work but when I go to apply them (e.g. calculate capacitor for circuit) my tiny mind begins to swim. I know how much time I have spent trying to learn what little I know about my field and this is why I appreciate the help from guys like you taking the time to share your knowledge.
    I had a couple of issues to deal with this morning and was just now sitting down to see if I can get this thing to latch.
    I had an idea for my pulse: I am going to put Vdd through a 10k resistor to the clock and tie this (in series) to one of these switching transistors with Vss at the emitter so hopefully I can get Vdd at the clock with the base low and Vss with the base high. This is probably another bad idea but since you don't know of my plan (as I am writing) and can't talk me out of it, and I need something like this to make it work, I am going to try. I will let you know of my success or failure. Once again, thanks!
     
  8. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Yes, however the voltage should be well-regulated. Voltage supplies have very low output impedance. Current regulated supplies have very high output impedance. When you are dealing with TTL/CMOS logic ICs, you want very well regulated voltage supplies. Putting a resistor in series with the power supply throws that out of whack.

    No, that's just fine. The 1N914/!N4148's are faster switching and smaller, but with much lower current handling capacity. That's why I suggested using the 1N914/1N4148 for the relays and 4004's for the motor windings.

    They'll be fine as long as you have installed them with the cathode towards the + supply.
    You can do that if you wish. Somewhere in the range of 220pF to 470pF ceramic caps should work just fine. They will "buy time" for the diodes to turn on.
    Posting a schematic would help a great deal.
    If you don't have a schematic capture/SPICE program, you can download/use Linear Technology's LTSpice for free. Google is your friend here. There is a learning curve, but it will help you a great deal.

    On your transistor scheme; you will need a current limiting resistor on the base. 1k is a typical "general purpose" value used around here. The rule of thumb for saturating a transistor is that the base current is 1/10 the collector current. If you are using a 10k resistor to Vdd from the collector, you could actually use a much higher value for the base resistor.
     
  9. gregcoll

    Thread Starter New Member

    Oct 11, 2009
    21
    0
    So, SgtWookie, I hope you will let me know if I am imposing on you, seriously. At any rate, until you do I have more questions. I downloaded LTSpice and definitely found that curve you were talking about. I started a circuit but after not being able to change the type of power supply to one like I have and not finding a symbol for a voltage regulator I drew a very simple version with Word. I have ordered NI circuits (I use LabVIEW all the time and like its format so decided to give it a try) and can try again when I get it. So, the circuit is fairly simple (not sure about the size of the capacitor at the 12V rectifier or if even needed). But I have a 5V source to the logic circuit (which will also power my 5V 1A motor, should I use a separate regulator circuit?). I have used a 3.3K ohm resistor from the 5V supply to the clock and done like I said before, tieing this to the collector with the emitter going to Vss. Base is supplied through a 10K resistor.... it surprised me by seeming to work. One question here, I am 'pulsing' a signal by touching base to 5V (through the resistor) and sometimes it seems to have not changed outputs. I attributed this to a shaking hand sending multiple signals but possibly this is not the case and it is not changing. IF this is the case do you have an idea what the culprit might be? From the circuit diagram I sent, you can see that I am circuits 2 and 3 in the d latch. I am supplying the data to D2 from Q3 and data to D3 from Q(bar)2. This gives a rotation through the signals I would like and should be correct (in a perfect world). The outputs (after any tie to a data supply line) go through 3.3K resistors and then through 1N4004 diodes and finally they go to their respective npn transistor base input. The transistors are running four LED's that I am using to check function and also for the correct sequence. The LED's are supplied by 5V through a 150 ohm resistor (red color). This is not exactly the right resistor but is close enough for now I think. So this is my circuit so far. If you come up with anything and have the time, let me know. Until then, thanks for the suggestions. I am going online to look for some suitable logic transistors.
     
  10. gregcoll

    Thread Starter New Member

    Oct 11, 2009
    21
    0
    How about FQE10N20LC (4A, 200V logic n-channel mosfet)?
     
  11. gregcoll

    Thread Starter New Member

    Oct 11, 2009
    21
    0
    Forgot the data sheet. Here it is.
     
  12. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    OK, a couple of things that will help a good deal.
    1) Please don't use login names in replies, unless you have specific questions about something that someone posted that you feel only they are capable of answering.

    For example, many people on the forums use LTSpice, and could help you with questions about that software. By prefacing your inquiry with my login name, others who have knowledge with this software (indeed, more than I may have) may be hesitant to reply. This delays the information that you need.

    2) Please try to organize your thoughts into sentences that fit into paragraphs of 3 to 6 lines. It is tiring to read a large block of text.

    Questions are fine. Please try to "bullet" or otherwise organize them.

    There is a symbol called "voltage" in the libraries. Plunk one of those in the schematic. Put a ground on one side of it. Right-click it and specify the voltage you want. Presto, instant ideal power supply. It's so good that you can't buy one anywhere, no matter how much you paid for it.

    I'm unfamiliar with that software. I had a trial version of NI's stuff installed for a while, but never really used it.

    [/QUOTE]So, the circuit is fairly simple (not sure about the size of the capacitor at the 12V rectifier or if even needed). But I have a 5V source to the logic circuit (which will also power my 5V 1A motor, should I use a separate regulator circuit?).[/QUOTE]
    Don't have your schematic open at the moment; I had to edit your text before I could read it.
    [eta] I do now. If you have regulated 12.6v available, you won't need caps on the input of your 5v regulator.
    The 7805 regulator will be fine for your logic portion. It will be woefully inadequate for your motor. It's only rated for 1A.

    I don't know what you're talking about here. It's not shown in the schematic, which is just slightly more than a block diagram.
    I have a mental image of components hanging in midair everywhere in a haphazard manner. I have no clue what you have going on there.

    Not without better documentation in the form of schematics and photographs of your set-up.

    That isn't clear at all.

    Why would you want diodes in the way? You DO know that an NPN transistor BE junction looks like a diode already, right?

    If your Vcc is 5v, and the LEDs are rated for a Vf of 2v @ 20mA, you're fine.

    So this is my circuit so far. If you come up with anything and have the time, let me know. Until then, thanks for the suggestions. I am going online to look for some suitable logic transistors.[/QUOTE]
    2N3904, 2N3906, 2N2222, 2N2907, 2N4401, 2N4410 will all work as switching transistors.
     
    Last edited: Oct 13, 2009
  13. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Nope.
    Shoot for a power MOSFET that's around 8A, 30v.
    When you go up in voltage rating, gate charge goes up.
    When you go up in current rating, gate charge goes up.

    You want 2x current rating, 2x voltage rating, or as close as you can get.

    Might look at an IRLU7807.
     
  14. gregcoll

    Thread Starter New Member

    Oct 11, 2009
    21
    0
    thanks again
     
Loading...