Shop OBEX P1 Docs P2 Docs Learn Events
Adc with basic stamp reading not stable. — Parallax Forums

Adc with basic stamp reading not stable.

mogu93mogu93 Posts: 22
edited 2013-10-30 09:47 in BASIC Stamp
-
[/COLOR]' {$STAMP BS2} ' {$PBASIC 2.5} 
 
' -----[ Program Description ]--------------------------------------------- 
' 
' This program demonstrates reading a variable voltage with an ADC0831 
' analog-to-digital converter chip. This program uses a Vref input of 
' 5.000 volts (Vdd) for a bit resolution of 19.6 millivolts. 
 
 
' -----[ I/O Definitions ]------------------------------------------------- 
 
CS PIN 0 ' chip select (ADC0831.1) 
Clock PIN 1 ' clock (ADC0831.7)
 DataIn PIN 2 ' data (ADC0831.6) 
 
 
' -----[ Constants ]------------------------------------------------------- 
 
Cnts2Mv CON $139C ' x 19.6 (to millivolts) 
 
 
' -----[ Variables ]------------------------------------------------------- 
 
result VAR Byte ' result of conversion 
mVolts VAR Word ' millivolts 
 
 
' -----[ Initialization ]-------------------------------------------------- 
 
Reset: 
 DEBUG CLS, ' create report screen 
 "ADC.... ", CR, 
 "volts... " 
 
 
' -----[ Program Code ]---------------------------------------------------- 
 
Main: 
 DO 
 GOSUB Read_0831 ' read the ADC 
 mVolts = result */ Cnts2Mv ' convert to millivolts 
 
 DEBUG HOME, ' report 
 CRSRXY, 9, 0, DEC result, CLREOL, 
 CRSRXY, 9, 1, DEC mVolts DIG 3, 
 ".", DEC3 mVolts 
 
 PAUSE 100 
 LOOP 
 
 
' -----[ Subroutines ]----------------------------------------------------- 
 
Read_0831: 
 LOW CS ' enable ADC 
 SHIFTIN DataIn, Clock, MSBPOST, [result\9] ' read ADC 
 HIGH CS ' disable ADC 
 RETURN
[COLOR=#333333]


Hi there i using Adc0931 with basic stamp to find the voltage reading for my circuit
but i found out that my reading is not stable at all ,kept on jumping .Instead the reading i want is stable and when i turn it ,
it will change stably .anybody can help me with that? how to make it stable.While i found out when i test it with a variable resistor to the input of the adc it is very stable.


Comments

  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2013-10-26 00:29
    What is the nature of your circuit that you are measuring the voltage with? Can you provide a schematic? a description of your setup? How much fluctuation are you seeing?
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2013-10-26 05:51
    in re. your schematic
    You're powering the Stamp via "Vin", well and good.
    You show the Stamp "Vdd" pin connected to your 7805's output - not good. Disconnect "Vdd" (it is an output, from the Stamp's on-board regulator).
  • mogu93mogu93 Posts: 22
    edited 2013-10-26 07:49
    i connect the stamp vdd suppy +5v from the output of the regulator as it gives 5 v .i don't get what you mean .
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2013-10-26 08:35
    mogu93 wrote: »
    i connect the stamp vdd suppy +5v from the output of the regulator as it gives 5 v .i don't get what you mean .
    The 7805 outputs 5V on its own. "Vdd" on the Stamp is an output (it is not an input.)
    Why are you connecting the 7805 output to the Stamp's 5V (Vdd) output?
    Tell me what good that accomplishes.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2013-10-26 08:46
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-10-26 10:57
    I'm going to suggest the opposite. Disconnect the 9V from Vin, and allow your 7805 to supply power to the Stamp. The way you have it is probably not hurting anything. @PJ, the Vdd pin can be either an input or an output. The voltage regulator on the BS2 can take a voltage on its output without any problem of leakage backwards; that is commonly done on Parallax boards such as the BOE that want more power supply capacity than is available from the on-board regulator.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-10-26 11:14
    mogu93,

    The resistor values in your sensor circuit are very high, 3.3M and a series on 1M. That makes the circuit susceptible to noise pickup from the AC lines and also radio frequencies. That will be especially true if the sensors are out on long, unshielded wires. You might have better results by connecting a 0.1µF capacitor from the ADC031 pin 2 to ground, close to the chip.

    It would also help if you can reduce the resistor values by a factor of 10 or 100. What is the nature of the sensors?

    When you attach a multimeter to the circuit, it will be averaging the reading, and it will be doing so in a manner that tends to reject 50Hz and 60Hz and radio interference. The ADC0831 does not do that, and the function of the suggested 0.1µF capacitor is to provide low-pass filtering at around 1Hz. It slows down the response of the circuit.

    Another thing about the multimeter. Most multimeters have an input resistance of around 10MΩ, so when you use it to measure the voltage in a high impedance circuit, that 10MΩ becomes part of the circuit and affects the reading. The ADC0831 reading too is affected by the high impedance of the circuit, but in a different way, because the ADC0831 injects a tiny pulse of electric charge into your circuit from pin2 when it takes the reading. The 0.1µF capacitor should help with that. There are other tricks, using pin 3 as a differential input.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2013-10-26 12:09
    @PJ, the Vdd pin can be either an input or an output. The voltage regulator on the BS2 can take a voltage on its output without any problem of leakage backwards...

    I'm aware.
    Pick one or the other (not both):
    If there's Vin supplied to the Stamp then leave its Vdd disconn'd.
    If Vin isn't supplied to the Stamp then 5V from some other source can be connected to its Vdd.

    As this chap went and made a 7805 circuit, I had the "absurd" notion that disconnecting the Stamp's Vdd pin from the mix was the quickest means to an end.
    that is commonly done on Parallax boards such as the BOE that want more power supply capacity than is available from the on-board regulator.

    Thanks, I guess, but here I'm looking right at the BoE Rev C drawing and the Stamp's "Vdd" pin is disconnected from everything else but a 1000uF cap. The board's "Vdd" (so-labelled) is derived from a certain VR1 (7805).
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-10-26 14:26
    PJ,

    I see what you mean about BOE rev C. I was looking at the BOE rev A schematic, which has the '7805 output as Vdd for both the BS2 and the external breadboard circuits. Rev C as you point out has them separated, the BS2 Vin connected to the input 9V supply, while the LM2940 supplies System-Vdd power only to the external circuits. That plus the extra 1000µF on the BS2-Vdd rev C power supply probably gives desirable isolation from spikes that might kick back from the servos or other externals of that sort.
  • mogu93mogu93 Posts: 22
    edited 2013-10-26 18:24
    thanks guys!
    i'm using flexiforce sensor http://www.tekscan.com/flexible-force-sensors the long version of it .
    i using a high resistance 3.3M fixed, as when i connecting using 1M fixed all the sensor can't be work.But when i used value above 2M it can be work ,
    so i decided to use 3.3M ,as the range of voltage jump when pressing all the weight sensor is more .
    i urgently need help in it,as i need to figure it out where went wrong and change it
    as my deadline is coming soon :(
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2013-10-26 18:31
    I understand well your concerns regarding the resistors as mentioned.

    http://www.ti.com/lit/ds/symlink/adc0831-n.pdf
    There's an example with load cells ( == "weight sensors"?) on pg 35.
    This is not a simple matter of slapping some load cells on it and "Bob's your uncle."
    There's a lot of low-noise construction technique involved, too, depending upon how refined a result is expected.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2013-10-26 18:33
    Flexiforce?
    Can't you use RCTIME for that?
  • mogu93mogu93 Posts: 22
    edited 2013-10-26 18:40
    sorry ,i can't .i'm given flexiforce sensor to work on that and connect to the circuit and make it work . haha .
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2013-10-26 19:32
    A "flexiforce" is a variable resistor.
    RCTIME is a Stamp/PBASIC feature made for just such a thing.
    Why is that impossible?

    http://emesystems.com/BS2rct.htm#RCtime
    http://www.dummies.com/how-to/content/electronics-projects-how-to-read-a-value-from-a-po.navId-810973.html
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-10-27 10:22
    I see you have 4 sensors, each one in parallel with a 1M resistor, and all in series with a 3.3M resistor, the one analog signal tapped from the junction between the series string and the 3.3M. I am wondering why you arranged the circuit that way, and also how the sensor are arranged physically? Please take a picture of how the sensors are arranged and how the weight comes to bear.
    Screen shot 2013-10-27 at 10.24.53 AM.png
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-10-27 10:50
    I'll add that in the past I've used flexiforce sensors for weighing of animals (kangaroo rats) visiting platforms with food trays. The idea was to determine if an animal was visiting at all, and to have a rough estimate of the animal's size. These sensors are not very accurate, but they did serve that purpose in a very thin package.

    Let me say this about the circuit I used. The platform consisted of a triangle with flexiforce sensors at the corners, supported on its base by thin pads centered on the sensors. (felt furniture protectors). The sensors were all three connected in parallel. The resistance in parallel is Rp = 1/(1/R1 + 1/R2 + 1/R3). Also,each resistance to first approximation is proportional to 1/Force, so Rp = K/(F1 +F2 +F3). That is the resultant force of the three sensors combined, and in a perfect world that would distribute to carry the animal's weight no matter where the animal stood on the platform, so Rp = K / Weight. Thus the parallel resistance was a direct measure of the quantity desired. It could be measured easily with a voltage divider and an ADC. Fluctuations in the reading were a great indicator that an animal was present, but made it diffiult to get a trustworthy weight reading. K is an empirical proportionality constant, and it depends somewhat on temperature.

    I see that you have 4 sensors connected in series, and based on my own experience, I wondered why.
  • mogu93mogu93 Posts: 22
    edited 2013-10-27 18:08
    thanks! my reading works now is stable after putting a 0.1uF capacitor :) just that now my reading is 2.2V I need it to make it to be 5V so I need to change my value of my resistor, maybe my fixed 3.3M need to parallel with other resistor value .I not sure why my sensor is connected in series instead of parallel as i'm given the circuit :P by my lecturer. Mine is square board with 4 button at the corner with flexi-force sensor .so any one of it sense the load . the value will change accordingly.Thanks once again! :D
  • mogu93mogu93 Posts: 22
    edited 2013-10-27 19:45
    when I use 1K ohm parallel with 3.3 M fixed resistor and series with 4 M . the output is around 5V but my sensor can't work at all when I pressed on the button . need help in it . as I try the fixed resistor need to be above 2M in order to let the sensor to work .so I have no idea in it .:(
  • mogu93mogu93 Posts: 22
    edited 2013-10-28 01:32
    I solved above problem ,now left :How to make a wider range ,full use of it from 0-5V,as I test it without any load is 5Vand with load is min can go to 4.8v only . I wan it to go to 0 with the max load and without load is 5V . how do I do it? with the sensor and circuit?
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2013-10-28 05:49
    mogu93 wrote: »
    I solved above problem ,now left :How to make a wider range ,full use of it from 0-5V,as I test it without any load is 5Vand with load is min can go to 4.8v only . I wan it to go to 0 with the max load and without load is 5V . how do I do it? with the sensor and circuit?

    Change Vref.

    I would still like an answer to my question: Why not use RCTIME?
  • mogu93mogu93 Posts: 22
    edited 2013-10-28 06:30
    What value do i change to for Vref?
    how does RCtime works?
    Do you have the code for it ?
    thanks!
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2013-10-28 08:46
    mogu93 wrote: »
    What value do i change to for Vref?

    As I understand it, you have a maximum variation of 200mV?
    The datasheet's page 23 shows two examples: "Span Adjust", to adjust full-scale
    and "Zero-Shift and Span Adjust", to adjust full-scale and establish a "window"
    http://www.jameco.com/Jameco/Products/ProdDS/116100.pdf
    mogu93 wrote: »
    how does RCtime works?
    Do you have the code for it ?
    thanks!

    PBASIC Help is always a good place to Start.
    If that's not enough information, click the links that I provided, yesterday, in Reply #15.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-10-28 09:08
    The circuit as you have it, with the sensors in series, is like an AND gate. The output signal will go to its lowest level only when all 4 sensors are pressed at the same time. If you want something like logical OR, wherein the output goes low if any one or more sensors are pressed, then the sensors will have to be connected in parallel.

    In post #18 you said, "I not sure why my sensor is connected in series instead of parallel as i'm given the circuit :tongue: by my lecturer. Mine is square board with 4 button at the corner with flexi-force sensor .so any one of it sense the load . the value will change accordingly." This is an assignment for school, and your comment troubles me, about not being sure why the sensor is set up that way, just because the lecturer told you to do it. Ask more questions. Understand the why. Maybe the lecturer is wrong. Maybe you don't understand the assignment. There are many possible things that can be done with this circuit and your job as a student is to explore and understand.
  • mogu93mogu93 Posts: 22
    edited 2013-10-28 18:58
    What I know and understand from it .Once told that it is connected in series is that when one of the sensor is detect . it will equal to the total voltage or sort ,so when more load is detect by the sensor in the circuit .as it is in series so it will sum out the total voltage at the end of the output .(don't know if this theory is correct ).Kind of having a headache solving the range of it .I have try changing to parallel but the drop and range still very little , while I wanted is full (0-5V ) change range in it .:( hehe!
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-10-29 09:03
    hehe:innocent:. That is a headache for sure.

    How about this. Can you borrow the multimeter again? Also one of the flexiforce sensors, by itself? Connect the sensor to the multimeter set on ohms. Record the resistance values that you see on the multimeter screen as you apply pressure on the sensor. What does it read when there is no pressure? What does it read when you press on it hard? What does it read when the pressure is in the range that you want to detect?
  • mogu93mogu93 Posts: 22
    edited 2013-10-29 18:42
    I measured that without any pressure it is around 26Mohm and with full pressure it is around 280K ohm. I not sure what the the pressure range I need .But what I want is when connected into the circuit without any load is around 5V but when will full load is around 0V when all 4 sensor connected in the 4 size of the Square board. I also have another flexiforce sensor but is around 1M ohms without any pressure and around 250 Kohm with full pressure. so I don't know which Value of flexiforce sensor to connect . But I was once told to use 1M ohm sensor ,is it this the problem of low voltage drop.?
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-10-30 09:47
    Are both of the sensor you tested supposed to be the same type? Is one perhaps overused and damaged? Or maybe the second already had a bit of stress applied. They both ended up around 250kΩ.

    Please explain more what you mean by, " ... when will full load is around 0V when all 4 sensor connected in the 4 size of the Square board."

    By "connected", do you mean when a force is applied? Where is that force coming from?

    In a voltage divider circuit, it will not be possible to have it go all the way from 5V to 0V. If each sensor is in parallel with 1MΩ as you have it in your first schematic, then its minimum resistance with force applied will be about 200kΩ, and the maximum will be somewhere between 500kΩ and 1MΩ. The minimum for a chain of 4 in series will be 800kΩ and the maximum between 2MΩ and 4MΩ. You can calculate the voltage range depending on the top resistor that you have, which you showed as 3.3MΩ:
    Vminimum = 5V * 800k/(3.3M + 800k) = 1V
    Vmaximum = 5V * 2M/(3.3M + 2M) = 2V using 2nd sensor
    or 5V * 4M/(3.3M + 4M) = 2.7V using 1st sensor

    Do you understand that reasoning?
Sign In or Register to comment.