5: BASIC Stamp Command Reference – OWOUT
BASIC Stamp Programming Manual 2.0c
•
www.parallaxinc.com
•
Page 211
Demo Program (I2C.bsp)
' This program demonstrates interfacing to a Dallas Semiconductor DS1820 1-wire Digital
' Thermometer chip using the BS2p's 1-wire commands. Connect the BS2p to the DS1820
' as shown in the diagram in the OWIN or OWOUT command description.
' This code reads the Counts Remaing and Counts per Degree C registers in the DS1820
' chip in order to provide a more accurate temperature reading (down to 1/100th of a
' degree). It also calculates degrees Fahrenheit. NOTE: The algebraic equations used
' will not work properly with negative temperatures.
'{$STAMP BS2p} 'STAMP directive (specifies a BS2p)
Temp VAR WORD 'Holds the temperature value
CRem VAR BYTE 'Holds the counts remaining value
CPerC VAR BYTE 'Holds the Counts per degree C value
Start:
OWOUT 0, 1, [$CC, $44] 'Send Calculate Temperature command
CheckForDone: 'Wait until conversion is done
PAUSE 25
OWIN 0, 4, [Temp] 'Here we just keep reading low pulses until
IF Temp = 0 THEN CheckForDone 'the DS1820 is done, then it returns high.
OWOUT 0, 1, [$CC, $BE] 'Send Read ScratchPad command
OWIN 0, 2, [Temp.LOWBYTE,Temp.HIGHBYTE,CRem,CRem,CRem,CRem,CRem,CPerC]
'Calculate temperature in degrees C
Temp = Temp>>1*100-25+((CPerC*100-(CRem*100))/CPerC)
DEBUG HOME, DEC3 Temp/100, ".", DEC2 Temp-(Temp/100*100), " C", CR
'Calculate temperature in degrees F
Temp = Temp*/461+3200
DEBUG DEC3 Temp/100, ".", DEC2 Temp-(Temp/100*100), " F"
GOTO Start
p
2
Содержание BASIC Stamp 2e
Страница 1: ...BASIC Stamp Programming Manual Version 2 0c...
Страница 30: ...Introduction to the BASIC Stamps Page 28 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 90: ...BUTTON BASIC Stamp Command Reference Page 88 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 118: ...END BASIC Stamp Command Reference Page 116 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 128: ...FREQOUT BASIC Stamp Command Reference Page 126 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 196: ...NAP BASIC Stamp Command Reference Page 194 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 206: ...OWIN BASIC Stamp Command Reference Page 204 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 214: ...OWOUT BASIC Stamp Command Reference Page 212 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 216: ...PAUSE BASIC Stamp Command Reference Page 214 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 226: ...POLLMODE BASIC Stamp Command Reference Page 224 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 232: ...POLLOUT BASIC Stamp Command Reference Page 230 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 236: ...POLLRUN BASIC Stamp Command Reference Page 234 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 240: ...POLLWAIT BASIC Stamp Command Reference Page 238 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 262: ...RCTIME BASIC Stamp Command Reference Page 260 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 274: ...RUN BASIC Stamp Command Reference Page 272 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 310: ...SEROUT BASIC Stamp Command Reference Page 308 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 324: ...STOP BASIC Stamp Command Reference Page 322 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...