Shop OBEX P1 Docs P2 Docs Learn Events
ADC Test — Parallax Forums

ADC Test

garylakegarylake Posts: 41
edited 2011-02-19 17:11 in Propeller 1
I am not having much luck with ADC and The Prop.
I am trying to read voltage from a Piezo transducer so I can tell how hard it was tapped.

I am using jm_adc0834_ez.spin and jm_adc0832_ez_demo.spin code from the Object Exchange.
I wire up the circuit as per the circuit in the code.

I hooked up an oscilloscope to check the output from the ADC. I included a snapshot of the oscilloscope reading. Is this what I should see on the oscilloscope without any input to the ADC? When I tap the Piezo element I do get a blip on that channel.

I also included the schematic.

Gary
800 x 600 - 159K

Comments

  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-02-19 09:13
    Having written and tested those ADC083x objects I can tell you the work fine, but may not be suitable for this app. Why? Because they're bit-banging SPI in Spin which is slow and you may not be able to catch the transient signal from the transducer.

    You may need to feed the transducer into an opamp and charge a cap with that (not sure the direct connection is enough), then read the voltage from the cap. You could use a FET to discharge the cap (needs another io pin) when you're done with the reading.
  • garylakegarylake Posts: 41
    edited 2011-02-19 10:30
    OK,
    I have a Digital circuit and an analog circuit I was working on.
    Will these circuits work as is or will I need to add some protection somewhere?

    These are for a 16 channel electronic drum controller.

    Gary
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-02-19 12:55
    With the MCP3204 you have a better chance it's faster than the ADC0834. What I'd suggest doing is writing a PASM object that will read each channel in turn and write it out to an array in the hub.
  • garylakegarylake Posts: 41
    edited 2011-02-19 13:11
    I do have some MCP3204 chips. I'll give them a try.
    Just to let you know, I do not play the drums or any other instrument. But I do want make a Propeller base drum kit.
    I see this done with the Arduino and MicoChip and wanted to give the Prop a try.
    PASM? Any good books on that?
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-02-19 13:28
    No books (yet) on PASM but it's not hard to learn if you have any programming experience. And if it can be done on an Arduino (bleh!), the Propeller will more than handle it.

    The attached code won't work as is (for you) but will give you something to start with. I use this in a camera pan/tilt controller than I designed/coded for a friend. You could write an object that reads all 16 channels in order.
  • potatoheadpotatohead Posts: 10,261
    edited 2011-02-19 13:43
    I'm currently in the process of making a PASM beginner book. It's taking me a while to get it to the next level, but I do have a primer for the absolute beginner here that is highly likely to get you started..

    http://forums.parallax.com/showthread.php?96594-Machine-Language-Tutorial!&p=668563&viewfull=1#post668563

    DeSilva and I started this project. He did a great job with his general, intermediate to advanced tutorial, and my document introduces that, and other references around the forum. It's really basic, but I've gotten a lot of great "thanks" feedback, indicating that it can get somebody over the initial hump! Maybe it's enough right now to get you started!

    That parent thread contains DeSilva's intermediate to advanced tutorial, and the parent topic thread contains some other references.

    PASM is a beautiful, and in my mind, not difficult assembly language to learn. I strongly encourage you to give it a go. Propeller Assembly Language is a lot of fun, and it's powerful. One thing I really like is you don't need to really get all that deep before you can start making sense of some pretty powerful programs.
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-02-19 14:34
    You can simplify your design by connecting all the CLK pins to one IO on the Propeller, and the DIO pins (you still need the resistor [3.3k] on each MCP3204) to one IO on the Propeller; this gets you down to six IOs to read 16 channels.

    The attached code is off the top of my head (from code that works), so it's not tested. If I had the hardware I'd feel confident in trying it. As PotatoHead points out, PASM is not difficult. Now... in some regards this code is inelegant and heavy handed -- it's not really intended for general re-use, it's intended to be straightforward. That said, you can still change up your IO mapping very easily which you may need to do when you layout your PCB.
  • garylakegarylake Posts: 41
    edited 2011-02-19 17:11
    Jon, thanks a lot. I changed my schematic to your specifications and will wire up the breadboard tomorrow and try you code.
    PotatoHead, thanks for the link to learning PASM.

    As far programming goes I have programmed in Visual Basic, some C and some other languages, but never assembly. But I will learn it.

    Gary
Sign In or Register to comment.