birt barcode open source I C BUS COMMUNICATION in Font

Create QR Code in Font I C BUS COMMUNICATION

CHAPTER 13 I C BUS COMMUNICATION
Generating Denso QR Bar Code In None
Using Barcode creation for Font Control to generate, create QR Code JIS X 0510 image in Font applications.
www.OnBarcode.com
Painting ANSI/AIM Code 39 In None
Using Barcode encoder for Font Control to generate, create Code 3/9 image in Font applications.
www.OnBarcode.com
Slave Address
Generating Denso QR Bar Code In None
Using Barcode generation for Font Control to generate, create QR Code 2d barcode image in Font applications.
www.OnBarcode.com
EAN / UCC - 14 Encoder In None
Using Barcode generator for Font Control to generate, create EAN 128 image in Font applications.
www.OnBarcode.com
R/W 0= Write
Print Data Matrix In None
Using Barcode generator for Font Control to generate, create Data Matrix ECC200 image in Font applications.
www.OnBarcode.com
Generating PDF-417 2d Barcode In None
Using Barcode drawer for Font Control to generate, create PDF 417 image in Font applications.
www.OnBarcode.com
Data
GTIN - 13 Generation In None
Using Barcode generation for Font Control to generate, create European Article Number 13 image in Font applications.
www.OnBarcode.com
Code 11 Generation In None
Using Barcode creator for Font Control to generate, create USD - 8 image in Font applications.
www.OnBarcode.com
Data
QR-Code Recognizer In Visual C#.NET
Using Barcode scanner for VS .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
Denso QR Bar Code Printer In Visual Studio .NET
Using Barcode encoder for ASP.NET Control to generate, create QR Code ISO/IEC18004 image in ASP.NET applications.
www.OnBarcode.com
Data Transferred A Data A Data A P
Reading Barcode In C#
Using Barcode scanner for Visual Studio .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
Code 128 Code Set B Scanner In Visual C#
Using Barcode decoder for .NET framework Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
Slave Address
Creating EAN-13 In VS .NET
Using Barcode creation for Reporting Service Control to generate, create EAN / UCC - 13 image in Reporting Service applications.
www.OnBarcode.com
UPC Code Creator In Java
Using Barcode encoder for Java Control to generate, create UPC Symbol image in Java applications.
www.OnBarcode.com
R/W 1= Read
Paint USS Code 39 In Java
Using Barcode generator for Java Control to generate, create USS Code 39 image in Java applications.
www.OnBarcode.com
Create Code 3 Of 9 In VS .NET
Using Barcode creation for Visual Studio .NET Control to generate, create Code 39 Extended image in .NET framework applications.
www.OnBarcode.com
Data Transferred A = Acknowledge S = Start P = Stop
Decoding Code 128 Code Set C In Java
Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Creating Universal Product Code Version A In Visual Studio .NET
Using Barcode creation for ASP.NET Control to generate, create Universal Product Code version A image in ASP.NET applications.
www.OnBarcode.com
From Master From Slave
European Article Number 13 Generation In .NET
Using Barcode creator for ASP.NET Control to generate, create EAN-13 image in ASP.NET applications.
www.OnBarcode.com
2D Creation In C#.NET
Using Barcode generation for Visual Studio .NET Control to generate, create Matrix image in .NET framework applications.
www.OnBarcode.com
Figure 13-1. I2C protocol
PCF8574
One of the most useful I2C devices is the PCF8574 remote I/O expander. It s a single integrated circuit that includes eight pins that can be either inputs or outputs. Figure 13-2 shows the basic block diagram of the part, in which the 8 I/O pins are labeled P0 to P7. The figure doesn t show the part s interrupt pin because you won t be using it for any of the projects in this book.
A0 A1 A2 SCL SDA 8 Bit Shift Register I/O Port
P0 P1 P2 P3 P4 P5 P6 P7 I2C Bus Control
VDD VSS
Power Reset
Figure 13-2. PCF8574 You use address pins A0, A1, and A2 to generate one of eight possible addresses for the expander. That means you can have eight PCF8574s on the same I2C bus by connecting the address pins either high to VDD or low to VSS. A PCF8574 with all address lines tied to VSS will have the address 40 hexadecimal (0x40) or 64 decimal. There s an alternate version of the part with an A suffix that has a base address of 70 hexadecimal (0x70) or 112 decimal. Figure 13-3 illustrates how to compute the address for the two devices.
CHAPTER 13 I C BUS COMMUNICATION
A2 A1 A0 Address
PCF8574
A2 A1 A0 Address
PCF8574A
Figure 13-3. PCF8574 and PCF8574A address When used as outputs, the pins can only sink current (that means they can only be expected to pull a load to ground). This can be confusing because turning a load on means you must write a zero to the pin, not a 1. For example, writing a zero will light an LED whose anode is tied to the positive power supply through a resistor. Each output can sink up to 25 mA, and is latched. That means if your program crashes, they ll remain in whatever state they were in last. Fortunately, when first powered up, the default condition of the pins is high, and the loads will be off.
Eight Outs
Figure 13-4 shows a PCF8574 driving eight LEDs. The LEGO hardware documentation specifies that resistors R1 and R2 must be 82k to terminate the I2C bus properly. Instead of using eight discrete LEDs, you can also use a single bar graph display that has multiple LEDs in the same package. This particular display has the anodes of ten LEDs along the side with the little notch cut in the corner.
Pin 4 Green R1 R2 R3 D1 16 VDD SCL R4 D2 R5 D3 R6 D4 R7 D5 R8 D6 R9 D7 R10 D8
Pin 5 Yellow Pin 6 Blue
14 15
Pin 2 Black Pin 3 Red
SDA 1 A0 2 A1 3 A2 8 VSS
P0 P1 P2 P3 P4 P5 P6 P7
4 5 6 7 9 10 11 12 U1
Figure 13-4. Eight Outs circuit Table 13-1 has the complete list of parts you ll need, and Table 13-2 takes you through the placement on the solderless breadboard step by step. Figure 13-5 shows the completed construction. To
CHAPTER 13 I C BUS COMMUNICATION
simplify the wiring, resistors R3 to R10 have insulation stripped from hook-up wire slid over their leads to prevent them from shorting to each other. The solderless breadboard lacks a hole at column 18, where one of the display pins needs to go. Bend the appropriate pin of the display over to an adjacent pin and wrap it around to make its connection. Table 13-1. Eight Outs Bill of Materials
Component
U1 D1 8 R1 and R2 R3 R10
Part Number
PCF8574 or PCF8574A LED 82k 150 for Eight Outs Ror 100 for Wand
Description
I C Digital Port LED Bar Graph Display 1/4 W 1% Film Resistor 1/4 W 1% Film Resistor
Digi-Key
296-13109-5-ND 160-1068-ND P82.0KCACT-ND P150CACT-ND or P100CACT-ND
U1 R10 R9
D1 D8
Green
Blue
Yellow White Black
Figure 13-5. Eight Outs circuit on solderless breadboard
CHAPTER 13 I C BUS COMMUNICATION
Table 13-2. Eight Outs Component Placement
Component
U1 pin 1 R1 R2 J1 J2 J3 J4 J5 NXT Green White NXT Red Black NXT Blue Yellow R3 R4 R5 R6 R7 R8 R9 R10 D1 D8 Anodes on X
Start
F4 A6 A5 Y4 Y5 Y7 Y11 X4 X1 Y2 C5 J7 I8 H9 G10 D11 C10 B9 A8 X23
X7 X5 J4 J5 J6 J11 A4 H1 Y1 C6 E21 E20 E19 E18 E17 E16 E15 E14
CHAPTER 13 I C BUS COMMUNICATION
You need to import two blocks into the NXT-G environment to control I2C devices such as the PCF8574. Instructions for importing new NXT-G blocks can be found back in 2. I2CbusW is for writing, and I2CbusR is for reading, and because the Eight Outs project has only outputs, we will look at I2CbusW first. The Blink program shown in Figure 13-6 uses the eight LEDs to display the binary value of the loop counter. I2CbusW needs to know the Port on the NXT and the decimal value of the I2C address of the device. In this case, we are using Port 1 and an A series part that has an Address of 112, but you would use 64 for the base PCF8574 part.
Figure 13-6. I2CbusW in Blink NXT-G program Sophisticated I2C devices are typically configured through registers. First, you send the device the register number you want; then you read or write that register s value. However, the uncomplicated PCF8574 doesn t have registers, so you don t enter a register number and you uncheck the WriteReg box in the block s configuration window. WValue is just the value that will be sent directly to the output port pins. The error output Yes/No is True if there has been some sort of communications error, and Status is a code for the error. For now, if there is an error, we ll just ignore it and keep going. While the program is running, all eight of the LEDs will be blinking on and off. The least-significant bit LED will blink so fast it will just look dim, but the most significant bit will take several seconds to blink on and off. The direction of the count might seem backward because an LED is lit when the output value is actually zero. Most likely, if you re using I2C communications, you re also ready to try some NXC programming. Listing 13-1 is for an NXC program that does exactly the same thing as the Blink NXT-G program. The two #define lines take care of specifying the Port and I2C address for the whole program. We declare and initialize a 2-byte array called WriteBuf to be used for I2C communications. WriteBuf[0] is the device address, and WriteBuf[1] is the data.
Copyright © OnBarcode.com . All rights reserved.