Ladybug LB5900 Series Interface Manual

Power sensor, spi & i2c interface
Hide thumbs Also See for LB5900 Series:

Advertisement

Quick Links

TABLE OF CONTENTS ......................................................................................................................... 1
NOTICE ............................................................................................................................................... 4
GENERAL ............................................................................................................................................ 5
Sensor Power ................................................................................................................................. 6
Data Line Electrical Specifications ................................................................................................. 6
Commands, Data Transmission & Reception................................................................................. 6
Sensor Reset and Communication 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 ................................................................................................................ 9
Sensor Busy & NACK ................................................................................................................ 10
I2C Timing ................................................................................................................................ 10
Data Format and Communications .......................................................................................... 11
The Address byte ................................................................................................................. 12
The Status byte .................................................................................................................... 13
Command Header ................................................................................................................ 14
06h Send Command plus Prepare Status & Length ......................................................... 16
0Ch Prepare Complete Output Buffer ............................................................................. 19
I2C Measurement Example .......................................................................................................... 20
USING SPI ......................................................................................................................................... 21
DOC: SPII2CHDWBrief - V2.71 07/25/2017
LB5900 Series Power Sensor
SPI & I2C Interface Guide

TABLE OF CONTENTS

PAGE 1

Advertisement

Table of Contents
loading

Summary of Contents for Ladybug LB5900 Series

  • Page 1: Table Of Contents

    LB5900 Series Power Sensor SPI & I2C Interface Guide TABLE OF CONTENTS TABLE OF CONTENTS ......................... 1 NOTICE ............................... 4 GENERAL ............................5 Sensor Power ..........................6 Data Line Electrical Specifications ....................6 Commands, Data Transmission & Reception................. 6 Sensor Reset and Communication Port Reset ................6 Wiring Diagram &...
  • Page 2 Electrical Data Connection and Addressing ................. 21 SPI Message Overview ......................... 22 SPI Clock Phase and Polarity ....................22 Sensor SPI Module Reset ......................22 Data format ..........................23 Command Header ........................ 23 Previous SPI communication status ..................23 Busyness ..........................24 Busy/Ready ..........................
  • Page 3 LIST OF FIGURES AND DIAGRAMS Figure 1 - Sensor, Cable & Mounting Bracket .................. 5 Figure 2 User Socket Connector Pin Out ................... 7 Figure 3 - I2C Device Address ......................8 Figure 4 - Typical I2C Connection ....................... 8 Figure 5 - Timing Diagram ........................
  • Page 4: Notice

    NOTICE Important Notice: LadyBug LB5900 Devices operating in SPI and I2C modes differ in several ways from traditional SPI & I2C devices. It is important to understand some of these differences to have a successful implementation of the system. Due to familiarity to memory and other chip based devices, the user may expect the response time to be the same after each request.
  • Page 5: General

    Using USB or other driver intense connectivity platform can interfere with timing and create startup issues. LadyBug LB5900 series sensors offer option SPI; the option enables sensor operation through SPI (Serial Peripheral Interface) or I2C (Inter-Integrated Circuit).
  • Page 6: Sensor Power

    Messages are transmitted to and received from the sensor using standard textual SCPI instructions and queries. Please refer to the Programming Guide For LadyBug True RMS Generation II Sensors for command details. Data is transmitted and received in full bytes (8-bits) using standard ASCII codes;...
  • Page 7: Wiring Diagram & Connector Pin Out

    The sensor’s cable is installed at the factory and is not removable or replaceable by the user. The cable extends 8” outside of the case, contact LadyBug for other options. The 10 wire ribbon cable exits the housing adjacent to the USB connector. 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.
  • Page 8: Using I2C

    LB5900 sensor is done using Pin 1 of the interface cable. Applying power (from Pin 6), selects I2C and disables SPI, grounding the pin will enable SPI and disable I2C. When using I2C, external pull-up resistors are required, refer to Figure 2. LadyBug’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.
  • Page 9: I2C Message Overview

    I2C Message Overview Commands with no required response can be sent with a single communication if the sensor is not busy. Queries require at least two communications, one to start a function, such as a measurement, then a second to read back the resultant data. After the request is made to the sensor, the master (user controller) is required to allow sufficient time for the sensor to process the function prior to requesting data.
  • Page 10: Sensor Busy & Nack

    transaction complete, a stop condition follows the NACK and completes the transaction. This resets the sensor’s I2C system preparing the sensor for a new I2C request. Sensor Busy & NACK The sensor may not be able to answer I2C requests when calculating measurements, processing non-volatile memory and possibly other functions.
  • Page 11: Data Format And Communications

    Data Format and Communications LadyBug sensors employ a standard I2C 7-bit addressing scheme with bits 0-6 as address and bit- 7, the eighth bit as a direction bit (R/W ̅ ). All messages begin by the user (master) issuing a standard I2C start condition and terminate with a standard I2C stop condition.
  • Page 12: The Address Byte

    Message content after the address is 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 below.
  • Page 13: The Status Byte

    The Status byte ●The status byte is used to determine if information such as a measurement is available/ready and possibly for other purposes. The status byte is returned as indicated in the command details. 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.
  • Page 14: Command Header

    Command Header ●Messages sent to the sensor contain a binary-formatted header containing four bytes that are sent immediately following the address byte. The first byte (Command Header) indicates how the message and any following I2C reads will be handled. For example, if the master (user controller) needs to read sensor status, the Command Header value of 06h should be written to the sensor;...
  • Page 15: Using Nack & Ack

    Using NACK & ACK Testing the sensor for an ACK should be done prior to sending any commands or queries. It is only necessary to send the address byte with the associated sensor number. A write with no data should be used, if a read is utilized and the sensor ACK’s indicating that it is ready, it will expect further data causing an error when it is not sent.
  • Page 16: 06H Send Command Plus Prepare Status & Length

    06h Send Command plus Prepare Status & Length ● This Command Header, 06h, sends the SCPI command that is included following the header. The command also causes the sensor to prepare the sensor’s status byte and the length of the data in the sensor’s buffer so that they can be returned.
  • Page 17: Figure 13 – Header 06H Used To Prepare Status & Length

    Example with no command (Prepare Status & Length): The controller may request the Status & Length of any available data anytime the sensor is in a ACK condition. This will indicate the sensor’s readiness and the number of bytes to be read in. Once the quantity of data is known, Header 0Ch Read Complete Output Buffer can be used to read in the data.
  • Page 18: Figure 14 - Read The Status And Length

    Example of Status and Length Read Back: ● Reading back the status byte and length (either with or without a command) 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.
  • Page 19: 0Ch Prepare Complete Output Buffer

    0Ch Prepare Complete Output Buffer ● This Command Header, 0Ch, causes the sensor to prepare to return the available data. The number of bytes requested must be the same as the number of bytes indicated in the preceding Read Status and Length sequence. The data is clocked in immediately following the complete 0Ch Command as indicated below in the Read Back section.
  • Page 20: I2C Measurement Example

    I2C Measurement Example ●The following example details the use of the READ? query to make a measurement. Read is often use programmatically because it establishes the beginning of the measurement when issued. If continuous triggering is active, FETCh? can be used to collect a “trailing” measurement. MEAS? may be inappropriate because the measurement time will vary due the use of automatic averaging.
  • Page 21: Using Spi

    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.
  • Page 22: Spi Message Overview

    SPI Clock Phase and Polarity LadyBug sensors utilizes full-duplex SPI communication. Clocking mode / phase is an accepted standard mode based on the clock’s polarity (CPOL) and phase (CPHA). The term phase indicates whether the bit-data is to be read on the leading or trailing edge of the clock;...
  • Page 23: Data Format

    line remains in the inactive state. Figure 19 - SPI Module Reset Data format SPI utilizes hardware sensor addressing. The first data sent to the sensor is the command header, described next. Command Header All commands sent to the sensor include a binary-formatted header preceding the SCPI command or data.
  • Page 24: Busyness

    The second byte returned with all command headers is the results of the last SPI communication. These codes indicated any errors associated with the communication, and are detailed in Figure SPI Error Codes Header No Errors Last communication was under clocked (not all data was received) Last communication was over clocked (Excess data was sent and ignored)
  • Page 25: Sensor Status Byte (Stb)

    sensor. Warning: The Sensor uses interrupts to process SPI communications; requests should be limited to less than one per millisecond. This will allow the sensor sufficient time to respond as well as process the commands. Sensor Status Byte (STB) Once Busy/Ready indicates the sensor is ready to process a command, the status byte can be utilized to determine if a measurement is complete.
  • Page 26: Command Header 06H - Read Status & Length

    Command Header 06h - Read Status & Length Figure 24 details the communications for Command Header 06h with an LB5900 sensor. Command Header 06h returns the Sensor Status and the length of any available data. The command is always be 6 bytes in total length, an error will result and be returned on the next commination if the length is not correct.
  • Page 27: Command Header F0H - Write Command

    Command Header F0h – Write Command Figure 25 details the communications for Command Header F0h with an LB5900 sensor. This Command Header is used to issue any command or query, such as FETCh?’ FREQ etc. The command does not implement reading back Query results, it simply issues the command. Results of any Query are read with Header 0Ch described later.
  • Page 28: Command Header 0Ch - Read Complete Output Buffer

    Command Header 0Ch – Read Complete Output Buffer ●After using Command Header 06h to determine that there is data and the length of the data, Command Header 0Ch is used to read back the data. Referring to Figure 26, the command reads the entire buffer which cannot be longer than 4095 bytes plus the terminator.
  • Page 29: Communication Examples

    Communication Examples The following examples detail communications between the User Controller and LB5900 sensor in SPI mode. The commands information is detailed in Hex data form in full bytes with bit data flow not shown. Please refer the SPI message information for bit flow, clocking and additional SPI enable information.
  • Page 30: Figure 27 - Command Details

    It is recommended that the returned data from byte 2, Previous SPI Transaction error be tested. E0h is expected if no errors were encountered. Refer to SPI message overview for details. Figure 27 - Command Details● As detailed in Figure 27, the command header is 4 bytes, the command header is shown in hexadecimal and is followed by the ASCII encoded message of 13 bytes including the space.
  • Page 31 To the sensor: F000000EFREQ 1020 MHZ00 At this point, a 1ms delay can be added or a “Read Status and Length” loop reading the status can utilized. For details on a “Read Status and Length” Loop refer to the READ? Command at the end of this section.
  • Page 32: Additional Spi Messaging Example

    Additional SPI Messaging Example ●The example below details byte by byte communications. All data is shown in Hex. ================================================================= ENTER COMMAND OR QUERY-->read? --> 06 00 00 00 00 00 READ STB AND LENGTH <-- 00 E0 00 00 00 00 READY SPI=E0 STB=00...
  • Page 33: Revisions & Updates

    REVISIONS & UPDATES Document Revision V2.3 No Notes Document Revision V2.4 Firmware: Added message length error test Firmware: Improved DCL and SPI module reset functions for SPI/I2C Document: Message length specified for SPI 0Ch messages. Page 27● Document: Detailed that concatenated messages are illegal in SPI/I2C Document: Added Information regarding SPI/I2C DCL and module resets Document: Added details to timing diagrams and text ●...

Table of Contents