|Description||This application note shows how to interface a 4D Systems intelligent display to the uCAM-II micro serial camera module. The attached project demonstrates navigation between forms, coding of touch detection routines for widgets, and serial communications.|
|Supported Processor||PICASO, DIABLO16|
This application note shows how to interface a 4D Systems intelligent display to the uCAM-II micro serial camera module. The attached project demonstrates navigation between forms, coding of touch detection routines for widgets, and serial communications. Below is a photo of the final output. Here the camera is focused on a stylus.
Before getting started, the following are required:
- Any of the following 4D Picaso display modules:
and other superseded modules which support the ViSi Genie environment
- The target module can also be a Diablo16 display
Visit www.4dsystems.com.au/products to see the latest display module products that use the Diablo16 processor.
- 4D Programming Cable / µUSB-PA5/uUSBPA5-II
for non-gen4 displays (uLCD-xxx)
- 4D Programming Cable & gen4-IB / 4D-UPA / gen4-PA
for gen4 displays (gen4-uLCD-xxx)
- micro-SD (µSD) memory card
- Workshop 4 IDE (installed according to the installation document)
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.
The uCAM-II (microCAM-II) is a highly integrated serial camera module which can be attached to any host system that requires a video camera or a JPEG compressed still camera for embedded imaging applications. The module uses a CMOS VGA colour sensor along with a JPEG compression chip that provides a low cost and low powered camera system. The module has an on-board serial interface (TTL) that is suitable for a direct connection to any host micro-controller UART or a PC system COM port. The uCAM-II is capable of outputting both RAW format and JPEG format images.
The application described in this document makes use of a uLCD-32PTU (Picaso display) to display images (RAW format only) captured by the uCAM-II. The images are transmitted serially from the uCAM-II to the uLCD-32PTU. The application has an interface for the user to be able to configure the image format, resolution, baud rate, and mode. Below is a simple diagram for the application. The display can also be a uLCD-35DT or a uLCD-70DT (Diablo16 display).
To learn how to test the uCAM-II using a utility in Workshop, refer to the application note Designer or ViSi uCAM-II Demo for Goldelox Displays.
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
Attached are zip files containing the ViSi demo projects. Choose accordingly.
For instructions on how to create a new ViSi project, please refer to the section “Create a New Project” of the application note
The program has two tasks – to handle graphics and to manage communication with the uCAM-II camera module. The task of handling graphics involves the process of displaying objects and defining their behaviour during touch detection. This part is discussed in the section “Writing the Code for a Form”. The task of communicating with the uCAM-II requires the addition of an include file at the start of the code. In this include file all the high level commands for talking to and listening from the uCAM-II are defined. These high level commands or functions are called when the appropriate button or object is touched. The following paragraphs provide further discussions.
The demo has an include file which contains the subroutines for communicating with the uCAM-II. This include file may be updated anytime. Check the application notes page section for the latest version.
To view the contents, put the cursor on the include file name text, then click on the right mouse button. Choose the first option, “Open file at Cursor”.
The file opens in another tab.
The code has been heavily commented to help the user. It can be easily edited for further improvement.
The general instructions below can be followed when writing the 4DGL code for a form that handles graphics and touch detection. The objective is to be able to display objects and control their behaviour when touched.
- Enable touch detection for objects that are meant to respond to touch
- Disable touch detection for objects that are not meant to respond to touch
- Set initial frames of objects then show the objects.
- Start touch detection routine.
- Define behaviour of objects when pressed.
- Define behaviour of objects when touch is released.
- Define behaviour of objects when touch is moving.
- Create an exit button to get out of the loop.
- Loop back to start of touch detection routine.
- Disable touch detection for all objects in the form before returning to main.
In Form1 of the project, Winbutton1 will display frame 1 (“down” state) when it is pressed. When a touch release is detected on Winbutton1, frame 0 will be displayed (“up” state). Also, the function sync_with_uCAM() is executed. This routine, which is defined in the include file “uCAM-IIserialCommsx.inc”, will perform synchronization with the uCAM-II. If the touch status is moving and if the touch point is not on Winbutton1, then frame 0 of Winbutton1 will be displayed. As more buttons are added to the form, the user will just have to define the behaviour for each button. The behaviour can also include calling a function or navigating to another form.
Attached is a PDF file that contains four flow charts. These flow charts illustrate the general flow of the program. These are intended as a learning guide only and are meant to be read along with the datasheet of the uCAM-II. Analysis of the details of how the flow charts are implemented in 4DGL is left as an exercise to the user.
For instructions on how to save a ViSi project, how to connect the target display to the PC, how to select the program destination, and how to compile and download a program, please refer to the section “Run the Program” of the application note
The uLCD-32PTU and uLCD-35DT display modules are commonly used as examples, but the procedure is the same for other displays.
For gen4 display modules, a break out board (gen4-PA/4D UPA) is needed to communicate with the uCAM module.
In PICASO, COM1 (RX and TX) is mapped to GPIO14 and GPIO15 of the gen4-PA board.
A uUSB-PA5 or a 4D USB programming cable can be used to power the display and the uCAM-II module. If using COM0 to talk to the uCAM-II, hook up the uUSB-PA5 to the programming header H2 of the display with the TX and RX pins disconnected.
If using COM1 to talk to the uCAM-II, connect the uUSB-PA5 to the programming header H2 of the display in the normal way. In this setup, the display can be programmed while it is connected to the uCAM-II module.
A breakout board (gen4-PA / 4D UPA) can be used to power the display and the uCAM-II module.
In the 4DGL code of the project, the constant uCAM_PORT determines the port to be used for talking to the uCAM-II.
When connecting to a Diablo16 display, note that the RX and TX pins for COM1 need to be mapped or assigned.
In the code above, the COM1 RX and TX pins are assigned to PA0 and PA1, respectively. Therefore, if the display is using COM1 to talk to the uCAM-II, the RX and TX pins of the uCAM-II need to be connected to PA1 and PA0. If using a uLCD-70DT for instance, the datasheet shows the pin configuration.
The uLCD-70DT and the uCAM-II can be powered using any of the two methods described in the previous section “Power Supply”. Note however that the USB ports of a laptop PC may not be able to provide enough current for the uLCD-70DT alone. Use a power hub instead.