Shop OBEX P1 Docs P2 Docs Learn Events
Help with Propeller programming. — Parallax Forums

Help with Propeller programming.

Mark_TMark_T Posts: 1,981
edited 2012-03-25 13:58 in Propeller 1
A link to the object in question would be good, searching "ADC" in the Obex is not illuminating!

[and this is a topic for the Propeller forum really]

Comments

  • chelletengchelleteng Posts: 29
    edited 2012-03-23 07:08
    In Beau Schwabe's ADC driver v1.0 from the Propeller Tool,

    How come there is no getSample method to obtain a reading?
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-23 08:09
    I looks like you give it the address of a variable when you launch it. The object just keeps updating the variable with the latest reading.

    You'd just check the value of the variable whenever you wanted to use a new reading.

    I couldn't find a demo for it but I could write a quick one if you don't understand how to pass an address of a variable.
  • turbosupraturbosupra Posts: 1,088
    edited 2012-03-23 08:55
    I would strongly recommend using Jon's adc driver for the mcp3208 ... life is easy with this

    http://obex.parallax.com/objects/625/
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-23 09:37
    How the heck did Mark's post become #1? This is odd.

    @Brad, The ADC object chelleteng is referring to doesn't use an external ADC chip.
  • turbosupraturbosupra Posts: 1,088
    edited 2012-03-23 09:55
    There must have been a shift in the time-space continuum?

    My bad chelleteng, if trying to make this work ends up consuming too much of your time, the chips are $3 and the object I referenced is easy to use

    Duane Degn wrote: »
    How the heck did Mark's post become #1? This is odd.

    @Brad, The ADC object chelleteng is referring to doesn't use an external ADC chip.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-23 10:10
    turbosupra wrote: »
    if trying to make this work ends up consuming too much of your time, the chips are $3 and the object I referenced is easy to use

    I always use an external chip myself. It was the first ADC method I learned with the Prop so I just stuck with what worked.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2012-03-23 10:28
    chelleteng posted the question in the general discussion forum, and I took my perogative as moderator to move the thread over here. Originally Mark's post was second, but the forum software in its great wisdom decided to mix it up over here. I don't know how to change that. The software help says that it uses the time stamp on the post to determine the order, and anyone can see that Mark was truly prescient!

    By the way, Beau posted a specific answer in chelleteng's general discussion question on sigma-delta.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-23 10:37
    chelleteng posted the question in the general discussion forum, and I took my perogative as moderator to move the thread over here. Originally Mark's post was second, but the forum software in its great wisdom decided to mix it up over here. I don't know how to change that. The software help says that it uses the time stamp on the post to determine the order, and anyone can see that Mark was truly prescient!

    By the way, Beau posted a specific answer in chelleteng's general discussion question on sigma-delta.

    So I wonder if Mark can change the thread to "Solved"?
  • chelletengchelleteng Posts: 29
    edited 2012-03-24 09:03
    Thank you! And I would really appreciate it Duane if you could write a quick one so I'd have a picture of how it works. Thanks
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-25 13:58
    I think the ADC.spin isn't ready to be in the Propeller Tool's library.

    The PASM section starts with:
    asm_entry     mov       dira,#1<<SDF                    'make SDF pin an output
    

    The compiler will give an error if the SDF pin is higher than P8.

    I also can't figure out why one would use the mov statement to make a pin an output. I'd think this would mess up any other pins that the program might be using.

    I changed the above the above code to:
    asm_entry     or        dira, feedbackMask               'make SDF pin an output
    

    feedbackMask is defined as:
    feedbackMask  long      1<<SDF
    

    This is the code I use to start the object:
    CON
      _Clkmode = xtal1 + pll16x                                             
      _Xinfreq = 5_000_000
      _PstBaud = 57600
      
    VAR
      long  adcReading
       
    OBJ
      Adc : "dwd_ADC"
      Pst : "Parallax Serial Terminal"
      
    PUB Setup
      Adc.SigmaDelta(@adcReading)
      Pst.Start(_PstBaud)
      waitcnt(clkfreq / 100 + cnt)
      
      MainLoop
      
    PUB MainLoop
      repeat
        Pst.char(13)
        Pst.dec(adcReading)
            
    

    You can see I passed the address of "adcReading" to the ADC object.

    The code the just outputs to the terminal the value stored in "adcReading".

    I used the Demo Boards mic pins for the input and feedback pins. The value displayed didn't change much. It stayed around 65000 IIRC.
Sign In or Register to comment.