Shop OBEX P1 Docs P2 Docs Learn Events
PWM decoding — Parallax Forums

PWM decoding

ADPADP Posts: 15
edited 2004-11-21 19:08 in BASIC Stamp
I an stuck at writing· a portion of my program that decodes data coming out of 8 bit A/D (representing temperature) into string of binary numbers.
Sample programs, examples and any help will highly be appreciated.
I am programming in BS2.
·

Comments

  • mikeCmikeC Posts: 4
    edited 2004-11-09 22:08
    if it's a serial A/D converter, then try the SHIFTIN command. i had good luck with this command on an SPI A/D converter (TLC0832).

    good luck.
  • ADPADP Posts: 15
    edited 2004-11-09 22:19
    Hey Mike

    Thanks for your response. I am somehow new to BS2 and am not sure what you meant. I am even having a hard time implementing the algorithm for the PWM decoding.

    Do you have any samples or examples that I could get an idea from.

    I will really appreciate it.
  • Shawn LoweShawn Lowe Posts: 635
    edited 2004-11-09 22:35
    look at your help file in the editor under the shiftin command.
    Shawn
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-10 14:45
    ADP,

    What component are you using? We may already have an example somewhere (there's a very good chance we do).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • ADPADP Posts: 15
    edited 2004-11-10 15:56
    Hi Jon,
    I actually am working on designing a vital signs monitor where I have 3 signals (converted to digital already) coming into the BS2 (temperature, Blood oxygen saturation level and Heart rate) and I have to send them to the PC (where labview will be responsible to display the data accordingly). Since I can't send the 3 signals at the same time, I need to compile them in some way and send them through 1 channel one after the other.
    I hope this description helps. A sample would help me alot,
    Your help is highly appreciater,
    A.P
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-10 16:14
    I'm still not with you ... can you read the signals? If yes, what is stopping you from transmitting them via SEROUT?

    · SEROUT pin, baud, [noparse][[/noparse]sensor1, sensor2, sensor3]

    We have lots of samples, but unless you can be much more specific, I don't know which one(s) will best help you.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office


    Post Edited (Jon Williams) : 11/10/2004 4:17:04 PM GMT
  • ADPADP Posts: 15
    edited 2004-11-10 21:09
    Thanks for the response Jon.

    I have not connected BS2 to my A/D converters yet. I do have 3 square waves each representing 3 different signals coming out of the A/D.

    I understand that they have to be decoded into string of binary numbers before I can actually send them out via a serial cable.

    I am quite aware on how to declare the input and output pins, declare the registers and send the signal out.

    I am having a hard time with the code that would convert the pulses read from the A/D into binary string.

    I would really appreciate if you can provide me with samples and examples that would help me out.

    Thanks again.

    ADP
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-10 23:38
    What A2D are you using?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • ADPADP Posts: 15
    edited 2004-11-11 02:28
    ADC0831 is what im using
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-11 04:10
    ADC0831 code·is all over the place -- if you don't duck from time-to-time it will smack you right in the mug! I've attached a simple demo from StampWorks.

    And here's an article from Nuts & Volts that uses the ADC0831 with a variable reference voltage: http://www.parallax.com/dl/docs/cols/nv/vol5/col/nv114.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office


    Post Edited (Jon Williams) : 11/11/2004 4:14:22 AM GMT
  • ADPADP Posts: 15
    edited 2004-11-17 02:23
    Hi Jon,
    I connected adc0831 ( i actually need to use adc08832 but i just want to see how 831 works) to bs2. I have a code for adc0831 that is even available on parallax website or pretty much everywhere. I, however do not get any display as i change the voltage input that goes into the adc0831 (which is hooked up to a potentiometer). Do i need to use the serout command to be able to see changed on my pc???
    If that is the problem, i'm sure it will fix all my problems.
    I would really appreciate your help,
    thanks
    ADP
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-17 03:48
    If you run the code from this experiment you should see the ADC0831 results in your Debug Terminal.

    http://www.parallax.com/dl/docs/books/sw/exp/sw27.pdf

    The experiment shows the connections and has a simple program.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • ADPADP Posts: 15
    edited 2004-11-21 17:46
    Hi Jon,
    thanks for that file for adc0831. Well I was wondering if there is a way that bs2 could just accept 1st 8bits from adc0831 and displays the corresponding voltage value on the debug window and then takes 8 more bits from the next adc0831 (assuming we have 2 adcs bringing in signals to bs2) and display its voltage and then go back to the 1st one and take the next 8 bits and so on???? I suppose the adc0831 continuously throughs binary values out but i just need 8 bit chunks to display at a time.
    Thank you Jon. I really appreciate you help and ideas.
    ADP
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-21 19:08
    Yes, that is completely possible -- and very easy to implement in code. What you'll need to have is a second chip select line for the second ADC0831. The data and clock lines can be shared as in the image I've attached a schematic to show how. When you write your program, just make sure that you don't select both chips at the same time, otherwise you'll get garbage back. Note the resistors in the DO lines of each ADC0831 for their protection.

    attachment.php?attachmentid=36600

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
    430 x 237 - 4K
Sign In or Register to comment.