background image

DOC: SPII2CHDWBrief - V2.71    07/25/2017 

 

PAGE 21 

 

USING SPI 

 
Electrical Data Connection and Addressing 
 
Enabling the SPI/I2C interface is controlled by Pin 2 (SPI/I2C Enable). Applying power to Pin 2 
(from pin 6) disables USB connectivity and enables the SPI/I2C interface. Choosing SPI or I2C for a 
LB5900 sensor is done using Pin 1 of the interface cable. Grounding the pin will enable SPI and 
disable I2C, applying power (from Pin 6), selects I2C and disables SPI.  
 
Data direction. To simplify connectivity, LadyBug utilizes the MOSI/MISO naming scheme. This 
allows the pins on the master and the slave to have the same name. For example, the output of 
the master must always be connected to the input of the slave. This line is called MOSI, 

M

aster 

O

ut 

S

lave 

I

n. The master’s input is MISO, 

M

aster 

I

S

lave 

O

ut. Some microcontroller 

manufacturers may not use this terminology, however the SPI connections function the same. 
 
SPI sensors require a separate Slave Selection (SS) connection for each sensor used. For example 
if two sensors are used, SCLK, MOSI and MISO are all connected to each sensor and the 
microcontroller. The microcontroller must also have two SS outputs, one to select each sensor. 
Only one SS line may be active at any given time, the non-active line disables the sensor’s MISO 
(the sensor’s data output line in this case) line. The SS line is active low as shown in Figure 17. 
 

 

Figure 17 - Typical SPI connection 

 
 
 
 

 

Summary of Contents for LB5900 Series

Page 1: ...ion Port Reset 6 Wiring Diagram Connector Pin Out 7 USING I2C 8 Electrical Data Connection and Addressing 8 I2C Message Overview 9 Processing Time Delay 9 Clock Start Stop Direction 9 Acknowledge NACK...

Page 2: ...ommand Header 23 Previous SPI communication status 23 Busyness 24 Busy Ready 24 Sensor Status Byte STB 25 Measurement Processing Time 25 Header Details 25 Command Header 06h Read Status Length 26 Comm...

Page 3: ...14 Figure 11 ACK NACK Tests 15 Figure 12 Header 06h with Command Example 16 Figure 13 Header 06h used to Prepare Status Length 17 Figure 14 Read the Status and Length 18 Figure 15 Command Header 0Ch E...

Page 4: ...ect Pin 1 SPI I2C Select directly to power or ground Do not connect it to a control line This line is tested at power up only and any startup glitches on the controller may cause erroneous selection t...

Page 5: ...ffer option SPI the option enables sensor operation through SPI Serial Peripheral Interface or I2C Inter Integrated Circuit Each interface technology has its own advantages LadyBug recommends that the...

Page 6: ...ed later may be in binary form In general SCPI commands sent USB I2C or SPI are identical There are however some exclusions and limitations The SPI and I2C interfaces do not accept concatenated comman...

Page 7: ...or With option SPI a standard USB cable can also be connected and the sensor will function as a USB sensor when SPI is not enabled The SPI I2C connector end is a Samtec FFSD type or equivalent keyed 0...

Page 8: ...yBug s nominal recommended value is 2 2K ohms The pull up resistors should be connected to the microcontroller s logic power supply 3 3 5 0 volts near the microcontroller High speed applications may b...

Page 9: ...stop conditions are always generated by the master user controller After a start condition is issued the bus is considered to be busy and cannot be used for any other transactions until a stop condit...

Page 10: ...ed and responds with ACK it is ready for a request if NACK is returned the master should wait A loop can be setup and continuous tests made until ACK is returned I2C Timing I2C timing conditions are s...

Page 11: ...R W All messages begin by the user master issuing a standard I2C start condition and terminate with a standard I2C stop condition Each byte must be acknowledged by the receiver of the data The figure...

Page 12: ...s ignored by sensors without matching addresses LadyBug utilizes I2C standard 7 bit addressing with bits 7 3 set as 10011 followed by two bits for sensor addressing then the direction bit as detailed...

Page 13: ...The primary bit used is bit 4 which indicates that a message is available The message can be the measurement an error message or other information Figure 9 Status Byte Details It is important to note...

Page 14: ...he indicated command Figure 10 I2C Command Header Table Note that reading data back from the sensor is done following one of the above commands and is detailed below with each command header explanati...

Page 15: ...an error when it is not sent Figure 11 ACK NACK Tests The list below details how to use ACK NACK for testing At the end of this section is a complete measurement example ACK NACK should be utilized pr...

Page 16: ...ed by hardware to determine the addressed sensor If only requesting the sensor status and the length of any available data no SCPI command or terminator is sent Direction address byte R W bit 0 Output...

Page 17: ...ta is known Header 0Ch Read Complete Output Buffer can be used to read in the data Using the Prepare Status Length alone without a command is normally not required since the number of bytes available...

Page 18: ...can be done after sending Header 06H and receiving ACK Normally if sent with no command the length of available data will be 0 and only the status byte is useful Figure 14 Read the Status and Length...

Page 19: ...to sensor Start condition Address byte 0Ch Stop Condition Figure 15 Command Header 0Ch Example Read Complete Output Buffer is designed to pass the entire buffer back Any data left in the sensor output...

Page 20: ...st for ready see below 8 Write FREQ 1000 MHZ use your frequency to sensor using Header 06h then wait 1ms Sets the measurement frequency 9 Test for ready see below 10 Write AVER COUN 10 use your of ave...

Page 21: ...same name For example the output of the master must always be connected to the input of the slave This line is called MOSI Master Out Slave In The master s input is MISO Master In Slave Out Some micro...

Page 22: ...gure 18 which details the sensors CPOL 1 and CPHA 1 SPI timing The clock is always generated by the master user controller and both the master and sensor capture data on the trailing clock edge The da...

Page 23: ...ller is required to allow sufficient time for the sensor to process the function prior to requesting data During the time the sensor is processing data the master can address other sensors For example...

Page 24: ...ed Figure 22 Byte Timing Diagram and Table Processing begins when the SS line is raised after a command is received from the master user controller During processing the sensor has limited capability...

Page 25: ...r contains a message 5 32 Event Status Bit Future implementation 6 64 Master Summary Status Future implementation 7 128 Status Summary Future implementation Figure 23 Sensor Status Byte Measurement Pr...

Page 26: ...e and the command will function as expected This is separate from the Sensor s measurement completion flag Measurement completion is indicated by bit 4 of the status byte however this byte is not vali...

Page 27: ...Header F0h The length of Command Header F0h is dependent on the command being sent however the minimum is 5 bytes including the message terminator The minimum 5 bytes including the terminator is only...

Page 28: ...st generate the required clocks This is done by sending irrelevant data to the sensor Figure 26 Command Header 0Ch Read Back Example Prior communication indicated that there are 16 bytes 010h availabl...

Page 29: ...delay 3 INIT CONT 0 Sets the sensor for single triggered measurements 4 AVER COUN AUTO 0 Turns off automatic averaging 5 FREQ 1020 MHZ Sets the frequency 6 AVER COUN 10 Sets Averaging to 10 7 READ Ma...

Page 30: ...d Length Loop refer to the READ Command at the end of this section 2 TRIG DEL AUTO 0 Turns off Trigger delay To the sensor F0000010TRIG DEL AUTO 000 At this point a 1ms delay can be added or a Read St...

Page 31: ...n the controller program because it is known that the measurement will take at least that long Now test the sensor to see if the measurement is complete To the Sensor 060000000000 Send all 6 bytes Ret...

Page 32: ...I E0 06 00 00 00 00 00 READ STB AND LENGTH FF E0 00 00 00 00 BUSY SPI E0 STB 00 BUFFER EMPTY 06 00 00 00 00 00 READ STB AND LENGTH FF E0 00 00 00 00 BUSY SPI E0 STB 00 BUFFER EMPTY 06 00 00 00 00 00 R...

Page 33: ...on Pages 28 27 24 21 Document Revision V2 5 Clarification regarding SPI I2C Selection during Startup Important changes marked with on Pages 4 6 Document Revision V2 6 Document Minor text changes Docu...

Reviews: