Shop OBEX P1 Docs P2 Docs Learn Events
BS2P inputs — Parallax Forums

BS2P inputs

JsavJsav Posts: 25
edited 2007-04-02 02:05 in BASIC Stamp
·Part of a project I'm working on is to take the input from 4 strain gages, which are analog. Is there a way to directly wire into the BS2P so that we can read analog input? We need to used the exact milivolt input (which is over a 0-11mV range)·to use in calculations in our programming. If there isn't such a way, do we need to buy and incorporate into our design 4 Digital to Analog converters and use the following code as found in the manual to interface to BS2P? Please help me out, it's for a junior design and our time is running out!

' SHIFTIN.bs2
' This program uses the SHIFTIN instruction to interface with the ADC0831
' 8-bit analog-to-digital converter from National Semiconductor.
' {$STAMP BS2}
' {$PBASIC 2.5}
CS PIN 0 ' chip select
AData PIN 1 ' data pin
Clk PIN 2 ' clock pin
adcRes VAR Byte ' ADC result
Setup:
HIGH CS ' deselect ADC
' In the loop below, just three lines of code are required to read the
' ADC0831. The SHIFTIN command does most of the work. The mode argument in
' the SHIFTIN command specifies MSB or LSB-first and whether to sample data
' before or after the clock. In this case, we chose MSB-first, post-clock.
' The ADC0831 precedes its data output with a dummy bit, which we take care
' of by specifying 9 bits of data instead of 8.
Main:
DO
LOW CS ' activate the ADC0831
SHIFTIN AData, Clk, MSBPOST, [noparse][[/noparse]adcRes\9] ' shift in the data
HIGH CS ' deactivate ADC0831
DEBUG ? adcRes ' show conversion result
PAUSE 1000 ' wait one second
LOOP ' repeat
END

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-31 22:34
    Have a look at this thread: http://forums.parallax.com/showthread.php?p=634625.

    You cannot connect the strain gauges directly to the Stamp or to an ordinary ADC. The voltages are too low.
  • ChrisPChrisP Posts: 136
    edited 2007-04-01 05:40
    Jsav, are you reffering to 4 load cells or one load cell consisting of 4 strain gauges? If its 4 gauges configured in a wheatstone bridge configuration, or as a single load cell. Then for experimenting I would highly recommend just a plain old AD620 Instrumentation amplifier from Analog devices. This will amplify your output to a 0-5 volt range to give your AD converter enough signal to work with.

    Used them in several applications, just follow the simple schematic in the data sheet, very few support components, and simple. The only drawback is they need 2-3 minutes in the simple configuration for the output to stabilize. Tip, where it specifies the gain resistor, use a resistor thats a little low in value in series with a potentiometer to get fine adjustment.

    If your working on a product or something that requires near instant stability at turn on, go another route.
  • JsavJsav Posts: 25
    edited 2007-04-01 18:33
    thanks a lot for the suggestions guys! aside from upping the voltages through amplifier circuits, we can take an analog input directly into the BS2P right? we need very quick updating to change the outcome of our equations as quickly as possible, relating to an alarm system. so thanks for the suggestion chrisP, but the 2-3 minute wait is out of question for us, it will be values from four individual strain gages.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-01 18:53
    I would not recommend using the Stamp for an analog to digital converter. It can do it, but it's slow and of limited accuracy. Tracy Allen (here: www.emesystems.com) talks about using the Stamp for checking its own power supply voltage ... a good application. Use an external converter. They're cheap and there are examples in the (freely downloadable) Stamps in Class tutorials on their use (see: www.parallax.com/detail.asp?product_id=28155 as well as: www.parallax.com/html_pages/edu/curriculum/sic_curriculum.asp).
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2007-04-01 20:51
    The ADC0831 does (if I recall correctly) have a differential input, but it is only 8 bits and the reference probably cannot be made low enough to digitize a signal of only 11 millivolts full scale.

    You'll need either a differential amplifier to bring the signal up to a higher level, single ended. Or, go right to a a higher resolution analog to digital converters. Note that in thread Mike brought up, Mohamed Refky suggested from experience the AD7730 for the weigh scale application and there is code available for that.

    There are A/D converters that have multiple inputs, such as the AD7718 has 4 fully differential inputs in one single package, but you would have to deal with the surface mount package, and develop the PBASIC code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • skylightskylight Posts: 1,915
    edited 2007-04-01 23:56
    Couldn't the use of 741 op amps be used as voltage followers driving varistors (voltage dependant resistors) which in turn charges an RC network then the stamp could use the RCtime command to read the resistance and convert into a voltage reading? or would this method not be fast enough for the application?
  • JsavJsav Posts: 25
    edited 2007-04-02 02:05
    turning on of the program and waiting a few minutes would be ok, sorry for the mix-up earlier, but while the program is running it needs to run as quickly as possible, since it will be tied into an alarm output system, and related in the health field, time is always of the essence.

    I think we are going to go with an amplifier circuit, followed by the a/d converter, and I've already written the code to turn the 8 bit binary output of the a/d converter into rounded 0-5V range voltages in our program. we can then use these values in our calculations.

    One thing I'm not sure of however, is the type of a/d converters to use, and if i should build my own amplifier circuits, or if they are easily and cheaply bought in, preferribly, small packages. currently my code involves using the ADC0831.
Sign In or Register to comment.