background image

Parallax, Inc.  •  BS2p “Plus Pack” (#45184)  •  10/2001

 

Page 47

 

 

 
tempIn          VAR     Word                    ' raw temperature 
sign            VAR     tempIn.Bit11            ' 1 = negative temperature 
tInLow          VAR     tempIn.LowByte 
tInHigh         VAR     tempIn.HighByte 
tSign           VAR     Bit 
 
tempC           VAR     Word                    ' Celsius 
tempF           VAR     Word                    ' Fahrenheit 
char            VAR     Byte                    ' character for LCD 
rjNum           VAR     tempIn                  ' right justified number 
rjSign          VAR     Bit                     ' sign for rj number 
pos             VAR     Byte                    ' position to print 
digits          VAR     Nib                     ' digits in rjNum 
width           VAR     Nib                     ' width of display 
 
 
' -----[ EEPROM Data ]---------------------------------------------------------- 

                ' ROM codes for connected sensors 
                ' -- these values MUST be edited for your sensors 
 
T_ID0           DATA    $22,$30,$34,$01,$00,$00,$00,$6C 
T_ID1           DATA    $22,$85,$42,$01,$00,$00,$00,$71 
 
 
                ' labels for temperature sensors 
 
T_Label0        DATA    "INSIDE ",0 
T_Label1        DATA    "OUTSIDE ",0 
 
 
' -----[ Initialization ]------------------------------------------------------- 

Initialize: 
  PAUSE 500                                     ' let the LCD settle 
  LCDCMD LCDpin,%00110000 : PAUSE 5             ' 8 -bit mode 
  LCDCMD LCDpin,%00110000 : PAUSE 0 
  LCDCMD LCDpin,%00110000 : PAUSE 0 
  LCDCMD LCDpin,%00100000 : PAUSE 0             ' 4 -bit mode 
  LCDCMD LCDpin,%00101000 : PAUSE 0             ' 2-line mode 
  LCDCMD LCDpin,%00001100 : PAUSE 0             ' no crsr, no blink 
  LCDCMD LCDpin,%00000110                       ' inc crsr, no disp shift 
 
 
' -----[ Main Code ]------------------------------------------------------------ 

Main: 
  LCDOUT LCDpin,ClrLCD,["    DS1822"]           ' splash screen 
  LCDOUT LCDpin,Line2, ["  Thermometer"] 
  PAUSE 2000 
  LCDCMD LCDpin,ClrLCD 
 
 
Show_Sensors: 
  LOOKUP sensor,[T_ID0,T_ID1],eeAddr            ' point to ROM code 
  GOSUB Get_Temp                                ' get temperature 
 
  LOOKUP sensor,[T_Label0,T_Label1],eeAddr      ' display sensor label 
  LCDCMD LCDpin, Line1 
  GOSUB Print_Label 
 
  width = 4 

Содержание BS2p Plus Pack AppKit

Страница 1: ...nsult the appropriate product data sheets not duplicated here for detailed explanation of each component s operation Each of the enclosed experiments was built tested and run on the BS2p Demo Board 45...

Страница 2: ...S2p Demo Board connect the LCD and install Jumper X6 Adjust contrast pot for best display Refer to the Hitachi HD44780 documentation for details on LCD control Revision History I O Definitions LCDpin...

Страница 3: ...00001100 PAUSE 0 no crsr no blink LCDCMD LCDpin 00000110 inc crsr no disp shift Main Code Main LCDCMD LCDpin ClrLCD clear display PAUSE 500 Splash_Screen LCDOUT LCDpin NoCmd THE BASIC STAMP PAUSE 2000...

Страница 4: ...flash display by display display toggling display bit LCDCMD LCDpin cmd PAUSE 250 NEXT PAUSE 1000 Shift_Display FOR idx 1 TO 16 shift display to right LCDCMD LCDpin DispRt PAUSE 100 NEXT PAUSE 1000 FO...

Страница 5: ...will hold up to eight customer characters To run this program on the BS2p Demo Board connect the LCD and install Jumper X6 Adjust contrast pot for best display Refer to the Hitachi HD44780 documentat...

Страница 6: ...00000 PAUSE 0 4 bit mode LCDCMD LCDpin 00101000 PAUSE 0 2 line mode LCDCMD LCDpin 00001100 PAUSE 0 no crsr no blink LCDCMD LCDpin 00000110 inc crsr no disp shift DLChars download custom chars to LCD L...

Страница 7: ...Parallax Inc BS2p Plus Pack 45184 10 2001 Page 7 Subroutines...

Страница 8: ...e counter and updates the screen by downloading the appropriate character map for each digit To run this program on the BS2p Demo Board connect the LCD and install Jumper X6 Adjust contrast pot for be...

Страница 9: ...c DATA 00 00 00 00 00 00 00 00 Initialization Initialize PAUSE 500 let the LCD settle LCDCMD LCDpin 00110000 PAUSE 5 8 bit mode LCDCMD LCDpin 00110000 PAUSE 0 LCDCMD LCDpin 00110000 PAUSE 0 LCDCMD LCD...

Страница 10: ...USE 100 NEXT GOTO Main END Subroutines Update_CC update custom character LCDCMD LCDpin CGRam cNum CLines point to character map FOR idx 0 TO CLines 1 READ addr idx char get data for character line LCD...

Страница 11: ...ng character cell definitions in the Stamp s EEPROM This program displays a rolling odometer type reading last digit rolls Character definitions are copied from the standard set using LCD Character Cr...

Страница 12: ...definitions Char0 DATA 0E 11 13 15 19 11 0E 00 00 00 Char1 DATA 04 0C 04 04 04 04 0E 00 00 00 Char2 DATA 0E 11 01 02 04 08 1F 00 00 00 Char3 DATA 1F 02 04 02 01 11 0E 00 00 00 Char4 DATA 02 06 0A 12 1...

Страница 13: ...in Line2 0 OdoChar 0 00 PAUSE 1000 Show_Counters FOR counter 0 TO 999 FOR hundreds 0 TO 99 temp counter display odometer version width 3 pos Line2 1 GOSUB RJ_Print addr hundreds GOSUB Update_CC update...

Страница 14: ...Parallax Inc BS2p Plus Pack 45184 10 2001 Page 14...

Страница 15: ...a single line LCD that will display the 5x10 character set The LCD character map includes properly descended characters but they are not mapped in the normal ASCII set A simple conversion routine can...

Страница 16: ...ON 0 button input is active low Variables char VAR Byte character sent to LCD addr VAR Byte message address answer VAR Nib answer pointer clock VAR Nib animation clock pntr VAR Nib pointer to animatio...

Страница 17: ...char read a character IF char 0 THEN Msg_Done if 0 message is complete GOSUB Translate fix letters with descenders LCDOUT LCDpin NoCmd char addr addr 1 point to next character GOTO Show_Msg Msg_Done...

Страница 18: ...inc com Started Updated 26 SEP 2001 STAMP BS2p Program Description This program reads bit 7 from the PCF8574 If that bit is high button is pressed a counter is incremented and displayed via LEDs on PC...

Страница 19: ...pulled up to Vdd 5 through 10K This input is connected to Vss ground through a N O pushbutton switch The input will read 1 when the switch is open 0 when pressed PCF8574 can sink current but provide...

Страница 20: ...DEBUG Press button to update counter Main Code Main I2CIN I2Cpin Rd8574 MixDDR cntr ioByte IF btn THEN Main wait for press cntr cntr 1 4 update counter DEBUG Home 10 10 10 BIN2 cntr display on screen...

Страница 21: ...Updated 26 SEP 2001 STAMP BS2p Program Description The program demonstrates the PCF8583 RTC RAM When the program starts you will be asked if you want to set the time If Yes you ll enter the hours min...

Страница 22: ...play Data RAM control Line1 CON 80 address of line 1 Line2 CON C0 address of line 2 Yes CON 1 No CON 0 Baud96 CON 240 9600 8 N 1 matches DEBUG Variables seconds VAR Byte minutes VAR Byte hours VAR Byt...

Страница 23: ...de LCDCMD LCDpin 00001100 PAUSE 0 no crsr no blink LCDCMD LCDpin 00000110 inc crsr no disp shift LCDOUT LCDpin ClrLCD BSP PCF8583 splash screen Check_Set_Clock DEBUG Would you like to set the clock Y...

Страница 24: ...s rawTime 60 Put_Clock regSecs 0 regMins HighNib minutes 10 convert regs to BCD regMins LowNib minutes 10 regHrs HighNib hours 10 regHrs LowNib hours 10 regMoDay HighNib month 10 regMoDay LowNib month...

Страница 25: ...Parallax Inc BS2p Plus Pack 45184 10 2001 Page 25 LCDOUT LCDpin NoCmd char print the character eeAddr eeAddr 1 point to next GOTO Print_Loop go get it Print_Done RETURN...

Страница 26: ...nstates the Philips PCF8591 4 channel A2D plus 1 channel D2A Channel 0 input is tied to the output of the D2A pin Channel 1 input is tied to the wiper of a pot Channes 2 and 3 are tied to Vss The PCF8...

Страница 27: ...Inc CON 00000100 auto inc a2d channels MVPB CON 139C millivolts per bit factor Variables aOut VAR Byte analog out value aIn VAR Byte 4 analog input channels mVolts VAR Word convert to millivolts dummy...

Страница 28: ...Parallax Inc BS2p Plus Pack 45184 10 2001 Page 28 NEXT PAUSE 500 delay between updates aOut aOut 1 increment analog output GOTO Set_D2A go again END Subroutines...

Страница 29: ...E mail stamptech parallaxinc com Started Updated 26 SEP 2001 STAMP BS2p Program Description This program writes to and reads from a 24LC32 I2C EEPROM The status of the program and data are displayed o...

Страница 30: ...2 CON C0 DDRAM address of line 2 Variables addr VAR Word EE address addrHi VAR addr HighByte addrLo VAR addr LowByte rVar VAR Word for random number tOut VAR Byte test value to LCD tIn VAR Byte test v...

Страница 31: ...UT LCDpin ClrLCD I 2 C Out LCDOUT LCDpin Line2 10 In FOR addr 0 TO MaxEE STEP 5 create addresses RANDOM rVar create random value tOut rVar HighByte write value then read it back I2COUT I2Cpin Wr2432 a...

Страница 32: ...h the BS2p Demo Board install Jumper iB2 Do not connect more than one device I O Definitions OWpin CON 15 1 wire device pin Constants 1 Wire Support OW_FERst CON 0001 Front End Reset OW_BERst CON 0010...

Страница 33: ...llas 1 Wire ID HEX2 romData 0 GOSUB Display_Device_Type DEBUG CR DEBUG Serial Number FOR idx 6 TO 1 DEBUG HEX2 romData idx NEXT DEBUG CR Checksum HEX2 romData 7 CR CR DEBUG Stamp Data IHEX2 romData 0...

Страница 34: ...ptech parallaxinc com Started Updated 26 SEP 2001 STAMP BS2p Program Description There is no actual code in this module This program stores the names of various Dallas Semiconductor 1 Wire devices The...

Страница 35: ...2450 DATA DS2450 0 DS2505 DATA DS2505 0 DS2506 DATA DS2506 0 DS2890 DATA DS2890 0 string pointers Pointers DATA 01 2 PntrBase Word FCode01 DATA 04 2 PntrBase Word FCode04 DATA 10 2 PntrBase Word FCode...

Страница 36: ...o board install Jumper X1 iB1 If using a Blue Dot Receptor RJ 11 connection with the BS2p Demo Board install Jumper X1 iB2 Do not connect more than one device I O Definitions LCDpin CON 0 connect LCD...

Страница 37: ...LCDCMD LCDpin 00110000 PAUSE 0 LCDCMD LCDpin 00100000 PAUSE 0 4 bit mode LCDCMD LCDpin 00101000 PAUSE 0 2 line mode LCDCMD LCDpin 00001100 PAUSE 0 no crsr no blink LCDCMD LCDpin 00000110 inc crsr no d...

Страница 38: ...AD addr strPtr LowByte get the string location READ addr 1 strPtr HighByte Read_Char READ strPtr char read character from string IF char 0 THEN Dev_Type_Done at end 0 Yes LCDOUT LCDpin NoCmd char no p...

Страница 39: ...DS1921 0 DS1963 DATA DS1963 0 DS1971 DATA DS1971 0 DS1973 DATA DS1973 0 DS1982 DATA DS1982 0 DS1985 DATA DS1985 0 DS1986 DATA DS1986 0 DS1990 DATA DS1990 0 DS1991 DATA DS1991 0 DS1992 DATA DS1992 0 DS...

Страница 40: ...2 DATA 09 2 PntrBase Word DS1982 DATA 0A 2 PntrBase Word DS1995 DATA 0C 2 PntrBase Word DS1996 DATA 1A 2 PntrBase Word DS1963 DATA 21 2 PntrBase Word DS1921 DATA 05 2 PntrBase Word DS2405 DATA 0B 2 Pn...

Страница 41: ...Pack File PP_DS1822 BSP Purpose Reads and displays information from a Dallas DS1822 Author Parallax E mail stamptech parallaxinc com Started Updated 26 SEP 2001 STAMP BS2p Program Description This pr...

Страница 42: ...ck VAR Nib device check return ocde idx VAR Byte loop counter romData VAR Byte 8 ROM data from DS1820 tempIn VAR Word raw temperature sign VAR tempIn Bit11 1 negative temperature tLo VAR tempIn LowByt...

Страница 43: ...re devices are present on the bus It does NOT search for ROM codes Device_Check devCheck 0 OWOUT OWpin OW_FERst SearchROM reset and start search OWIN OWpin OW_BitMode devCheck Bit1 devCheck Bit0 RETUR...

Страница 44: ...Parallax Inc BS2p Plus Pack 45184 10 2001 Page 44...

Страница 45: ...r R1 for 1 Wire pull up Title BS2p Plus Pack File PP_DS1822 2 BSP Purpose Reads and displays information from two Dallas DS1822 Author Parallax E mail stamptech parallaxinc com Started Updated 26 SEP...

Страница 46: ...played chars left DispRt CON 1C shift displayed chars right DDRam CON 80 Display Data RAM control CGRam CON 40 Custom character RAM Line1 CON 80 DDRAM address of line 1 Line2 CON C0 DDRAM address of l...

Страница 47: ...D1 DATA 22 85 42 01 00 00 00 71 labels for temperature sensors T_Label0 DATA INSIDE 0 T_Label1 DATA OUTSIDE 0 Initialization Initialize PAUSE 500 let the LCD settle LCDCMD LCDpin 00110000 PAUSE 5 8 bi...

Страница 48: ...InHigh tSign sign save sign bit tempC tempIn tempC tempC 4 round to whole degrees IF tSign 0 THEN NoNeg1 tempC tempC FF00 extend sign bits for negs NoNeg1 tempF tempC 01CD multiply by 1 8 IF tSign 0 T...

Страница 49: ...Parallax Inc BS2p Plus Pack 45184 10 2001 Page 49...

Страница 50: ...cription Flashes an LED with a DS2405 addressable switch In this demo the LED status follows a bit in a randomly generated variable Note that the sink capability of the DS2405 is only 4 mA Use at leas...

Страница 51: ...Word random value flags VAR rndValue LowByte flags byte ledFlag VAR flags Bit7 LED flag status VAR bit EEPROM Data Initialization Get_SN DEBUG CLS PAUSE 250 let debug window open DEBUG DS2405 Reading...

Страница 52: ...ED otherwise turn off LED_On DEBUG LED On IF status On THEN Show_Flags if on shake flags GOTO Toggle_LED otherwise turn on Subroutines Shake_Flags FOR idx 0 TO 15 let all bits change RANDOM rndValue N...

Страница 53: ...amptech parallaxinc com Started Updated 26 SEP 2001 STAMP BS2p Program Description This program demonstrates the DS2980 digital pot by placing it in an RC circuit that would typically be used with RCT...

Страница 54: ...ON 96 release new pot setting Variables romData VAR Byte 8 ROM data from device idx VAR Byte temp VAR Byte potLevel VAR Byte rcValue VAR Word EEPROM Data Initialization Get_SN DEBUG CLS PAUSE 250 let...

Страница 55: ...CR send new level to pot OWOUT OWpin OW_FERst MatchROM STR romData 8 WrPot potLevel OWIN OWpin 0 temp read new level back IF temp potLevel THEN Pot_Error check for correct receipt OWOUT OWpin OW_BERst...

Отзывы: