Download Print this page

Advertisement

Quick Links

BS2p "Plus Pack" AppKit (#45184)
Introduction
The BS2p "Plus Pack" is a selection of components and ready-to-run source code to assist experimenters
with mastering some of the exciting new features of the BS2p; specifically the use of parallel LCDs,
2
Philips I
C™ components and Dallas Semiconductor 1-Wire® components.
Please note that this AppKit is designed for intermediate to advanced users. The schematics and source
code have been carefully checked and are commented, but the expectation is that the user will consult
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 (#45183). Should
you desire more space for connecting components, please consider the NX-1000 lab board (#28135).
Packing List
Verify that your BS2p "Plus Pack" package is complete in accordance with the list below. The contents of
the package include:
Packing List (this page)
Documentation/Source Code Diskette
Parallel LCD module; 2 lines x 16 characters (HD44780-compatible)
PCF8574 Remote 8-Bit I/O Expander
PCF8583 Clock/Calendar with 240 x 8-Bit RAM
PCF8591 8-Bit A/D and D/A Converter
24LC32 32K Serial EEPROM
(2) DS1822 Econo-MicoLAN Digital Thermometer
DS2405 Addressable Switch
DS2890 1-Wire Digital Potentiometer
(4) Jumper wires packs
220 ohm resistor
(2) 1K resistor
10K resistor
100K potentiometer
0.01 uF capacitor
(2) low-current LED
Normally-open pushbutton switch
32.678 kHz crystal
Parallax, Inc. • BS2p "Plus Pack" (#45184) • 10/2001
599 Menlo Drive, Suite 100
Rocklin, California 95765, USA
Office: (916) 624-8333
Fax: (916) 624-8003
General: info@parallaxinc.com
Technical: stamptech@parallaxinc.com
Web Site: www.parallaxinc.com
Educational: www.stampsinclass.com
Page 1

Advertisement

loading
Need help?

Need help?

Do you have a question about the BS2p Plus Pack AppKit and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Summary of Contents for Parallax BS2p Plus Pack AppKit

  • Page 1 220 ohm resistor • (2) 1K resistor • 10K resistor • 100K potentiometer • 0.01 uF capacitor • (2) low-current LED • Normally-open pushbutton switch • 32.678 kHz crystal Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 1...
  • Page 2 ' shift displayed chars left DispRt ' shift displayed chars right DDRam ' Display Data RAM control DispCtrl %00001000 ' display control command ' -----[ Variables ]------------------------------------------------------------ Byte ' command sent to LCD Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 2...
  • Page 3 PAUSE 150 NEXT PAUSE 1000 Block_Cursor: cmd = DispCtrl display = On blinking = On ' enable block cursor LCDCMD LCDpin,cmd PAUSE 2000 blinking = Off ' turn it off Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 3...
  • Page 4 PAUSE 1000 FOR idx = 1 TO 16 ' shift display back LCDCMD LCDpin,DispLf PAUSE 100 NEXT PAUSE 1000 GOTO Main ' do it all over ' -----[ Subroutines ]---------------------------------------------------------- Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 4...
  • Page 5 DDRam ' Display Data RAM control CGRam ' Custom character RAM Line1 ' DDRAM address of line 1 Line2 ' DDRAM address of line 2 ' -----[ Variables ]------------------------------------------------------------ Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 5...
  • Page 6 ' 5 characters in cycle LOOKUP cNum,[2,1,0,1,newChr],char LCDOUT LCDpin,cmd,[char] ' write animation character PAUSE 100 ' delay between animation chars NEXT NEXT PAUSE 3000 GOTO Main ' do it all over Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 6...
  • Page 7 ' -----[ Subroutines ]---------------------------------------------------------- Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 7...
  • Page 8 ' Display Data RAM control CGRam ' Custom character RAM Line1 ' DDRAM address of line 1 Line2 ' DDRAM address of line 2 CLines ' lines per character Space Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 8...
  • Page 9 IF (cNum < 2) OR (addr > 0) THEN DigitOK addr = Space ' leading space if < 10 DigitOK: addr = addr * CLines ' calculate map for this digit GOSUB Update_CC ' download to LCD NEXT Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 9...
  • Page 10 ' point to character map FOR idx = 0 TO (CLines - 1) READ (addr + idx),char ' get data for character line LCDOUT LCDpin,NoCmd,[char] ' write to LCD CGRAM NEXT RETURN Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 10...
  • Page 11 ' No command in LCDOUT ClrLCD ' clear the LCD CrsrHm ' move cursor to home position CrsrLf ' move cursor left CrsrRt ' move cursor right DispLf ' shift displayed chars left Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 11...
  • Page 12 $11,$0E,$1E,$1D,$1B,$17,$00,$1F,$1F,$1F Char3i DATA $00,$1D,$1B,$1D,$1E,$0E,$11,$1F,$1F,$1F Char4i DATA $1D,$19,$15,$0D,$00,$1D,$1D,$1F,$1F,$1F Char5i DATA $00,$0F,$01,$1E,$1E,$0E,$11,$1F,$1F,$1F Char6i DATA $19,$17,$0F,$01,$0E,$0E,$11,$1F,$1F,$1F Char7i DATA $00,$1E,$1D,$1B,$17,$17,$17,$1F,$1F,$1F Char8i DATA $11,$0E,$0E,$11,$0E,$0E,$11,$1F,$1F,$1F Char9i DATA $11,$0E,$0E,$10,$1E,$1D,$13,$1F,$1F,$1F MapStart Char0i ' -----[ Initialization ]------------------------------------------------------- Initialize: Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 12...
  • Page 13 READ MapStart + (addr + idx // 100),char LCDOUT LCDpin,NoCmd,[char] ' write to LCD CGRAM NEXT RETURN RJ_Print: ' right justified printing digits = width LOOKDOWN temp,<[0,10,100,1000,65535],digits LCDOUT LCDpin,pos,[REP " "\(width-digits),DEC temp] RETURN Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 13...
  • Page 14 Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 14...
  • Page 15 ' the breadboard, connect the LCD to X5 and install Jumper X6. Adjust contrast ' pot for best display. ' Refer to the Hitachi HD44780 documentation for details on LCD control. ' -----[ Revision History ]----------------------------------------------------- Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 15...
  • Page 16 ' 4-bit mode LCDCMD LCDpin,%00100100 : PAUSE 0 ' 5x10 font LCDCMD LCDpin,%00001100 : PAUSE 0 ' no crsr, no blink LCDCMD LCDpin,%00000110 ' inc crsr, no disp shift Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 16...
  • Page 17 LOOKUP pntr,["-+|*"],char ' load animation character LCDOUT LCDpin,DDRam + 15,[char] ' write it at column 15 pntr = pntr + 1 // 4 ' update animation char Shuffle_Done: RETURN Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 17...
  • Page 18 ' I2CIN and I2COUT commands support this with an address parameter (this byte ' comes after the Slave Address byte). With the PCF8574, replace the address ' byte with a value that reflects the desired state of the I/O pins, where Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 18...
  • Page 19 Byte ' i/o byte for PCF8574 ioByte.Bit7 ' button input (0 = pressed) cntr ' counter ' -----[ EEPROM Data ]---------------------------------------------------------- ' -----[ Initialization ]------------------------------------------------------- Initialize: DEBUG CLS Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 19...
  • Page 20 ' update counter DEBUG Home, 10, 10, 10, BIN2 cntr ' display on screen I2COUT I2Cpin, Wr8574, MixDDR, [~cntr] ' send new value PAUSE 200 GOTO Main ' -----[ Subroutines ]---------------------------------------------------------- Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 20...
  • Page 21 ' To run this program on the BS2p Demo Board, connect the LCD and install ' Jumper X3. ' Refer to the Hitachi HD44780 documentation for details on LCD control. ' -----[ Revision History ]----------------------------------------------------- ' -----[ I/O Definitions ]------------------------------------------------------ Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 21...
  • Page 22 Byte ' data to/from register eeAddr Byte ' EE data pointer char Byte ' character from EE Byte ' loop counter response Byte ' -----[ EEPROM Data ]---------------------------------------------------------- Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 22...
  • Page 23 DEBUG CR, "Day (0..6 [0 = Sunday]): " SERIN RxD,Baud96,[DEC1 day] IF (day < 7) THEN Set_The_Clock day = 0 Set_The_Clock: month = 9 date = 18 year = 1 GOSUB Put_Clock Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 23...
  • Page 24 = regMoDay >> 5 RETURN Print_Day: LOOKUP day,[Su,Mo,Tu,We,Th,Fr,Sa],eeAddr ' point to EE string Print_Loop: READ eeAddr,char ' read a character IF (char = 0) THEN Print_Done ' done? Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 24...
  • Page 25 LCDOUT LCDpin,NoCmd,[char] ' print the character eeAddr = eeAddr + 1 ' point to next GOTO Print_Loop: ' go get it Print_Done: RETURN Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 25...
  • Page 26 In this demo, the analog output ' bit is enabled and four single-ended analog inputs are used. ' Note that the first byte transmitted in a read cycle contains the conversion Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 26...
  • Page 27 DEBUG "Channel ", DEC1 chan, " In... ", DEC aIn(chan), " ", Tab mVolts = aIn(chan) */ MVPB DEBUG "(", DEC mVolts DIG 3, ".", DEC3 mVolts, " volts)", CR Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 27...
  • Page 28 NEXT PAUSE 500 ' delay between updates aOut = aOut + 1 ' increment analog output GOTO Set_D2A ' go again ' -----[ Subroutines ]---------------------------------------------------------- Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 28...
  • Page 29 ' Refer to the Hitachi HD44780 documentation for details on LCD control. ' -----[ I/O Definitions ]------------------------------------------------------ LCDpin ' LCD is connected to OutL I2Cpin ' SDA on 8; SCL on 9 Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 29...
  • Page 30 ' 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 display shift Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 30...
  • Page 31 = tIn : width = 3 : pos = Line2 + 13 GOSUB RJ_Print PAUSE 250 NEXT ' -----[ Subroutines ]---------------------------------------------------------- RJ_Print: ' right justified printing digits = width LOOKDOWN temp,<[0,10,100,1000,65535],digits LCDOUT LCDpin,pos,[REP " "\(width-digits),DEC temp] RETURN Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 31...
  • Page 32 ' ROM data from device devType romData devCheck ' device check return ocde addr Word ' address of string pointer strPtr Word ' string pointer (device address) char Byte ' character for LCD Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 32...
  • Page 33 ' This subroutine is used to display the part number of a 1-Wire device. ' The text data and pointers to it are stored in the EE of a different ' program slot. Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 33...
  • Page 34 ' Store strings first so labels can be used in address pointer table Unknown DATA "Unknown device",0 ' shared family codes FCode01 DATA "DS1990/DS2401",0 FCode04 DATA "DS1994/DS2404",0 FCode10 DATA "DS1920/DS18S20",0 FCode14 DATA "DS1971/DS2430",0 FCode23 DATA "DS1973/DS2433",0 ' iButtons Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 34...
  • Page 35 @$21*2+PntrBase,Word DS1921 DATA @$05*2+PntrBase,Word DS2405 DATA @$0B*2+PntrBase,Word DS2505 DATA @$0F*2+PntrBase,Word DS2506 DATA @$12*2+PntrBase,Word DS2406 DATA @$20*2+PntrBase,Word DS2450 DATA @$22*2+PntrBase,Word DS1822 DATA @$27*2+PntrBase,Word DS2417 DATA @$28*2+PntrBase,Word DS18B20 DATA @$2C*2+PntrBase,Word DS2890 Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 35...
  • Page 36 ' DDRAM address of line 1 Line2 ' DDRAM address of line 2 ' 1-Wire Support OW_FERst %0001 ' Front-End Reset OW_BERst %0010 ' Back-End Reset OW_BitMode %0100 OW_HighSpd %1000 Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 36...
  • Page 37 IF (romData(7) < $FF) THEN Show_Device LCDOUT LCDpin,ClrLCD,["Bad device?"] Show_Device: LCDCMD LCDpin,ClrLCD GOSUB Display_Device_Type ' serial number LCDCMD LCDpin,Line2 FOR idx = 6 TO 1 LCDOUT LCDpin,NoCmd,[HEX2 romData(idx)] NEXT Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 37...
  • Page 38 ' is used to map the strings in EEPROM. The pointer to a device's string ' discription is stored at the location determined by this formula: pointer = device_id * 2 + $600 Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 38...
  • Page 39 "DS2417",0 DS2430 DATA "DS2430",0 DS2433 DATA "DS2433",0 DS2450 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 Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 39...
  • Page 40 @$21*2+PntrBase,Word DS1921 DATA @$05*2+PntrBase,Word DS2405 DATA @$0B*2+PntrBase,Word DS2505 DATA @$0F*2+PntrBase,Word DS2506 DATA @$12*2+PntrBase,Word DS2406 DATA @$20*2+PntrBase,Word DS2450 DATA @$22*2+PntrBase,Word DS1822 DATA @$27*2+PntrBase,Word DS2417 DATA @$28*2+PntrBase,Word DS18B20 DATA @$2C*2+PntrBase,Word DS2890 Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 40...
  • Page 41 With only one sensor, we can use SkipROM and ignore ' the device serial number. ' Program output is via DEBUG. ' -----[ Revision History ]----------------------------------------------------- ' -----[ I/O Definitions ]------------------------------------------------------ OWpin ' -----[ Constants ]------------------------------------------------------------ Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 41...
  • Page 42 DEBUG "-- Insert device and re-start." Get_ROM OWOUT OWpin,OW_FERst,[ReadROM] ' send Read ROM command OWIN OWpin,OW_BERst,[STR romData\8] ' read serial number & CRC IF (romData(0) = DS1822) THEN Show_Data Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 42...
  • Page 43 IF tSign = 0 THEN NoNegF ' if neg, extend sign bits tempF = tempF | $FF00 NoNegF: tempF = tempF + 32 ' finish C -> F conversion RETURN Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 43...
  • Page 44 Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 44...
  • Page 45 ' This program demonstrates individual device addressing with the Dallas ' 1-Wire bus. Before running the program, the individual device addresses ' must be determined and stored in the EEPROM. Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 45...
  • Page 46 ' inside and outside ' -----[ Variables ]------------------------------------------------------------ sensor ' sensor number to process ' loop counter eeAddr Byte ' ee address of ROM match romData Byte(8) ' ROM data to DS1822 Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 46...
  • Page 47 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 Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 47...
  • Page 48 = rjNum.Bit15 ' save sign rjNum = ABS(rjNum) ' convert to positive digits = width LOOKDOWN rjNum,<[0,10,100,1000,65535],digits LCDOUT LCDpin,pos,[REP " "\(width-digits-1),13 * rjSign + " ",DEC rjNum] RETURN Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 48...
  • Page 49 Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 49...
  • Page 50 ' device is read in bit mode after addressing it with Match ROM. ' Refer to PP_DS1822-2.BSP for an example of dealing with multiple 1-Wire ' devices on the same pin. ' -----[ Revision History ]----------------------------------------------------- Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 50...
  • Page 51 DEBUG "DS2405 Digital Switch Demo (LED = flags.Bit7)" Show_Flags PAUSE 1000 ' delay between tests GOSUB Shake_Flags ' randomize output DEBUG Home, CR, CR, "Flags... ", BIN8 flags, CR IF (ledFlag) THEN LED_On Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 51...
  • Page 52 FOR idx = 0 TO 15 ' let all bits change RANDOM rndValue NEXT RETURN Toggle_LED: OWOUT OWpin, OW_FERst, [MatchROM, STR romData\8] OWIN OWpin, OW_BitMode + OW_BERst, [status] ' get new status GOTO Show_Flags Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 52...
  • Page 53 ' Refer to PP_DS1822-2.BSP for an example of dealing with multiple 1-Wire ' devices on the same pin. ' -----[ Revision History ]----------------------------------------------------- ' -----[ I/O Definitions ]------------------------------------------------------ OWpin ' 1-Wire bus RCpin ' RCTIME pin Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 53...
  • Page 54 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 Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 54...
  • Page 55 ' read pot DEBUG "RC Value..", DEC rcValue, " " PAUSE 500 NEXT GOTO Main ' -----[ Subroutines ]---------------------------------------------------------- Pot_Error: DEBUG CLS DEBUG "Error -- could not set pot" Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001 Page 55...

This manual is also suitable for:

45184