Shop OBEX P1 Docs P2 Docs Learn Events
Spin / assembly function for measuring voltage of a pin — Parallax Forums

Spin / assembly function for measuring voltage of a pin

lklolklo Posts: 4
edited 2012-04-06 12:47 in Propeller 1
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!

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-04-06 12:07
    Take a look at AN008, regarding sigma-delta A-to-D conversion:

    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
  • StefanL38StefanL38 Posts: 2,292
    edited 2012-04-06 12:30
    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)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-04-06 12:47
    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
Sign In or Register to comment.