Oscillation in digital feedback loop - Page 1
Forum section: electronics / beginners

author: Unixon
author_rank: Frequent Contributor
timestamp: April 19, 2014, 03:52:55 am
content: I've built this stepper motor control circuit (http://en.wikibooks.org/wiki/Practical_Electronics/Stepper_Motors) with different sets of ICs and in some cases there's weird full supply voltage scale oscillation at tens of MHz happening in logic feedback (in output of synchronous JK flip-flop fed into input of 2-xor gate). Touching the insulation of connecting wires or ground wire as well as touching the package (without touching pins) sometime stops oscillation. What's really going on there and how can I get rid of this oscillation? Will Schmitt trigger buffer in feedback loop help?1) HCF4070BEY+CD4027BE+L293B = works just fine, but DIP packages are huge;2) MC14070BDR2G+M74HC86RM13TR+L293DD = oscillates when "step" is low or in the middle of pulse when "step" is high;3) MC14070BDR2G+HEF4027BT.652+L293DD = same as (2);4-12) CD4070B/HCF4070M013TR/HEF4070BT.653+HEF4027BT.652/HEF4027BT.653+L293DD = didn't try yet, waiting for ICs to arrive;

author: Christe4nM
author_rank: Unknown
timestamp: April 19, 2014, 01:33:01 pm
content: Well let me ask for a bit more information first. I took a quick look at the site you linked in, but maybe you can show us your own circuit. Since that is the actual circuit that has a problem.Now the fact that touching the circuit changes it's behavior has to do with that your finger/hand adds a tiny bit of capacitance to the circuit. The same might hold true for different ICs which most likely have different pin capacitance. That change in capacitance may be just enough to stop the circuit from oscillating.OK, so that might explain a bit, but what is the actual culprit? Well that's why I asked for more information since we'll have a hard time helping you out without knowing how you actually built the circuit. Since you implemented a control loop with feedback my first thought was control loop stability. So before going into too much details, what do you know about control loops? Mind, the actual problem might be quite simple, but you might as well learn something in the processBasically your controller constantly compares a desired output from the motor with the actual output. Subtract the actual output value from the desired value and you are left with the error between them. Say you want to heat a room. Your controller would subtract the actual temperature from the desired temperature. If the result is positive the room is not warm enough and the controller turns on the heater.Now suppose the heater is insanely quick by heating the room from 0 degree C to 50 degree C in just one second. Also suppose that if the heater is off the temperature drops just as quick. Can you imagine what happens?You want the room to be at 21 degree C so the controller turns on the heater. The next second the room is at 50 deg. C and the controller turns the heater off. The next second the room is at 0 deg. C and the controller turns the heater back on. See whats happening here? Oscillation.Now this example is very exaggerated for a heating problem, but it illustrates the point very well.Suppose your motor is able to turn quicker than your control loop can follow. That means it overshoots it's position by a bit. Now the controller reads the actual position and decides that the motor must move a bit back. This can be happening as fast as the controller is so a MHz range oscillation can be the result.Now I'm not saying that this indeedisthe problem, for we'd need to know a bit more about your circuit first. Yet this is the direction that I'm thinking about.

author: Unixon
author_rank: Frequent Contributor
timestamp: April 19, 2014, 03:30:54 pm
content: I've built several implementations of the mentioned circuit in different ways.Actually, the first implementation was built with on a very compact PCB (2x1 inch) from a local board house, using ICs from (2). It has failed to work properly.The second implementation was built on a regular breadboard with ICs from (1) in DIP packages (but these ICs are not exact equivalents, they just do the same function) - unexpectedly this implementation worked just fine.My first guess that was the reason that output of a synchronous trigger is changing when it should stay still is that some internal circuitry is going into linear mode and the entire circuit stops being digital which may become possible due to differences in internal schematics and electrical properties of different series of functionally equivalent ICs.I soldered same SMD ICs as in first implementation to breakout boards and replaced DIP ICs that worked and perfectly reproduced the original issue.In order to find the culprit I began replacing ICs by other SMD equivalents of other series from other manufacturers that would be closer to those that worked.Since I had no all available options, I couldn't check cases (4-12). Now my ICs have arrived and I can test them as well.p.s. Also I have 0.1uF caps at power pins of all ICs, they aren't shown in linked schematic since the article just describes the basic idea.

author: Christe4nM
author_rank: Unknown
timestamp: April 21, 2014, 08:24:12 pm
content: You forgot to attach your schematicsBy the way, I can only think alongside for so much so I hope others tune in as well.

author: Fank1
author_rank: Regular Contributor
timestamp: April 21, 2014, 10:19:25 pm
content: Put a 1k or so load on the outputs of the flip flops.You are driving MOSFETS and they look like capacitors to the logic.

author: TerminalJack505
author_rank: Super Contributor
timestamp: April 22, 2014, 12:25:34 am
content: I would drive the MOSFETs from a buffer (4050, e.g.) or a MOSFET driver (TC427, e.g.) rather than driving the MOSFETs directly from the flip-flop outputs. Those outputs are really puny and aren't designed to drive a large capacitive load like a MOSFET gate.I seem remember reading somewhere (The Art of Electronics?) that, unless you are driving just one or two logic gate inputs, that you should always buffer the outputs of flip-flops.

author: Unixon
author_rank: Frequent Contributor
timestamp: April 22, 2014, 06:18:07 pm
content: No, the logic is driving L293DD H-bridge that then drives the actual stepper motor.I'm linking the schematic down below.

author: Unixon
author_rank: Frequent Contributor
timestamp: April 22, 2014, 06:23:37 pm
content: Quote from: Fank1 on April 21, 2014, 10:19:25 pmI think that 1k is too big load for the purpose a 10k~50k would still work just fine.However, this does not explain why switching occurs not at clock signal front, but whenever the thing wants.Oscillation takes place on M1A / M4A signals between STEP clocks.

author: TerminalJack505
author_rank: Super Contributor
timestamp: April 23, 2014, 01:11:03 am
content: You can try putting some bypass caps on the Vsspin of the L293. I'd use a small ceramic (~100nF) and a largish electrolytic (~10uF.) You might be getting ground bounce during switching.You can also try putting an inductor between Vccand the Vsspin to help keep switching noise off of Vcc.

author: Unixon
author_rank: Frequent Contributor
timestamp: April 23, 2014, 08:31:04 am
content: Quote from: TerminalJack505 on April 23, 2014, 01:11:03 amAs you can see from the schematic I've linked just above, I have all these 100nF caps at power pins. For driver's power line I have C4 of 33~47uF (fits planned pcb layout).I tried to put various inductors of tens to hundreds uH - no positive effect.

author: TerminalJack505
author_rank: Super Contributor
timestamp: April 23, 2014, 12:03:09 pm
content: Sounds like it's time to try using a Schmitt trigger like you mentioned in your first post.

author: Unixon
author_rank: Frequent Contributor
timestamp: April 25, 2014, 05:51:58 am
content: OK, people. I've tested all available to me 18 combinations of ICs for few times and comfirmed only one faulty M74HC86RM13TR 20xor gate (2nd test gave me false positive afterall). I still don't if this particular IC was faulty or the entire model is incompatible, going to check this later. I've built two circuits with HEF* ICs from NXP and MC* ICs from ON Semiconductor on a [pre-]final revision PCB and they work perfectly.So, the problem is solved, but I still don't know why exactly that IC wasn't working.

author: Dave Turner
author_rank: Frequent Contributor
timestamp: April 26, 2014, 06:10:48 pm
content: Can you confirm that your schematic is correct? I note that clocks on the 4027 are tied to ground via a 10k resistor. As far as a recall the output changes state on the clock rising and falling edge.

author: Unixon
author_rank: Frequent Contributor
timestamp: April 26, 2014, 09:32:23 pm
content: Quote from: Dave Turner on April 26, 2014, 06:10:48 pmYes, it works now. The only problem I could eventually confirm is one faulty/incompatible type of ICs. All inputs with active high level are tied to ground to avoid undefined behavior. Finally, yes, the outputs are changing on the the clock rising edge.

author: Dave Turner
author_rank: Frequent Contributor
timestamp: April 26, 2014, 10:48:38 pm
content: What I'm getting at is how can the clock trigger anything if it's tied to ground.Since you said that it's working now (excellent) I had to assume that the schematic was in error unless I've misread the circuit.

author: TerminalJack505
author_rank: Super Contributor
timestamp: April 26, 2014, 11:08:24 pm
content: You'll notice that he labeled the net ("STEP") on the other side of the resistor so it is connected to the signal of the same name on the JP4 header. Basically, it looks like the resistor is meant to weakly pull the clock pins low so that they have a defined state when the off-board driver is in a high-impedance state (powered down, resetting, disconnected, etc.)

author: Dave Turner
author_rank: Frequent Contributor
timestamp: April 27, 2014, 05:37:47 pm
content: Quote from: TerminalJack505 on April 26, 2014, 11:08:24 pmMissed that - makes sense now.