Shop OBEX P1 Docs P2 Docs Learn Events
Generating 0 to +5v on 13 pins of the prop with at least 128 steps — Parallax Forums

Generating 0 to +5v on 13 pins of the prop with at least 128 steps

base2designbase2design Posts: 78
edited 2011-05-17 15:41 in Propeller 1
Hello prop-ers!

I'm trying to interface to a control-voltage (CV) device with the prop that needs 0 to +5 volts output to 13 input pins on the external device with a resolution of (at least) 7 bits or 128 steps.

My first thought is to use PWM on 13 prop pins going to a pair of 74HC244 buffers (to obtain the 3.3v to 5v shift) and then run through resistors/capacitors to filter the output.

Does this sound like an efficient setup? Any way to simplify this?

Thanks in advance for your input!

Comments

  • davidsaundersdavidsaunders Posts: 1,559
    edited 2011-05-16 06:59
    I can not see a better way with the requirement of 13 separate DACs.
  • ctwardellctwardell Posts: 1,716
    edited 2011-05-16 07:07
    What is the highest frequency needed, ie: how fast do these signals need to change?

    C.W.
  • base2designbase2design Posts: 78
    edited 2011-05-16 09:51
    ctwardell wrote: »
    What is the highest frequency needed, ie: how fast do these signals need to change?

    C.W.

    Less than 60Hz...
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2011-05-16 10:02
    So that means that the rate of change would need to be (60 * 128) * 2 = 15360 steps per second, is this correct?
    If so then yes using PWM with filters would suffice.
  • base2designbase2design Posts: 78
    edited 2011-05-16 10:47
    So that means that the rate of change would need to be (60 * 128) * 2 = 15360 steps per second, is this correct?
    If so then yes using PWM with filters would suffice.

    Cool. So can you wizards out there give me some pointers on how to suitably filter the output?

    In the meantime, I'll probably spend some time google-ing this, because my fundamental understanding of electronics is so limited.

    I'll post my results here for the next poor traveller...
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-05-16 11:13
    Use 74HCT244s. 3.3V is less than the guaranteed "high" input for HC devices running at +5V.

    -Phil
  • lonesocklonesock Posts: 917
    edited 2011-05-16 11:20
    Just a crazy idea, but what about a resistive ladder, pulling down from +5V (or slightly more, if available)? Leave outa at 0, just modify dira so the pins either float or are pulled low. You'd want to make sure the resistors are large enough to not make the prop sink/source too much current per pin.

    Jonathan
  • base2designbase2design Posts: 78
    edited 2011-05-16 11:39
    Use 74HCT244s. 3.3V is less than the guaranteed "high" input for HC devices running at +5V.

    -Phil

    Thanks for the tip PhiPi!
  • base2designbase2design Posts: 78
    edited 2011-05-16 11:45
    lonesock wrote: »
    Just a crazy idea, but what about a resistive ladder, pulling down from +5V (or slightly more, if available)? Leave outa at 0, just modify dira so the pins either float or are pulled low. You'd want to make sure the resistors are large enough to not make the prop sink/source too much current per pin.

    Jonathan

    Interesting... would this work with PWM on one pin? A resistive ladder to me implies one resistor per output bit, so if I understand you, this would require 7 output pins per CV input (I need 13 independent CV outputs), so I don't have enough prop pins to do that.

    Correct me if I misunderstood what you suggested.

    BR!
  • lonesocklonesock Posts: 917
    edited 2011-05-16 12:47
    Sorry, I meant something like:
        +5
         |
         R1
         |
    (Pin)+-R2--+--output
               |
               C
               |
              Gnd
    
    PWM will have to be done semi-manually as the counter can't control the dira register. Also, the charge & discharge times will be asymmetrical, so 50% duty cycle won't get you 2.5 V, but that should be easy to accommodate. You could get even crazier by using 3 output states: float (5V via R1+R2), drive high (3.3V via R2), or drive low (0V via R2), but that seems like a lot of work to me! [8^)

    Jonathan
  • lonesocklonesock Posts: 917
    edited 2011-05-16 13:15
    Here's an Excel spreadsheet showing the steady state (non-linear) response of the above circuit. Note that the larger R1 is relative to R2, the less linear the output. I used initial (guessed) values of R1=1k, R2 = 8k. C is unspecified.

    Jonathan
  • AribaAriba Posts: 2,690
    edited 2011-05-17 00:58
    lonesock

    The problem is the protection diode at the Propeller pin. So your R1 can pull up the pin only to ~3.3V + 0.7V = 4 V and not 5V. Also the total PWM resistance has a non linear component because of this diode.

    Andy
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2011-05-17 02:03
    The rate of 2 x wanted frequency is the absolute minimum. I would get it running and then see how much faster the rate could be made. The higher the sampling the easier the filtering.
  • jmgjmg Posts: 15,185
    edited 2011-05-17 03:21
    Cool. So can you wizards out there give me some pointers on how to suitably filter the output?

    You want to target the ripple to be less than 1 LSB, so the RC filter timeconstant needs to be longer than 64 * 50% Period.

    To simplify the RC filtering, you can shift from PWM, to the slightly more complex Rate Multiplier.

    Look at the CD4089BE http://focus.ti.com/lit/ds/symlink/cd4089b.pdf

    for an example of how a binary rate multiplier works.
  • lonesocklonesock Posts: 917
    edited 2011-05-17 15:04
    Ariba wrote: »
    The problem is the protection diode at the Propeller pin. So your R1 can pull up the pin only to ~3.3V + 0.7V = 4 V and not 5V. Also the total PWM resistance has a non linear component because of this diode.
    Good point. From the datasheet, each pin can handle +/- 500 uA as the "Max. DC current into an input pin with internal protection diode forward biased". So it should be safe at 5V as long as the Resistor values are > 2k ohms or so, right (say 3.3k)? The point about even more non-linearity is a good one as well.

    Jonathan
  • AribaAriba Posts: 2,690
    edited 2011-05-17 15:33
    lonesock wrote: »
    Good point. ... So it should be safe at 5V as long as the Resistor values are > 2k ohms or so, right (say 3.3k)?
    Yes it will be safe, because the diode clips the voltage to ~4 V at the pin (that's the purpose of this diodes) and therefore you never get a 5 V level at the output of the PWM filter. R2 can not charge the capacitor to a higher voltage than you have at the pin.

    Andy
  • lonesocklonesock Posts: 917
    edited 2011-05-17 15:41
    Ah, I see what you are saying. Thanks for bearing with me. [8^)

    Jonathan
Sign In or Register to comment.