background image

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

 

Page 54

 

 

 
 
' -----[ Constants ]------------------------------------------------------------ 

' 1-Wire Support 

OW_FERst        CON     %0001                   ' Front-End Reset 
OW_BERst        CON     %0010                   ' Back-End Reset 
OW_BitMode      CON     %0100 
OW_HighSpd      CON     %1000 
 
ReadROM         CON     $33                     ' read ID, serial num, CRC 
MatchROM        CON     $55                     ' look for specif ic device 
 
' DS2890 control 

RdPot           CON     $F0                     ' read pot position 
WrPot           CON     $0F                     ' write pot position 
RdCtrl          CON     $AA                     ' read control register 
WrCtrl          CON     $55                     ' write control register 
IncPot          CON     $C3                     ' increment resistance 
DecPot          CON     $99                     ' decrement resistance 
Release         CON     $96                     ' release new pot setting 
 
 
' -----[ Variables ]------------------------------------------------------------ 

romData         VAR     Byte(8)                 ' ROM data from device 
idx             VAR     Byte 
temp            VAR     Byte 
potLevel        VAR     By te 
rcValue         VAR     Word 
 
 
' -----[ EEPROM Data ]---------------------------------------------------------- 

 
 
' -----[ Initialization ]------------------------------------------------------- 

Get_SN: 
  DEBUG CLS 
  PAUSE 250                                     ' let debug window open 
  DEBUG "DS2980 - Reading serial number" 
  OWOUT OWpin,OW_FERst,[ReadROM]                ' send Read ROM command 
  OWIN  OWpin,OW_BERst,[STR romData\8]          ' read serial number & CRC 
  DEBUG CR, "         " 
  FOR idx = 6 TO 1                              ' display serial number 
    DEBUG HEX2 romData(idx) 
  NEXT 
  PAUSE 1000 
 
  DEBUG CLS 
  DEBUG "DS2980 - Setting control register" 
 
Set_Ctrl:   
  ' wiper 1, charge pump off 
  OWOUT OWpin, OW_FERst, [MatchROM, STR romData\8, WrCtrl, %00001100] 
  OWIN OWpin, OW_BERst, [temp]                  ' read back ctrl data 
  IF (temp = $FF) THEN Set_Ctrl                 ' $FF = invalid ctrl reg val 
  PAUSE 1000 
 
 

Summary of Contents for BS2p Plus Pack AppKit

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 7: ...Parallax Inc BS2p Plus Pack 45184 10 2001 Page 7 Subroutines...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 14: ...Parallax Inc BS2p Plus Pack 45184 10 2001 Page 14...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 44: ...Parallax Inc BS2p Plus Pack 45184 10 2001 Page 44...

Page 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...

Page 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...

Page 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...

Page 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...

Page 49: ...Parallax Inc BS2p Plus Pack 45184 10 2001 Page 49...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Reviews: