Facebook Pixel

AN-00075 ViSi Data Communication Over Zigbee

Description This application note is intended to demonstrating to the user the interconnection of the 4D Systems Diablo16 display module with a ZIGBEE personal area network module.
Supported Processor DIABLO16
Supported Environment ViSi
Difficulty Difficult

 

File Downloads
Files

Description

This application note is intended to demonstrating to the user the interconnection of the 4D Systems Diablo16 display module with a ZIGBEE personal area network module.

Before getting started, the following are required:

Visit www.4dsystems.com.au/products to see the latest display module products that use the Diablo16 processor.

When downloading an application note, a list of recommended application notes is shown. It is assumed that the user has read or has a working knowledge of the topics presented in these recommended application notes.

 

Application Overview

This application note is intended to demonstrating to the user the interconnection of the 4D Systems Diablo16 display module with a ZIGBEE personal area network module.

 

Setup Procedure

For instructions on how to launch Workshop 4, how to open a ViSi project, and how to change the target display, kindly refer to the section “Setup Procedure” of the application note

ViSi Getting Started - First Project for Picaso and Diablo16

 

Create a New Project

For instructions on how to create a new ViSi project, please refer to the section “Create a New Project” of the application note

ViSi Getting Started - First Project for Picaso and Diablo16

 

Design the Project

Wireless network technology have paved the way to a better way of interconnecting devices.  It has enabled reporting of data from a remote device to a central devices to other remote devices. Without the need of the physical interconnection between devices, this has brought about numerous applications. For this application project, a DRF1605H Zigbee was used. The module is based on TI's CC2530F256 chip running Zigbee.

The Zigbee module in this application project is based on a serial mode of communication. In particular, an asynchronous mode of serial communication is used. The DRF1605H is a module that has its connection pre-defined by the manufacturer. This means that connecting to it is simply straight forward.

The Diablo16 on the other hand is a very capable embedded graphics processor. It drives a touch capable display panel and is capable of communicating over several means of interconnectivity. For serial connection, the Diablo16 I/O pins can be configured and setup to a total of six connections. These serial connections are able to communicate over a wide range of pre-set baud rates but for this application project a 38400 baud rate was used. The baud rate was referenced to the default settings of the Zigbee module.

As mentioned from the previous statements, the interconnection between these two devices utilizes an asynchronous serial mode of communication. The data lines involved are the TRANSMIT and RECEIVE together with the positive and ground of connections of the power supply.

A good reminder at this point is that the power supply used for the Zigbee module is 3.3 volts. These conditions should be considered by the user in case other electronic parts are to be added to the system described in this application project.

 

Interconnections for the devices

For the Diablo16, the serial port one is used as the communication port for the Zigbee module. The later parts of this document will discuss the setup of the port used. There are several things to consider in using the Zigbee module with the display devices. For a perfectly working application the baud rate must first be considered, for this case a 38400 baud rate was used. Setting the baud rate for the Diablo16 would require functions and statements that are written in 4DGL language and DIABLO16 Internal functions. On the other hand, the baud rate for the Zigbee module must be configured using its own setup software. Secondly, consider the mode on which the system will operate.

 

The system may be configured to operate as a coordinator or as a router. Setting the mode of the Zigbee to a coordinator would result to the system being a master. Likewise, setting this module to a router would make the system a slave. For this application, the Diablo16 was setup to operate as a master and the slave device was made with another display module. This was done to demonstrate the flexibility of interconnectivity with the Zigbee modules of the 4D Systems displays.

 

Referring to the images, shown are the images of the DRF-1605H Zigbee module and its header pin-out.

 

The interconnection between the Diablo16 and the DRF1605H primarily involves the headers on J2 of the Zigbee module. Pins J2-4= RX, J2-3=TX, J2-11=GND and J2-12=3.3 Volts supply.  The table below shows the pin match up for the MASTER display device and the COORDINATOR Zigbee module.

 

 

DIABLO16

DRF-1605H

3.3 volt

J2 – 12

COM0 TX

J2 - 4

COM0 RX

J2 – 5

Gnd

J2 – 11

 

The connections for the slave is almost the same as the pin match up shown above except for the pins of the display module used. Since the slave device used is a uLCD-43PT, the pins to be used are shown below.

uLCD-43PT

DRF-1605H

3.3 volts

J2 – 12

COM0 TX

J2 - 4

COM0 RX

J2 – 5

Gnd

J2 – 11

 

Having been able to discuss the electrical connections between the devices, the next thing to consider is the data communication itself. Exchange of data in a Zigbee personal area network may follow several arrangements such that there would be several routers and a central coordinator. For this application project, the data communication was set to a transparent mode. In the transparent communication mode the data is simply interchanged between the master and a particular slave. The exchange of data between the two does not necessarily affect the communication of other routers to the coordinator.

 

The ViSi-based MASTER Application Project

For this project, the master display module was made to interact with the data sent by the slave. The master module is comprised of several forms which can be accessed by the slave module through strings that are sent over the wireless PAN.

 

After all the objects have been laid-out, let’s continue with the other half which involves the coding of the project. This will be presented in a sectional manner so as not to create confusion with the project. For an in-depth detail of the functions used in this application note please refer to the DIABLO16 Internal Functions Reference Manual.

 

The Include Section

This project starts with the identification of the platform being used as declared by the #platform function. For the program to be able to function properly files are included herein using the #inherit function.

Three other files are included automatically during creation of the new project, namely:  4DGL_16bitColours.fnc, the VisualConst.inc, and ControlConst.inc.  Notice that the last include file is almost the same as the project filename. This file is automatically generated as soon as project is saved.

 

The Main Program

The main program for this projects contains several sections: the initialization and the mounting of the micro-SD card, the initial displaying of the image objects, and a continuous repeat-forever loop.  The main loop detects data from the serial communications ports and processes the data received according to a set of if-conditions.

 

The micro-SD Initialization

Let’s start with the initialization of the uSD card. The uSD card contains all the image information about the objects used in the project. The object information and data are saved under a *.DAT and a *.GCI filename extension which is copied to the uSD during project compilation. Mounting of the disk in this application note was done using the following set of program statements.

 

Before the initialization of the microSD card, a pair of statements shown below sets the communication port zero to receive and transmit at a baud rate of 38400 with an initialized buffer named ‘_data’.

 

When starting a new project in the ViSi environment these set of statements are already included in the coding area. The last part of these set of statements uses a function file_LoadImageControl() to call on the object data/information files on the uSD drive. This initializes the data to be called in using the variable ‘hndl’.  In addition, the filenames for the dat and gci files are automatically changed to the project filename as soon as the project is saved.

Added to the statements above are the screen orientation setup function and the      touch enable function. The screen orientation is set to portrait thereby providing a 480x800 pixel dimension. This setup is attained using the gfx_Set() function.

Having been able to load and initialize the uSD drive, the processor is now able to access the information stored therein. As mentioned from the previous section, the filenames with an extension of DAT and GCI has the image data and information.  Therefore, the next part of the main program is to display all the objects that were placed on the Workshop IDE form viewer.

 

A special button from the Object Inspector can help reduce the time of coding of this part. The ‘Paste Code” simply pastes object code.

 

Displaying the Objects

In this part of the program, the img_Show() function simply calls out the object image and information found in the microSD drive.  This set of statements call out the images from their handlers and are displayed on screen. Observe the characters with the green font colours. This denotes the available object frame numbers available for the particular User Image object.

 

Note that there is a statement that added before the series of image show statements. The ‘again’ is a label for a ‘jump to location’ inside the main program. The use of this shall be shown in the succeeding section.

 

The Repeat-forever Loop

This section of the main program contains statements that are continually run by the processor.  For this project, the serial data is saved to the variable ‘n’.  The serial input serin() function is monitored using the if-condition statement. Whenever the result value on the variable n is not equal to -1, the data received is saved into the n.

 

There is a series of if-else conditional statement shown above. These conditions tests the values received and saved on the variable array rec_buffer. The values received herein is a set of hexadecimal values that are the equivalent of a string being sent from the slave module.

The if-else condition needs several conditions to call and execute a particular sub-routine. Considering the first condition on the statements shown above, if the received bytes are equivalent to the values starting from buffer index zero up to three it will direct the processor to jump to the address given by the label ‘again’. For the other if-else conditions, the content of the rec_buffer is compared to the

 

values and index position given in the program. If the values and index position are all the same as the reference then the subroutine statements is called and executed.

 

The ViSi-based SLAVE Application Project

The slave project includes a couple of winbutton that are setup to send out data over the serial communications port when pressed.

 

After all the objects have been laid-out, let’s continue with the other half which involves the coding of the project. This will be presented in a sectional manner so as not to create confusion with the project.

 

The Include Section

This project starts with the identification of the platform being used as declared by the #platform function. For the program to be able to function properly files are included herein using the #inherit function.  Three other files are included automatically during creation of the new project, namely:  4DGL_16bitColours.fnc, the VisualConst.inc, and slaveConst.inc.  Notice that the last include file is almost the same as the project filename. This file is automatically generated as soon as project is saved.

 

The Main Program

The main program for this projects contains several sections: the initialization and the mounting of the micro-SD card, the initial displaying of the image objects, and a continuous repeat-forever loop that is related to the touch status of the button objects.

 

The micro-SD Initialization

Let’s start with the initialization of the uSD card. The uSD card contains all the image information about the objects used in the project. The object information and data are saved under a *.DAT and a *.GCI filename extension which is copied to the uSD during project compilation. Mounting of the disk in this application note was done using the following set of program statements.

 

Before the statements that detect and initialize the microSD, a statement using the touch_Set() function enables the touch function. Another statement sets the screen orientation and the last one configures the baud rate that will be used for the com0 communications port.

 

Displaying the Objects

In this part of the program, the img_Show() function simply calls out the object image and information found in the microSD drive.  This set of statements call out the images from their handlers and are displayed on screen. Observe the characters with the green font colours. This denotes the available object frame numbers available for the particular User Image object.

 

Setting of the touch feature for an image requires the function Img_Clearattributes(). This function allows the touch detection on the images.  The result of the touch on the images is saved on a variable in the repeat-forever loop.

 

The Repeat-forever Loop

This section of the main program contains statements that are continually run by the processor.  For this project, the serial data is saved to the variable ‘n’.  The serial input serin() function is monitored using the if-condition statement. Whenever the result value on the variable n is not equal to -1, the data received is saved into the n.

 

Following the detection of a touch action on the image, a set of if-conditions process the status of the touch panel. The touch panel is checked for two conditions – a press over an image or a touch released on an image.

 

If a touch pressed is detected, the next is to determine which image was touched. After both conditions are satisfied, a couple of statements are executed. The first statements that are executed are related to images simply changes the image index state of the button object. The last statements includes a to() and print() function pair, send out a string to the serial communications port. These strings are the data being received by the master module and processed.

Another touch related condition is the ‘touch_released’ condition. After a touch is detected on the screen, this conditional loop detects the release part of the process. The sole purpose of this if conditional loop is to return the button’s image index to zero.  The transitions that occur during the touch and the release results to a simple animation that shows images being pressed and released.

 

Running the Program

For instructions on how to save a ViSi project, how to connect the target display to the PC, how to select the program destination (this option is not available for Goldelox displays), and how to compile and download a program, please refer to the section “Run the Program” of the application note

ViSi Getting Started - First Project for Picaso and Diablo16

 

The uLCD-32PTU and uLCD-35DT display modules are commonly used as examples, but the procedure is the same for other displays.

 

Share: