BS2P inputs
Jsav
Posts: 25
·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
' 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
You cannot connect the strain gauges directly to the Stamp or to an ordinary ADC. The voltages are too low.
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.
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
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.