Shop OBEX P1 Docs P2 Docs Learn Events
Outputting analog signal with Basic Stamp 2 — Parallax Forums

Outputting analog signal with Basic Stamp 2

bannor32bannor32 Posts: 20
edited 2005-04-22 21:57 in BASIC Stamp
Hi there. I am working on a project where I am taking accelerometer measurements and outputting it to a 3.5 digit·LED display. I already have a nice·LED voltage meter that I want to use to output the voltage numerically, but it only outputs a signal in real time without the ability to pause the output. (I want·to be able to read the display for·about·5·seconds without the number fluctuating.) Is it possible to have the signal from the accelerometer to be fed into the Stamp, detecting the highest measurement (speed) over a two second period,·and have·that information fed out as an analog·signal into the 3.5 digit·LED voltage meter? I'd want the Stamp to·store the max voltage that was supplied in that 2 second sampling period, and then steadily output that max voltage as an analog signal, which would then·display on the voltage meter's·LED for about 5 seconds.·

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-04-20 19:12
    Hello,

    ·· You could do this using a DAC (Digital to Analog converter).· It really just depends on what voltage range your LED Panel Meter is expecting.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • bannor32bannor32 Posts: 20
    edited 2005-04-20 22:18
    Do I initially have to use an A/D converter to interpret the info coming from the acclerometer to the basic stamp? Then a DAC to convert back to digital when I am sending the data to the Voltage Meter?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-04-21 01:40
    Hello,

    ·· A quick look at the docs <hint> tells you that the Memsic returns a PULSE value, which the Stamp can read using PULSIN.· So, no, you don't need an A/D converter, but you should read the docs for the parts you want to use so you know what you'll need to do.· tongue.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • bannor32bannor32 Posts: 20
    edited 2005-04-21 22:05
    Thanks. I've ordered the ADXL210JE accelerometer which outputs a Pulse value. In the meantime in order to test I've connected an A/D converter to the stamp. I am inputting voltage from a 2-20V variable power supply, through the A/D converter to pin 15 of the stamp. I wrote a basic prog to output the pulse value in the Debug Console. Here is the code:

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    PulseInput CON 15
    Pulse VAR Word

    Main:
    PULSIN PulseInput, 1, Pulse
    DEBUG "Value: ", DEC Pulse, " ", CR
    GOTO main

    When I run the program, the Debug Console shows Value: 0 steadily. Turning the dial up and down on the variable power supply has no effect. Is my code correct for measuring a pulse value on pin 15?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-04-22 00:57
    Hello,

    ·· What A/D converter are you using that outputs a PULSE value to indicate the voltage input?· In all honesty, I have never heard of one that does that.· Do you have a part #?



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • bannor32bannor32 Posts: 20
    edited 2005-04-22 01:49
    It is a circuit I found online using a 555 timer. Here is a link to the circuit diagram (inserted a 1uF cap in place of 4.7uF cap for use with the BS2 as per author's instructions):

    http://www.bobblick.com/techref/projects/a2d555/a2d555.html
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-04-22 02:02
    Hello,

    ·· Sounds like kind of a VCO, so to speak.· Obviously something's not working though.· Without seeing the circuit, I couldn't guess what though.· If you don't mind me saying, it sounds like you're trying to overly complicate things for yourself.· You can actually do what you want to do in a more straight forward manner.

    ·· An accelerometer that returns a PULSE width can be directly read by the Stamp Module without any extra hardware.· As for LED output, the MAX7219 can display the output on up to 8 7-Segment Displays (you can use 4 each for the X & Y axis, respectively).· Or, you could use an LCD Display, as these are cheap (We sel one for $29.99 which is serial).

    ·· So much has changed since your original specifications already anyway, and you still aren't able to output to the Digital Penl Meter yet, are you?· That would require a D/A Converter.· We actually have code that displays the output of the Memsic Dual-Axis Accelerometer to a Serial LCD Display.· Just some thoughts.· wink.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com


    Post Edited (Chris Savage (Parallax)) : 4/22/2005 2:58:08 AM GMT
  • bannor32bannor32 Posts: 20
    edited 2005-04-22 02:33
    Yes. It is definitely more complicated than it needs to be. I actually intend to hook the accelerometer up directly to the stamp. I'm just trying to hook up a temporary solution so I can verify my code is working and ready to go when the accelerometer arrives. The DAC is already in place and working, so outputting to the LED panel that I have shouldn't be a problem (once I learn more about the PWM command). Right now I have simply been testing the DAC with a single LED, and a little program from the tutorials that slowly brightens then dims the LED. Now I need to figure out how to take the varying input from the accelerometer, and output it through the DAC. All this experimenting is at least helping me learn a little along the way. I knew nothing about electronics (as I'm sure you probably guessed) before I got the Stamp the other day. Still wrapping my head around it, but it is quite interesting.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-04-22 02:57
    ·· I didn't realize you already had the DAC connected.· You shouldn't need to use PWM if you have the DAC.· The two can do the same thing to a degree.· As for the Accelerometer, I suppose you could substitute the 555 circuit if you can get it working.· A scope would certainly help there.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • bannor32bannor32 Posts: 20
    edited 2005-04-22 17:54
    Still trying to test the circuit to make sure my code is correct for reading pulsin on pin 15. Have hooked up a transducer with a digital transmitter directly to pin 15(thus completely bypassing the a/d circuit and eliminating it as a possible problem). Per the specs of the digital transmitter with no load on the transducer the digital transmitter should emit 15000 pulses. That number goes higher as weight is applied to the transducer, and the pulse width narrows. Checked with an o'scope to make sure it is emitting pulses, but still getting nada in the debug terminal. Here is the code:

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    PulseInput CON 15
    Pulse VAR Word

    Main:
    PULSIN PulseInput, 1, Pulse
    DEBUG "Value: ", DEC Pulse, " ", CR
    GOTO main

    Should this be outputting the number 15000 to the debug console without any weight applied to the transducer? Value keeps coming up at 0. Is this code correct? is 15000 pulses too fast?

    Post Edited (bannor32) : 4/22/2005 6:10:30 PM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-04-22 19:17
    Hello,

    · Can you try another PIN for input with your new circuit?· I can't help but wonder if the PIN may be blown since you're apparently unable to read anything.· You could also try connecting that pin HIGH and LOW and reading the value to see if it's changing states that way.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • bannor32bannor32 Posts: 20
    edited 2005-04-22 21:15
    Good call! Not sure what happened, but pin 15 does indeed seem to be dead. Hooked up to pin 14, and now getting a reasonably steady value in the debug console (39-41, though it dips down to 1 every now and again). It's nice to actually see a result coming up. On an unrelated note are common anode 7-segment LEDs compatible with the stamp, or will only common cathode LEDs work?

    Thanks,
    Dennis
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-04-22 21:57
    bannor32 said...(trimmed)
    On an unrelated note are common anode 7-segment LEDs compatible with the stamp, or will only common cathode LEDs work?
    Hello,

    ·· CA or CC 7-segment displays really depend on how they're connected.· Either could be used with the Stamp Module, but certain driver chips require one of the other.· For example, the MAX7219 uses CC displays.· For Common Anode you would connect the Anode to Vdd, and the 8 cathodes to port pins through resistors (The value would depend on the forward segment current).· When a pin was LOW a segment would light up, and when it was HIGH it would go out.· The default state of the pins is INPUT so they would be off until the pins were initialized anyway.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.