Professional Documents
Culture Documents
4D SYSTEMS
4D-AN-P5003
Description
Content
Page 2 of 15
Description ............................................................................................. 2
Content .................................................................................................. 2
Application Overview.............................................................................. 3
Configure the Display as a Serial Slave ..................................................... 4
Program the Arduino Host....................................................................... 4
Understanding the Arduino Demo Sketch.......................................... 4
Open a Serial Port and Set the Baud Rate ......................................... 4
Reset the Arduino Host and the Display ............................................ 5
Let the Display Start Up.................................................................... 5
Clear the Screen ............................................................................... 6
The Command Bytes
Send a String.................................................................................... 8
The Command Bytes
8
www.4dsystems.com.au
4D SYSTEMS
The Null Byte
4D-AN-P5003
9
Application Overview
2013 4D Systems
This application note does not make use of the Arduino-Picaso Serial
Library. Instead it deals directly with the low level serial data bytes. The
objective is to demonstrate the basics of implementing the Serial Protocol
as described in the Picaso Serial Command Set Reference Manual. Users
who intend to create their own libraries (in C) for interfacing a 4D display
serial slave device to other host controllers may use this application note
as a reference. Likewise, users who wish to start looking inside the
Arduino-Picaso Serial Library may find the sketch in this application note
useful. In the end, before the sketch gets very complicated and explaining
gets even more difficult, the user is now directed to the document 4D-ANP5004 Serial Connecting a 4D Display to an Arduino Host using a Library,
which explains the use of the Arduino-Picaso Serial Library.
Page 3 of 15
www.4dsystems.com.au
4D SYSTEMS
4D-AN-P5003
In the function setup( ), port Serial0 is set to communicate with the display
module at 9600 bps.
Logically, the 4D display should also communicate with the Arduino host at
the same baud rate. To check the baud rate of the display module check
the baud rate indicated on the Serial Platform Environment (SPE)
application splash screen.
2013 4D Systems
Page 4 of 15
Comms 9600
www.4dsystems.com.au
4D SYSTEMS
4D-AN-P5003
Note that the GPIO pin D4 of the Arduino host is used here for resetting
the display. When using the new 4D Arduino Adaptor Shield (Rev 2.00
written on the PCB), simply connect RES to AR in jumper J1. See the section
Connect the 4D Display Module to the Arduino Host. If using the old 4D
Arduino Adaptor Shield (Rev 1), simply change the code above. Use pin 2
instead of pin 4.
Note that the logic state for resetting the display is now 0 instead of 1. This
is because the display modules RESET pin is directly connected to D4 via a
1kohm resistor. If using a 4D Arduino Adaptor Shield, the display modules
RESET pin is switched by the D4 pin via a transistor.
Note that on section 2.5 Power-Up and Reset of the Picaso Serial
Command Set Reference Manual it says:
If using jumper connecting wires, connect the RESET pin of the display
module to the D4 pin of the Arduino with a 1kohm series resistor in
between (see the section Connect the 4D Display Module to the Arduino
Host), and modify the code as shown below.
2013 4D Systems
Page 5 of 15
www.4dsystems.com.au
4D SYSTEMS
4D-AN-P5003
The purpose of this routine is to wait for the ACK byte from the display
module. A time limit must therefore be defined.
Set the Time Limit
The while loop below will execute while nothing is received from the
display yet and the waiting time has not yet exceeded the specified time
limit.
This now explains the need for the following lines in the code:
2013 4D Systems
Page 6 of 15
www.4dsystems.com.au
4D SYSTEMS
4D-AN-P5003
When using the Serial Commander, the user has also the option of setting
the time limit.
and evaluated if it is equal to the ACK byte. The variable Error4D is then set
depending on the results and its value returned to the main function.
2013 4D Systems
Page 7 of 15
www.4dsystems.com.au
4D SYSTEMS
4D-AN-P5003
Note that mycallback ( ) will only blink the LED at pin 13 indefinitely. The
user may also use this function to reset the display and re-establish
communications. When an error occurs, it would be improper for the
program to proceed further without resetting the display. Again,
Commands should only be sent and their response
received, before another command is sent. If two
commands are sent before the first response is
received, incorrect operation may follow.
Draw a Line
Send a String
Section 5.2.5 Draw Line of the Picaso Serial Command Set Reference
Manual describes in detail the command for drawing a line on the screen.
Section 5.1.2 Put String of the Picaso Serial Command Set Reference
Manual describes in detail the command for printing a string on the
display.
2013 4D Systems
Page 8 of 15
www.4dsystems.com.au
4D SYSTEMS
4D-AN-P5003
2013 4D Systems
Page 9 of 15
www.4dsystems.com.au
4D SYSTEMS
4D-AN-P5003
The display module should now display the string length in hex.
Jumpers
2013 4D Systems
Page 10 of 15
www.4dsystems.com.au
4D SYSTEMS
4D-AN-P5003
To reset the display using the D4 pin of the Arduino and to power the
display from the Arduino host, set jumpers J1 and J2 as shown below.
and the Arduino host. Refer to the display modules datasheet for the
specified supply current.
Using the USB cable:
To the right are images of a complete setup wherein the display module
and the Arduino host have a common power supply. Note that the power
supply must be able to provide enough current for both the display module
2013 4D Systems
Page 11 of 15
www.4dsystems.com.au
4D SYSTEMS
4D-AN-P5003
2013 4D Systems
Complete setup:
Note that the display module cannot be programmed thru the USB-PA5 in
this setup since H2 transfers power only. Before programming the display
module, disconnect it first from the Arduino Adaptor Shield. Likewise,
before programming the Arduino, make sure that it is not connected to the
display module. Do this only when the Arduino host and the 4D display
communicate thru Serial0. Always double check the orientation of the
connectors.
Page 12 of 15
www.4dsystems.com.au
4D SYSTEMS
2013 4D Systems
4D-AN-P5003
Page 13 of 15
www.4dsystems.com.au
4D SYSTEMS
2013 4D Systems
4D-AN-P5003
Page 14 of 15
www.4dsystems.com.au
4D SYSTEMS
4D-AN-P5003
Proprietary Information
The information contained in this document is the property of 4D Systems Pty. Ltd. and may be the subject of patents pending or granted, and must not be
copied or disclosed without prior written permission.
4D Systems endeavours to ensure that the information in this document is correct and fairly stated but does not accept liability for any error or omission. The
development of 4D Systems products and services is continuous and published information may not be up to date. It is importan t to check the current
position with 4D Systems.
All trademarks belong to their respective owners and are recognised and acknowledged.
2013 4D Systems
Page 15 of 15
www.4dsystems.com.au