4D LCD Interface With MyRIO

download 4D LCD Interface With MyRIO

of 16

description

from labview forum

Transcript of 4D LCD Interface With MyRIO

  • LCD Interface with myRIO

    Objective

    - Make user interface for myRIO

    - Send and receive string commands or results to/from proprietary software via serial

    communication

    - Make example VI for controlling meter object, controlling scope object and reading slider object

    on the LCD display

    Hardware List

    NI-myRIO

    SK-32PTU (Starter Kit)

    This item includes the following:

    - uLCD-32PTU Display Module

    - 2GB microSD Card

    - uUSB-PA5 Programming Adaptor

    - 150mm 5 way Female-Female jumper cable, for quick connection to another device

    or breadboard

    - 5 way Male-Male adaptor (for converting the Female-Female cable to be Male-

    Female)

    uUSB-PA5 Programming Adaptor

    Cable jumper

    Software List

    LabVIEW 2013 or later

    Labview Real Time 2013

    Labview FPGA 2013

    Labview myRIO Driver (Included in myRIO DVD 1)

    Workshop Genie 4.0

    Hardware Setup

    Debugging/Development Mode using PC

    Figure 1. Connection uLCD 32PTU to PC

  • Stand alone using NI myRIO

    4D Systems

    uLCD 32PTU

    NI myRIO Figure 2. Connection uLCD 32PTU to NI myRIO

  • Software Setup

    Installing Workshop Software

    Installing Workshop.

    1. Double-click WORKSHOP4 INSTALLER.4.1.0.28

    2. Click Next

    3. In License Agreement section, click I Agree.

    4. In Choose Install Location section, click Next. It will require around 310 MB harddisk space

    5. Select program folder, click Next

    6. In next section, click next to begin installation

    7. After the installation is completed, click Close.

    8. Youve now installed Workshop 4D Systems

  • Create user Interface in uLCD 32 PTU

    1. Open Workshop IDE

    2. Click New, choose product uLCD-32PTU

    3. uLCD 32PTU use only USB Programming Cable from 4D Systems. Be careful when using USB

    UART from another brand instead of 4D systems or warranty will be void.

    4. Choose environment, click ViSi Genie arrow. We will use ViSi Genie environment to create user

    interface in LCD

    5. We will create user interface in LCD consisting,

    a. 2 objects of Meter

    b. 2 objects of Slider

    c. 2 objects of Scopes

    As shown below,

  • 6. In ViSi Genie Environment, Click tab Gauges and click Meter icon, click on the blank LCD panel to

    place Meter icon on LCD

    Place all object as shown in picture step 5

    7. You can modify the properties of object in Workshop ViSi Genie. For example, you can set

    minimum and maximum value of Meter objects (default: minimum 0, maximum 100). In this

    documentation, we will leave all objects properties as default

    8. Save the Visi Genie Project

    Downloading project into SD card

  • 9. Prepare and insert SD Card from uLCD 32PTU into PC

    10. Click Build Copy/Load

    11. After finish build, it will ask which drive to use. Select the drive which uSD card is inserted

    12. Reinsert uSD card into uLCD 32PTU

    13. Turn on the LCD by connecting power supply 5V and ground to pin serial in LCD

    14. After turning on, you should see the display of meter that you build in ViSi Genie in the LCD

    screen

  • Debugging using workshop GTX

    We can check the command for controlling using GTX

    1. Connect uLCD 32PTU to PC using uUSB-PA5 Programming Adaptor as shown in figure 1

    2. Start Workshop and open file project which is used in uLCD

    3. Select Tools > GTX

    4. The display should shows control of objects we have created on this project,

    5. We can send the serial command to Set value to object or we can send serial command to

    Query to get the value of object.

    6. The command is represented as hexadecimal string. Once the command is sent, uLCd will

    response.

    Command from PC is represented in green, response from uLCD is represented in red

    7. We can see the change in uLCD hardware s we send the command

  • Development using Labview and NI-VISA

    Sending serial command from PC to uLCD 32PTU can be done by using Labview and NI VISA. Here is

    an example about how to write program to send command to Set meter value using NI VISA

    1. Serial command to uLCD 32PTU consists of several parameter , refer to documentation ViSi-

    Genie-Reference-Manual-REV1.pdf for more detailed command

    - Byte 1 : Command write

    - Byte 2 : Object ID

    - Byte 3 : Object Index

    - Byte 4 : MSB

    - Byte 5 : LSB

    - Byte 6 : Checksum CRC

    2. For meter write command, we can set byte 1 and byte 2 as a constant (0110)

    3. Byte 3,4,5 we can derive the value from parameter in control

    4. Checksum CRC is generated by calculating and XOR-ing byte 1 to byte 5

    5. The representation of byte in serial command is converted into hexadecimal string

    6. Use Visa Write function to send the command from PC to uLCD

    7. Use Visa Read function to read response drom uLCD.

    8. Use the same method for another object (Slider, scope) and save it as a subVI

    9. Open Interface4d project under LCD VISA folder. Open Main.vi

    10. When program below executes, it reads slider value, get the value and use the value for

    writing meter and writing scope

  • 11. Use VISA Configure Serial to set the configuration of serial setting and resource name

    12. Use Visa Close to end device session

    13. When the VI is running, we can control the meter and scope by moving the slider.

    Implementation in NI myRIO

    We will implement the serial command for uLCD 32PTU using myRIO. But we will use digital input

    output as port Tx and Rx in serial communication. Because we cannot use NI VISA, we will build

    serial communication protocol in myRIO FPGA connected to I/O digital input output.

    Installing Software in NI myRIO

    1. Ensure that the following software is installed in the NI myRIO:

    2. By default the software NI myRIO 13.0.1 is already installed. But in case of it is deleted because

    of formatted after previous use. You can find the software in NI myRIO CD

    Implement Serial Communication on Digital Input and Output of NI myRIO

    In this step, we will implement serial communication into FPGA into NI myRIO. Everytime we modify

    the FPGA vi we must synthesize the code into gated level code which stored in bitfile.

    14. Open RS232 LCD myRIO lvproj project file

  • 15. Right click NI myRIO and click Connect

    16. Verify the code which implemented in FPGA, click FPGA Target, and open FPGA Main block

    Diagram.

    We can see the Digital Input Output port used for serial Tx (DIO0) and Rx (DIO4). You can

    change for desired your settings.

    17. Expand Chassis (myRIO-1990) , click FPGA Target, open Build Specification

  • 18. Right Click FPGA Main, click Rebuild. Choose compile server, select Use the local compile

    server. Wait for Xilinx compiler to synthesize the gate level.

    19. The synthesized gate is saved into file image bitfile with extension *.lvbitx in FPGA bitfiles

    folder.

    Implement bitfile into Realtime VI

    We already made gated level configuration of FGPA into bitfile. We will implement this code in

    serial communication. As we know, the common function serial communication is

    - Serial Init

    - Serial Read

    - Serial Write

    - Serial Close

    The function is implemented in folder Real Time VI. And because we made change in FPGA code

    and made new FPGA bitfiles, we need to modify the FPGA reference on those real time VI. This

    step is

    20. Open LV Serial Init VI, double click FPGA Main terminal

  • 21. Choose Bitfile and browse the bitfile code we already made before, and click the bind FPGA

    host reference to type definition. And save it on FPGAref.ctl. save the VI

    22. Check all other VI (LV Serial Close, Read, Write) and see whether any broken wire.

    23. If there is any broken wire, use FPGA ref.ctl as a control of FPGA Interface in and as an

    indicator of FPGA Interface out

    Using Application to read Slider, write Meter and write Scope

    To read data from LCD and write data to LCD. The program is using serial communication. In this

    documentation, the command for reading slider object, writing meter object and writing scope

    object is presented. For specific command and more object command, refer to documentation ViSi-

    Genie-Reference-Manual-REV1.pdf

    Using Slider Read

    This VI is used for reading data.

    Input

    - FPGA Interface In : Input of FPGA reference

  • - Object Index : Object ID to differ several object

    - Error In : error cluster input

    Output

    - FPGA Interface Out : Output of FPGA reference

    - Value Read : Value read from slider in integer

    - Error Out : error cluster output

    Using Meter Read

    Input

    - FPGA Interface In : Input of FPGA reference

    - Object Index : Object ID to differ several object

    - Error In : error cluster input

    Output

    - FPGA Interface Out : Output of FPGA reference

    - Error Out : error cluster output

    Using Scope Write

    Input

    - FPGA Interface In : Input of FPGA reference

    - Object Index : Object ID to differ several object

    - Error In : error cluster input

    Output

  • - FPGA Interface Out : Output of FPGA reference

    - Error Out : error cluster output

    Guide to write application of specific object in LCD 32PTU

    1. Refer to Documentation Genie-Reference-Manual-REV1.pdf for command list of Visi Genie

    command.

    2. The VI of specific command of an object must consists of serial write part and serial read

    part

    Serial Write

    Serial Read

    - Command

    - Object ID

    - Parameter- CRC

    - Response

    3. Refer to this table (also available on Visi genie Documentation) for Serial write command

    4. The command is represented as Hexadecimal of String.

    5. Here is an example of application design of Slider Read.

    Command : 4 byte : 1x00 , 1x04 , 1 byte object index, 1 byte checksum CRC

    Response : 6 byte : 1x05, 1x10 , 1 byte MSB, 1 byte LSB , 1 byte checksum CRC

    6. Here is an example of application design of Meter Write

  • Command : 6 byte : 1x01 , 1x10 , 1 byte MSB , 1 byte LSB , 1 byte checksum CRC

    Response : 1 byte : 1x06 if success or 1x15 if fail

    Implementing application with Labview real time

    In this step, we will implement the VI in NI myRIO and use Labview in PC for debugging and

    development purpose.

    1. Setup the hardware configuration as shown in Hardware Section.

    Warning : Use only USB UART TTL of 4D system (TTL 0 5V) for connection. Dont connect it to serial

    port of external device (TTL 0 - > 12 V)

    2. Open file CheckSLiderMeter.vi

    3. This example shows the process of reading value in slide and then writing the value into

    Meter and Scope. You can modify the application, for example showing sinusoidal wave in

    Scope, or randomly generating number and show it in Meter objects.

    4. The serial setting of LCD 32PTU is as below,

    o Baud rate : 9600 bps

    o Data bits : 8

    o Parity : None

    o Stop bits : 1 bit

    o Invert Polarity : True

  • 5. Right Click on CheckSliderMeter and select Deploy

    6. Run the VI.

    7. Try to change the value of Slider in LCD, see what happen to Meter and Scope objects.The

    Meter and Scope should follow the movement of Slider.

    8. Click stop button in PC Front Panel to stop the program