PDA

View Full Version : Unsolved Help with Propeller programming.



Mark_T
03-23-2012, 11:48 AM
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]

chelleteng
03-23-2012, 03:08 PM
In Beau Schwabe's ADC driver v1.0 from the Propeller Tool,

How come there is no getSample method to obtain a reading?

Duane Degn
03-23-2012, 04:09 PM
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.

turbosupra
03-23-2012, 04:55 PM
I would strongly recommend using Jon's adc driver for the mcp3208 ... life is easy with this

http://obex.parallax.com/objects/625/

Duane Degn
03-23-2012, 05:37 PM
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.

turbosupra
03-23-2012, 05:55 PM
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



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 Degn
03-23-2012, 06:10 PM
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 Allen
03-23-2012, 06:28 PM
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 Degn
03-23-2012, 06:37 PM
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"?

chelleteng
03-24-2012, 05:03 PM
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 Degn
03-25-2012, 09:58 PM
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.