need advice for frequency to voltage converter

Discussion in 'General Electronics Chat' started by strantor, Jan 23, 2013.

  1. strantor

    Thread Starter AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    I want to make basically a DAC for interfacing with a quadrature rotary encoder. It needs to read the frequency of a square wave and put out an analog ±10V proportional to frequency. For example, I connect a 1024 pulse per revolution rotary encoder to a motor with a max speed of 3400 RPM. That corresponds to 58,027Hz, and I want this to give me a voltage of 10V. @ 1700RPM I would want 5V output, and so forth. I want to also be able to differentiate between forward and reverse, using the encoder's A & B channel phase offset.

    I've seen TI's LM2719 but I'm not sure if it's exactly what I'm looking for. Seems to need a different capacitor/resistor combination for different pulse per revolution encoders. I would like to be able to change pulse per revolution for any standard encoder, from 1 PPR to 1024PPR, via dip switch setting or programming.

    Is this doable with discrete ICs? Or is this a job for a microcontroller? If so, which one would be a good candidate?
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,418
    3,355
    For a given encoder (e.g. 1024 ppr) a simple monostable multivibrator with an output pulse width of 17μs (the reciprocal of 58kHz) would do the trick. You can use a standard monostable such as 74LS123 or 14538 or 555.
    This will give you a PWM signal that has a fixed pulse width but changing frequency. Feed this into a low pass filter and you will get a voltage output proportional to rotational speed.

    One problem is at very low speeds the filter time-constant will have to be longer.

    For different encoders you would have to alter the pulse width accordingly by simply changing the timing resistor or capacitor.
     
    strantor likes this.
  3. GopherT

    AAC Fanatic!

    Nov 23, 2012
    5,984
    3,725
  4. strantor

    Thread Starter AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    Gopher, that IC is basically the same thing as the LM2719, the TC9400, and the XR4151. The app note you linked to has much more information than is available for the others, but they all seem to work on the same principle. These all (+ Mr Chips' circuit) seem to need a different resistor/capacitor setup for any intended max frequency. Also none of these have a provision to differentiate between forward and reverse. The quadrature encoder has an A channel and a B channel which are 90deg out of phase, and from this it is possible to determine direction.

    I'm thinking that a microcontroller would simplify things by not needing potentially infinite resistor/capacitor combinations and by determining direction without needing an additional circuit. The problem is I'm a total noob as far as UCs are concerned. from what I understand, accurately reading pulses like this would require the use of an interrupt, and i'm not sure what that means or if it's a bad thing. Is there a UC out there that is well suited to my application?

    or am I still barking up the wrong tree asking about UCs?
     
  5. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    uC is probably the easiest way to do this... some uCs come with a module specifically for decoding a quadrature encoder, others have a timer approach. Interrupts are great, provided you do them properly. However, doing this doen't require an interrupt, though they do make things easier...

    Microcontrollers make a lot of things easier, you may want to learn them just to get another tool in your utility belt...
     
    strantor likes this.
  6. strantor

    Thread Starter AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988

    Thanks for the tips! Ok, so I see that Microchip offers a few uCs with quadrature encoder modules; PIC24EPxxxxxxxx, dsPIC33 (several), and dsPIC30 (several). I looked into dsPIC33 a while back for a different project and IIRC it required a lot more costly initial investment than just pickit - I believe because it needs a different compiler or something. Could I use the pickit (as shipped) for the PIC24EP or would I need to buy some additional software for that as well?

    is there any other uC that might be a better fit?

    EDIT: PIC devices with QEI module: (dsPIC33EPXXXMC20X/50X and PIC24EPXXXMC20X DEVICES ONLY)
     
    Last edited: Jan 25, 2013
  7. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    The Pickit 3(the one you linked) should be able to program all of PICs out there, I believe.

    If you use Microchip's MAPS tool, you can select that you want a uC with X number of quadrature encoder reader modules, QEI. It came up with primarily dsPIC30s, dsPIC33s, PIC24s, and, a couple PIC18s(18F4331 & 18F2331). The 18F is probably the easiest platform out of the others listed to start uCs with.

    The software is Microchip's MPLAB(it's free!), this will interface to the Pickit 3 and program & debug your uCs from there...

    Microchip now offers free versions of all of its C compilers...
     
    strantor likes this.
  8. strantor

    Thread Starter AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    awesome! I didn't find the PIC18F with QEI, probably because I wasn't using the MAPS tool. I'll probably go with that one. Do you think I can swap out the PIC18F45K20 that comes on the development board with a PIC18F2331/2431/4331/4431?


    EDIT: I created a new thread for this question, here.
     
    Last edited: Jan 25, 2013
  9. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    Why bother with a quad encoder module?

    To get the speed you only need to get the period of one encoder sensor, quadrature is not needed.

    How accurate does the voltage output need to be and what response speed is needed? Will it be changing speeds rapidly or just required to keep the speed (and voltage) constant?
     
  10. strantor

    Thread Starter AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    The reason for bothering with quadrature encoder module is because I need to be able to interface with encoders of different pulses per revolution, theoretically from 1PPR to 1024PPR, maybe more, and every solution I've seen so far outside of the QEI requires a specific combination of resistor and capacitor for the intended max frequency. and:
    But I want to determine direction as well, which requires both. I want to have a negative 0-10V for 0 to -max speed.
    It needs to be as accurate as a DC tachogenerator, which I believe is deadly accurate.

    It also needs to actually go all the way down to zero. A lot of the solutions I've looked at are only accurate from 10%-100% or similar.

    Speed, the faster the better. I don't really know where to draw the line but I think anything over a couple hundred mS would be a bad deal.
     
  11. MrChips

    Moderator

    Oct 2, 2009
    12,418
    3,355
    In that case you need to go fully digital.
    Interface the encoder to a microcontroller and count pulses.
    From there you can determine speed and direction and output the voltage to a DAC or PWM.
    You can use DIP switches to select your options.
     
    strantor likes this.
  12. strantor

    Thread Starter AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    that was the plan. I was looking at microchip's DACs that communicate via I2C. I was thinking DIP switches in the same way I've seen DIP switch address settings, like:
    1: 1
    2: 2
    3: 4
    4: 8
    5: 16
    6: 32
    7: 64
    8: 128
    9: 256
    10: 512
    11: 1,024
    12: 2,048
    13: 4,096
    14: 8,192
    15: 16,384
    16: 32,768
    The switches add up and you multiply encoder PPR X max motor speed and divide by 60, so for example if your encoder was 120PPR and your motor was 1200RPM, your max frequency would be 2400, and you would turn on switches 12, 9, 7, and 6.
     
  13. MrChips

    Moderator

    Oct 2, 2009
    12,418
    3,355
    btw, to read 16 dip switches, you only need 5 I/O lines.
    Four outputs go to a 4-to-16 decoder to the switches.
    All the switches then feed into one input line.
    You scan across all 16 switches and determine which ones are closed.
     
    strantor likes this.
  14. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    Thanks for clarifying that Strantor, I didn't know it had to provide -10v in reverse.

    Really this is not going to be an easy project, if you want fast, highly accurate and also highly accurate negative voltages in reverse.

    It gets harder if this device will be placed into a closed loop for machine speed control to replace a tachogenerator, as that control loop will add its own complexities regarding response time and instabilities caused by DAC granularity etc.
     
    strantor likes this.
  15. panic mode

    Senior Member

    Oct 10, 2011
    1,318
    304
    technically everything can be done using discretes but i agree with RB that this may not be trivial.

    for example decoding direction of quadrature encoder can be done with pair of D flip-flops or specialized products like LS7084:
    http://www.lsicsi.com/pdfs/Data_Sheets/LS7083_LS7084.pdf

    using monostables one can get PWM signal with mean corresponding to frequency which is fine for displaying purposes but required filter will introduce delays. this skew can be minimized using real DAC (and MCU).

    to distinguish 16 positions you don't need decoder IC, it is enough to use a 16-position encoded switch like CD16R. to read it you need 4 inputs on MCU.
    http://ca.mouser.com/ProductDetail/CK-Components/CD16RM0AB/?qs=sGAEpiMZZMu6TJb8E8CjrzjMdeTyoZaF

    but if this is meant for interfacing to PLCs, why not use appropriate PLC input directly and avoid conversion to analogue or using custom hardware?
     
    strantor likes this.
  16. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    What resolution do you need?

    If you called a 2.5V output zero, then scaled from there to ±10V, that would reduce the uC resolution by 4, so a 1024 bit DAC output would effectively be a 256 bit DAC after scaling.
     
  17. MrChips

    Moderator

    Oct 2, 2009
    12,418
    3,355
    Another way of putting this is saying that the DIP switches would represent a 16-bit binary value which would be interpreted as an unsigned integer from 0-65535 or 1-65536.
     
    strantor likes this.
  18. strantor

    Thread Starter AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    True. It will need to be pretty fast or could cause oscillations or other loop corruption. However I would hope that whatever control loop it ends up being included in, can be properly tuned to compensate; after all it seems (to me) that any slight lag introduced by the device would be no different than a fixed value additional mechanical load. I hope that whatever instabilities and granularity can be minimized by using a high resolution DAC.

    This is not for interfacing with PLCs, really. It's meant to be a replacement for costly analog tachogenerators. I've encountered a problem recently while planning an upgrade on a cabling machine from DC drive & motor to AC drive & motor. The old (current) setup has a 3500RPM DC motor with a 50V/1000RPM tach on it.
    The machine in question is an "antique" cabling machine. The company that made it is no longer in business and the documentation for it was lost long ago. There is no chance of getting new copies of that documentation.
    As the machine was designed, it uses the 0-175V tach feedback not only for the 25HP DC drive feedback, but also for several one-off proprietary control boards. These control boards perform various functions relating to lay length of the cable (#of twists per ft), and traverse rate (rate of side to side movement per ft of spooled cable). These functions include engaging/disengaging several clutches, clutch power, a motorized variator setpoint, servo direction, servo speed, et. al. (I'm not sure what else, as I haven't figured out what all the boards do). Anyway, this 0-175V signal splits several times and goes to all these boards. The boards all need this reference, as all their functions are related in some way to the main motor speed. I'm sure that on each board, the signal is divided down to some useful level, but without the drawings I would have to painstakingly map out each board and reverse-engineer it to accept a 0-10V signal instead of a 0-175V one. Due to down time constraints, I won't have time to do this. It needs to be done in a day, so I want to have something ready that I can just install an call it done. This upgrade is still a good distance in the future so I have time to come up with something.

    This is a 2-part thing. The first part (turning ±10V into ±200V) is already well on its way. This quadtrature encoder portion of the project isn't a necessity of the project, as there are already frequency to voltage converters made for the task, but they all put out ±10V. That was the purpose of my previous thread. I intend to use one of those (+ my 200V signal conditioner) if I'm not done with the quadrature encoder portion of the design by then. Either way, I'm sure I'll be able to use it in the future, as I've had similar need in the past.




    I'm not sure what resolution I need, but I think the higher the better.

    EDIT: for more info on the retrofit project, see here if interested.
     
    Last edited: Jan 27, 2013
  19. panic mode

    Senior Member

    Oct 10, 2011
    1,318
    304
  20. strantor

    Thread Starter AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    Yes that's a good example of one of the commercially available F/V converters. That one as well as the others I've found don't go above 10V. If I don't finish the quadrature encoder portion of this design, I'll end up interfacing something like that to my ±10V>±200V signal conditioner. But I really would like to make something that's a standalone unit that accepts quadrature encoder input and outputs ±200V, and does not require you to buy something else from someone else.
     
Loading...