OWL2c/e/pe and BASIC Stamp interface guide

(c) 1998 , 2001 EME Systems, Berkeley CA U.S.A.
 <stamp index> <home>

Contents (updated 6/03/2004)


ATMOS Barometer

top

Note: Atmos sells primarily to OEM customers with minimum purchase requirements.

ATMOS barometers are OEM modules that have a stamp-compatible digital serial (SHIFTIN) interface, and cover 500mb--1100mb resolved to 0.1mb The static accuracy at 1013mb, 20°C is <±0.4mb. The total error band is ±1.2mb from -20 to +50°C. The design of the module uses sophisticated microprocessor compensation for the effects of temperature and other factors on the silicon strain gage sensor. ATMOS makes other pressure modules that use this same protocol, as well as a tilt sensor module, and a weather station module that includes temperature-humidity- and barometric pressure.

 Rodger Reinhart, President, ATMOS, PO Box 807 Pescadero,CA 94060-0807
 Phone 650-879-1674 Fax 650-879-1675
 http://www.ATMOS.com
mailto:reinhart@ATMOS.com.

The serial interface with the stamp2 is straightforward; however, a couple of peculiarities need to be taken into consideration. The reading of barometric pressure requested from the module can be either a current value of barometric pressure or an internally maintained average, filtered, value. After powering up the module with 5 volts, it takes about 30 seconds for the averaged value to stabilize. This is important if a logging system sleeps with power off between readings. Once the average value stabilizes, it can be read from a buffer in the module quickly, with no delays for a conversion to complete. . On the other hand, the current value of pressure can be read soon after the power to the module is turned on, but the request for a current value must be followed by a delay of up to 300 milliseconds to wait for the current conversion to complete. The stamp must test the modules "ready" flag and it must read out the data within 5 milliseconds after the module signals that data is ready; otherwise the module may reenter its sampling mode for computation of the average. The conversion cycle is asynchronous with the request for data, so a simple PAUSE to await the data will not work and will give bogus results. These subtleties are not at all apparent in the specifications from ATMOS.

Here is an example BASIC STAMP 2 routine to read the current value of barometric pressure:

 ' this is an example program to acquire and display data
' from the ATMOS AT2510-BARO digital barometer module.
result var word ' result of conversion
cntr var byte ' watchdog counter
sdi con 2 ' BS2 serial data in pin
sdin var in2 ' alias for state of serial data pin
sdo con 3 ' BS2 serial data out pin
clk con 4 ' serial clock pin
baro con 15 ' barometer chip select pin
'..
loop:
gosub baroread
debug CR,DEC result/10,".",DEC1 result," millibar"
goto loop
baroread:
input sdi
low sdo ' for command $0000
gosub waitbaro ' send command
gosub waitbaro ' get result
return
waitbaro:
low baro ' chip select
cntr=0 ' init the watchdog timer
waitbaro1: ' wait for ready
cntr=cntr-1 ' watchdog
' loop until ready, or until timeout
if sdin-1*cntr then waitbaro1
shiftin sdi,clk,msbpre,[result\16]
result.bit16=0 ' have to zero the end-of-conversion bit
high baro ' deselect chip
return

The waitbaro routine both clocks a command into the barometer and clocks out the result of the previous command. Here, the command clocked in is always $0000, simply by holding the SDO line low, to read the current value. The first call to waitbaro clocks in the command. The second call to waitbaro clocks out the resulting data. It is not possible to substitute blind delays for the wait loops The data must be shifted out within milliseconds after the sdin "ready" line goes high. This has to do with the AT2510 averaging mechanism. The AT2510 allows only a few milliseconds delay after "ready" before it goes back into its free-running mode.

There are two ways for the program to escape from the waitbaro1 loop. Either pin sdin goes high to indicate end-of-conversion, or the cntr counter goes to zero. This counter provides an exit in case the barometer is unplugged or not functioning. The conversion cycle within the AT2510 runs asynchronously, so it can take from 0 up to about 300 milliseconds for the data to be ready.

The above routine reads the current value of the barometric pressure. This value will fluctuate +/- 1 millibar, due to real pressure variations and due to electronic noise. In the following example the BS2 averages 10 samples, which takes about 2.2 seconds. By this means fluctuations in the reading are held to near 0.2 millibar.

   result var word  ' result of conversion
cntr var byte ' watchdog counter
sdi con 2 ' BS2 serial data in pin
sdin var in2 ' alias for state of serial data pin
sdo con 3 ' BS2 serial data out pin
clk con 4 ' serial clock pin
baro con 15 ' barometer chip select pin
accum var word ' for accumulation of average
ix var nib 'counter for loop
'..

loop:
gosub baroread
debug CR,DEC result/10,".",DEC1 result," millibar"
goto loop
'..
baroread:
accum=0 ' initialize accumulator
input sdi
low sdo ' for command $0000
gosub waitbaro ' send command
for ix=1 to 10 ' 10 samples
gosub waitbaro ' get results & compute average
accum=result&$7fff-5000+accum
' $7fff to clear the end-of-conversion flag
' -5000 to keep the accumulation <2^16
next
result=accum/10+5000 ' compute the average & restore offset
' result is pressure in mbx10
return
 
waitbaro:
low baro ' chip select
cntr=0 ' init the watchdog timer
waitbaro1: ' wait for ready
cntr=cntr-1 ' watchdog
' loop until ready, or until timeout
if sdin-1*cntr then waitbaro1
shiftin sdi,clk,msbpre,[result\16]
high baro ' deselect chip
return
 

The initial call to waitboro makes sure that the first sample fetched from the barometer after power up is valid data. The ten sequential samples take about 2 seconds to acquire.

The ATMOS barometer also has a command to read internally maintained averaged value. (Also one to read back the device serial number). The following routine issues the $0100 command necessary to retrieve the average.

  result var word ' result of conversion
cntr var byte ' counter for wait
sdi con 2 ' BS2 serial data in pin
sdin var in2 ' alias for state of serial data pin
sdo con 3 ' BS2 serial data out pin
clk con 4 ' serial clock pin
baro con 15 ' barometer chip select pin
'..
loop:
gosub baroread
debug CR,DEC result/10,".",DEC1 result," millibar"
goto loop
baroread:
input sdi
gosub waitbaro
serout sdo,clk,msbfirst,[$0100\16]
' $0100 for average
' $0600 for serial number
high baro
gosub waitbaro
shiftin sdi,clk,msbpre,[result\16]
high baro ' chip deselect
result.bit15=0 ' msb needs to be zeroed,
' result is pressure in mbx10
return
waitbaro:
low baro ' select the barometer
cntr=0 ' reset the watchdog counter
waitbaro1: ' wait for bit to go high
cntr=cntr-1
if sdin-1*cntr then waitbaro1
return

There are a couple of things to keep in mind about the average. So long as the power is applied, the barometer takes samples of air pressure about 4-5 times per second. It adds each new sample onto 15 times the existing accumulation, and divides the total by 16. This is effectively a low pass filter with a time constant of about 10 seconds that cuts down the fluctuations in the reading. When the program fetches this average value, the response comes within 2 milliseconds since there is no wait for the module to complete the current conversion. On the other hand, when power is first applied to the barometer, it takes over 20-30 seconds for the filter to acquire a stable reading. One would wish that the module would initialize on the current value instead of at zero, but that is not the way it works. So this command is not useful in a scenario where the system only wakes briefly to take readings, and sleeps most of the time to conserve power. The barometer draws about 5 milliamps.

When reading the average or the serial number, it is important for the program to first issue the command ($0100 or $0600), and then pulse the chip select line high for no longer than 5 milliseconds, but for no less than 50 microseconds. Then it should wait for the end-of-conversion bit, and then immediately read in the data using SHIFTIN. If the timing is off, the barometer will revert to its scanning mode and will report the current value instead of the average or serial number. The above program pulses the line high for about 300 microseconds.


4-20 ma current loop signaling

top

The following are reasons to use current loop signalling:

Here's a diagram to show standard connections:

                                                              Analog/Digital converter
long paired cable ---
sensor |------------------------------o--------> + 12-24 volt power supply
& 4-20 mA |
xmtr |
|
|
& 'enough' |------------------------------o--------> + input
compliance |
/
\ 3 volt
150 ohms / full scale
0.1% \ @ 20 mA
|
o--------> - input
|
o--------> power supply common
 

When applying 4--20 ma transmitters, be sure to observe "voltage compliance". The voltage across the transmitter circuit will vary along with the output current. That voltage has to stay above some minimum at all current levels, or the transmitter will not work right. Say you have a 12 volt power supply for the loop, and say the loop terminated with 150 ohms. At 4 mA, the voltage across the transmitter will be (12 - 150*.004) = 11.4 volts, but at 20 mA, the voltage across the transmitter will be down to (12 - 150*0.020) = 9volts. Most loop transmitters will operate at those levels, but some are designed for a 24 volt dc industrial supply and need 12 or 15 volts minimum acrsoss the transmitter. One certainly can not operate a loop transmitter off a 5 volt supply and expect to get 5 volts out of it! The choice of termination resistor and loop power supply voltage go hand in hand.

There are other kinds of current transmitters. First, although 4-20 mA is standard, there are also 10-50mA, 2-10mA and 1-5mA implementations, used very rarely. 4-20 is industry standard. Also, sometimes the elecronics are not powered by the loop itself. The sensor/transmitter may have its own power supply, and it may draw considerably more than 4mA from that supply. But the 4-20 mA signalling still has advantages to avoid problems with differences in ground potentials between instruments separated by a large distance. Finally, there are transmitters that use zero mA instead of 4 mA as the offset, say 0.00 to 20.00 mA. This scheme has to have a separate power supply available, but it still has the advantage of transmitting the data as a current over a long distance. Having zero as the offset also takes more advantage of the available dynamic range of the electronics. Our IMUX input multiplexer module uses 0-12.8 mA signal, with three wires 1) common; 2) 0-12.8mA signal; 3) power supply for all the devices attached to the IMUX.


 .<top> <index> <home> logo < mailto:info@emesystems.com >