Pulse multiplier circuit? - Page 1
Forum section: electronics / projects

author: blazini36
author_rank: Regular Contributor
timestamp: July 14, 2022, 03:59:54 pm
content: I've been working on basically an improved stepper motor driver for an old machine. The machine itself outputs what is basically quadrature from a Motorola MCU to drive the original stepper driver which was a custom job. It basically uses 2 outputs to output 00 01 11 10 in cycles. I use an LSI chip to convert the quadrature into Step+direction then feed that into a step driver module. I made the Step driver itself modular because it's getting rather difficult to get many stepper ICs these days. Right now I use a DRV8825 but that's not really important.I didn't use much effort to figure out how the original step driver worked, but my setupdoes workthe problem is it interprets the quadrature cycles as exactly half the steps. The LSI chip, (can't think of it at the moment) but it has a selectable resolution. @ 4x it basically outputs 4 pulses per quadrature cycle while detecting the direction. That is all fine but in practice I notice with the DRV8825 or an external stepper driver set to full step It will move exactly half the distance the original drive will. Now I cannot alter the software on the MCU that is outputting the quadrature for commanding the movement, and I do not really want to use an MCU on my device either it's overkill and just not necessary.So at the least I need to use some pulse doubler circuit between the LSI chip and the Step driver. Even though I kind of knew it wouldn't work, I used a PLL with the lowest minimum frequency I could find (501MLF) as a test and it did not work. Would have been nice because it had 8x multiplication but the input is just too slow, looking @ 1-2khz going into the device that has to do the pulse multiplication. I've seen some circuits around the net but I'm not sure the ones I've come across were all that great for this purpose. I need to at least double the pulse rate, then this thing is useable. Any multiplication I can do beyond 2x would be great for microstepping. Ideally I would find a magic chip to do this but I cannot find anything to work with such slow a frequency so hopefully someone here has a suggestion.

author: blazini36
author_rank: Regular Contributor
timestamp: July 14, 2022, 07:58:02 pm
content: Well I've come across relatively simple schematics for pulse doublers that use a comparator and an XOR gate. Trying to avoid using an MCU, for one programming is not my strong suit, There is not much space left on this PCB and it will be difficult to manage noise and routing it going to get out of hand. I have a rectifier, bulk caps optos and motor power traces running from one end to the other. It has to drop into place of the old device so the PCB has to be routed so that the original connectors don't have to be rewired.I use alot of Teensy4.x's on other things, that's obviously overkill here and I don't have the space. If you can recommend a small MCU something with some legs that uses very little external circuitry and can deal with relatively lousy routing on a 2 layer PCB, I could probably make it work. In that case I would get rid of the LSI chip and use the MCU to convert the quadrature to step and direction and obviously with an MCU I wouldn't have to worry about doubling the pulses. I haven't really worked with discrete MCUs I'm not all that concerned about it, I'm just not sure what I can get my hands on to do the job.

author: eugene
author_rank: Frequent Contributor
timestamp: July 14, 2022, 09:00:10 pm
content: What do you mean by "pulse doubler"? The quadrature output changes state 4 times per cycle. You can generate 1 pulse (with direction) per transition.If you wanted to have 8 pulses per cycle, how would you knowwhento send the extra pulses? I suppose you could just send 2 pulses instead of 1 at every change of state of the quadrature output...What does the LSI chip output now given the described quadrature-like input?

author: blazini36
author_rank: Regular Contributor
timestamp: July 14, 2022, 10:32:15 pm
content: Quote from: eugene on July 14, 2022, 09:00:10 pmLol exactly what it sounds like, 2 pulses out for every pulse inQuote from: eugene on July 14, 2022, 09:00:10 pmI described all of that in the original post I thought. Yes, there are 4 state changes per cycle, and the LSI chip outputs 4 pulses per cycle when set to x4 mode. Now that I'm in front of my workstation, it is an LSI7184https://lsicsi.com/datasheets/LS7183N_LS7184N.pdf. That is not the problem, the old driver used 2 driver chips presumably to do some kind of trickery with the number of quadrature cycles coming in vs the cycles to drive the motor. Each of those chips by itself has enough power to drive the small stepper and I can't explain exactly how it worked because I purposely did not try to reverse engineer it. They're relatively simple drives but clever in the way they were implemented. For whatever reason they are totally useless with motors having <~50ohms coil resistance and they are a bit flaky overall. This is not off the shelf stuff, they were purpose built 20+ years ago to drive a stepper motor on a specific machine. The machines MCU as it's explained to me determines the number of steps to move from an input command and the quadrature type output is only adjustable within an 8-bit range. There is not enough room to double the quadrature output from the MCU and messing with the software in that machine was not my intention anyway.What I can say is in practice I have the machine, with the original geared stepper and original stepper driver If I command it to move 0.030" then measure it's movement physically it does just that. Now that original driver will not drive a typical modern bipolar stepper. The driver's I made will drive both the original motor and a modern motor with sub 1ohm coil resistance without a problem. Measuring the distance traveled shows 0.015" when commanded to move 0.030". And this is feeding a drv8825 set to full step with the LSI chip in x4 mode on both new and old motors. Both motors are 1.8degree bipolar steppers with the same gearbox ratio. So based on that I'm determining that the original driver was somehow doubling the effective step cycles. If I can simply double the output from the LSI chip I will be moving 1:1. The pulse rate of this thing is pretty slow, it's nothing for a drv8825 or any other microstep chip, in fact ideally I'd like to x8 this signal so I can 1/4 step the driver but that's not really necessary. I came across this pulse doubler circuithttps://www.maximintegrated.com/en/app-notes/index.mvp/id/3327/that looks like a contender.I'm just kind of amazed this doesn't seem to be more common practice until you get into mhz-ghz ranges. The 501MLF PLL multiplier I tried doesn't work with such slow frequencies, but then again it only claimed to work down to 2mhz. If I could find a chip like that that actually worked at ~2khz I think I'd be set.

author: langwadt
author_rank: Super Contributor
timestamp: July 14, 2022, 10:56:38 pm
content: sure you have the driver in full step mode?

author: blazini36
author_rank: Regular Contributor
timestamp: July 14, 2022, 10:59:58 pm
content: Quote from: evb149 on July 14, 2022, 09:40:11 pmThanks for the suggestions. I'll definately be doing more than 1 but not "mass produced" I make all of my PCBs by hand with paste and stencils. I try to stick with SMD packages but passives I try to stick with 0805 and such. I can solder BGA and 0201's but I really don't enjoy it. If I go the MCU route I'd probably use something like thishttps://www.digikey.com/en/products/detail/microchip-technology/ATTINY44A-SSUR/2357401or the QFN package, the through hole takes up too much space and messes with the backside routing. I've heard of attiny's before, but never really looked into them. Looks like they can be programmed with Arduino IDE and you can use an Arduino as a programmer which simplifies things quite a bit.I'd still love to just find a simple multiplier chip that would work here but barring that it might be a good idea to just change course and use the MCU.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 14, 2022, 11:23:33 pm
content: Quote from: blazini36 on July 14, 2022, 03:59:54 pmLet me explain in terms others can easily understand:The setup is like this:═≣The host uses two logic level lines to tell the driver what to do.A transition in the logic levels causes the motor to turn very slightly. The pairs of states are ordered thus:0 00 11 11 00 0and only one of the logic lines can change at a time. Transitioning downwards causes a tiny bit of rotation in one direction, upwards in the other.Because the driver is a custom job, OP has replaced it with a module that converts the logic line changes into pulses, and another logic line indicating the direction. So, every transition causes a pulse, and the direction (up or down in the above diagram) defines the state of the other line.This is then fed to a common stepper driver, currently a DRV8825. These drivers support more than one pulse per "microstep": they have DACs that can generate sinusoidal currents, instead of just on or off. The pulses needed for a full step are always a power of two, and 2 (half-stepping), 8, 16, 32, and 256 are currently common.So, OP's problem is to multiply each incoming pulse by inserting a (fixed-length) pulse midway between each incoming pulse.Even better results would be to generate a pulse train where the interval between pulses tracks the input pulse rate (and count!) exactly, but at a higher multiplier, and the interval varies smoothly.If we look at an example case, and pick rising edge as our trigger (use the edge that follows the default state; is normally low, but could be high if intended to use with optoisolated inputs on a driver), OP wants to convert↑ ↑ ↑into↑ ↑ ↑ ↑ ↑ ↑or↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑and so on. Although input pulse length may vary, only the initial transition matters, and output pulses can be of fixed width.Is this the only stepper motor involved? Or is there actually a pair of steppers here?I don't think this is too complicated to do in software on a small MCU, but the critical thing is the allowed latency. If the output can be delayed by either a fixed amount, or by a single input pulse (up to a maximum, the inverse of minimum interpolated speed), then it is doable. Otherwise you need predictive logic, and that tends to behard, since the exact number of pulses emitted truly needs to be exact (multiple of input pulses).Things that such a choice affects includes end stops. Personally, I'd also wire any end stop sensors to the MCU, too.Personally, I'd eschew 8-bitters, and use an ARM one with a cycle counter (ARM_DWT_CYCCNT), and run it as a state machine. I'd probably need to use a predictive algorithm, so to avoid losing steps, I'd have it track the virtual position output (a counter that is incremented at each output pulse if direction is high, and decremented if low), as well as the input (but this time the increment/decrement count being the multiple of pulses), so that if discrepancies do occur, they can be "cancelled" by omitting a future one or at the end of a pulse train (when minimum speed pulse interval is exceeded), corrected by a final pulse in the right direction. Better drivers like Trinamics do something similar internally anyway.Edit: Uh, so perhaps try a Trinamic driver, say TMC2208, since it natively does this pulse multiplication/interpolation anyway, and pretty well, too?

author: blazini36
author_rank: Regular Contributor
timestamp: July 14, 2022, 11:58:01 pm
content: Quote from: Nominal Animal on July 14, 2022, 11:23:33 pmYeah you pretty much got it there. That last edit you'll have to explain to me though. If that's the case, yeah you're right it solves the problem. I did a quick scan of the datasheet and didn't really see what you're speaking of, can you point that out? The driver section of my setup is a module, so this would be a good solution.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 15, 2022, 12:22:51 am
content: Quote from: blazini36 on July 14, 2022, 11:58:01 pmTrinamic drivers like TMC2208 are silent because they implement what Trinamic callsmicroPlyer interpolation unit.Essentially, it internally always works at 256 microsteps per full step mode, and simply interpolates incoming pulses roughly how I described, so that the output is very close to sinusoidal.In thedatasheet (TMC2202/08/24, PDF), it does mention that it does not supportfull stepinputs; it needs at least half step inputs (2, 4, 8, 16, 32, microsteps per step are supported). So you still might need that pulse doubler, unless halving the speed and range is also acceptable.However,TMC2130supports full step inputs, and does do microPlyer interpolation to 256 microsteps per step. See Chapter 16.3 MicroPlyer Step Interpolator and Stand Still Detection, page 71 onwards, in the datasheet. As these are widely used in 3D printers, you can find a simple breakout board with TMC2130 (for example from BigTreeTech) on eBay and BangGood for less than $10 apiece. Even if you do do your own board, I recommend testing with one of these first. Note that you do need to program them via SPI, for example to set theintpolbit in theCHOPCONFregister, to enable microPlyer. Also, at very low pulse rates, microPlyer does not work: it has a minimum speed at which it can do the interpolation, so at the very slowest of movements, you will still get clear pulses. (Just like a single pulse full step movement using DRV8825, in other words.)