Shop OBEX P1 Docs P2 Docs Learn Events
A to D — Parallax Forums

A to D

Jen HJen H Posts: 3
edited 2006-07-25 16:43 in BASIC Stamp
Is there a way that I can program the bs2 to output a certain analog signal.· For example, if i want to get 3.2 volts, how would I go about doing it besides using PWM?· I have tried using PWM for my motor control but I keep getting random pulses.

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-07-25 02:15
    · Well, other than by smoothing out (averaging) the PWM with an R-C -- No, there isn't an analog output as such.
    · You could do a rudimentary D-to-A with a summing amplifier (op-amp), but that would cost you I/O pins (16-bit resolution = 4 pins.)
    · If all you want is a particular voltage there are ways to approach that, too (if it is < VDD, then a voltage divider on the STAMP output pin would be easiest.)
    · Either way, the result would be a reference voltage, not one that you could drive with, necessitating use of an amplifier.
    · At any rate, you cannot achieve this objective through programming alone.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-07-25 03:03
    Jen -

    As they make A/D (analog to digital) chips, they also make D/A (digital to analog) chips. This is especially helpful if your requirements change over time, since the output is variable.

    Regards,

    Bruce Bates

    Post Edited (Bruce Bates) : 7/25/2006 3:18:17 AM GMT
  • Jen HJen H Posts: 3
    edited 2006-07-25 16:25
    I guess I can see if I have enough pins for the summing amp. Or maybe someone will have another suggestion. I have an encoder that is sending pulses to the stamp. From there, I am using COUNT to determine how fast the motor is running. Based on the pulses, I want to adjust the motor to slow down or speed up. Then it will feedback and adjust the speed again until it reaches the ideal speed. I am currently using a md03 motor control. It takes 0-5V. I mentioned before that PWM is not the most consistent way to drive the motor for this particular design. Does anyone have any suggestions?
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2006-07-25 16:43
    As Bruce mentioned, the option of a DAC may be better for you.
    The following messages have code for a couple of different 12 bit (4096 step) DACs...
    MAX5722:
    http://forums.parallax.com/showthread.php?p=553090
    TLV5618A:
    http://forums.parallax.com/showthread.php?p=555268

    I think you may be misapplying the PWM. What do you mean by "I have tried using PWM for my motor control but I keep getting random pulses."? You may need both an RC filter and an op amp x1 buffer between the Stamp PWM and the MD03. The buffer is described in the Stamp manual.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
Sign In or Register to comment.