PDA

View Full Version : Unsolved Spin / assembly function for measuring voltage of a pin



lklo
04-06-2012, 05:35 PM
Hi everyone,
we are looking for a spin / assembly function (for the propeller chip on the propeller demo board) that will give us a reading of what the voltage is at that pin. After reading the voltage we want to set that as a threshold for a bunch of sensors that we are using. We are aware the the current Hi/Lo threshold is vdd/2 = ~1.6V but none of our sensors are able to output at that range without issues.

I found a blogger that is using an Arduino board with the same alcohol sensor (http://sensorworkshop.blogspot.com/) and looking at the C code I believe the function analogRead() is what we think we are looking for, if there is a spin / assembly equivalent.
Any help would be very much appreciated!

Phil Pilgrim (PhiPi)
04-06-2012, 07:07 PM
Take a look at AN008, regarding sigma-delta A-to-D conversion:


http://www.parallaxsemiconductor.com/an008

If you're using the Demo Board, you may need to solder some SMD parts directly to the Propeller pins, as this method does not work very well when implemented on the solderless breadboard.

-Phil

StefanL38
04-06-2012, 07:30 PM
Hi Iklo,

to explain a bit more about the propeller-chip.
The propeller-chip has no analog-inputs. Just digital. One way to read analog voltages is described in the application note 8 that PhiPi mentioned.

Another way is to use an external ADC-chip lik ethe MCP3208. In the Obex there is an object for reading the MCP3208 ADC.

best regards
Stefan

Phil Pilgrim (PhiPi)
04-06-2012, 07:47 PM
Upon rereading your post, I realize that you don't really need analog input to the Prop. What I would do is simply to measure the voltage with a voltmeter. Then you can bias the Propeller inputs with resistive dividers so that the desired threshold produces a 1.67V level (or whatever the digital threshold is determined to be) at the inputs, IOW if the threshold were 1V, you would use a series resistor to the pin, with a pull-up from the pin to Vdd. If the threshold were 2V, use a pull-down resistor instead. You will have to calculate the resistor values to provide the desired division ratio. Placement will not be nearly as critical as it is with the sigma-delta ADC, and you could simply use the solderless breadboard for your dividers.

-Phil