|Description||This Application Note shows how to use the analog input of the Goldelox processor.|
|Supported Environment||Designer, ViSi|
This Application Note shows how to use the analog input of the Goldelox processor.
Before getting started, the following are required:
- Any of the following 4D Goldelox display modules:
or any superseded module that supports the Designer environment
- 4D Programming Cable or µUSB-PA5
- Workshop 4 IDE (installed according to the installation document)
- uCAM-II serial camera module
- A 10-kiloohm potentiometer
- Multi-switch joystick (see page 5 for the schematic diagram).
- 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.
- This application note requires that the reader has a basic knowledge of any programming language such as C.
The IO1 pin of the Goldelox display can be programmed as an A/D input. Option is available to select 8 bit or 10 bit resolution. The voltage reference or the highest voltage that can be read by the IO1 pin is 3.3 volts. The diagram below is a circuit of a Light Dependent Resistor (LDR) connected to IO1 to measure and record changes in ambient light. This diagram illustrates one way to utilize the analog input of the Goldelox display.
The application described in this document makes use of a variable resistor as a voltage divider, the output of which is connected to the IO1 pin of a uOLED-128-G2.
Pin IO1 is then configured as an analog input and the readings are shown on the screen. The application also shows how the joystick() function is used, which is essentially an ADC process as well.
For instructions on how to launch Workshop 4, how to open a Designer project, and how to change the target display, kindly refer to the section “Setup Procedure” of the application note
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
For instructions on how to create a new Designer project, please refer to the section “Create a New Project” of the application note
For instructions on how to create a new ViSi project, please refer to the section “Create a New Project” of the application note
To configure the IO1 pin for ADC, user either one of the two following functions.
The first line configures the IO1 pin for 8-bit resolution ADC, the second for 10-bit resolution ADC.
To read the analog value of pin IO1,
For 8-bit resolution ADC, the pin_Read() function returns a value between 0 and 255. For 10-bit resolution, the pin_Read() function returns a value between 0 and 1023.
The Joystick is essentially a five-position multiswitch. Each position connects to a junction of a resistor ladder network that forms a voltage divider. The output of the joystick voltage divider connects directly to the IO1 pin of the Goldelox display module. Utilising the analog-to-digital-conversion feature of Goldelox displays, each individual switch position voltage value can be read and decoded. Below is the schematic diagram for the joystick.
Note that the circuit can also be implemented using tactile switches and resistors.
To use the joystick function, first declare a variable to hold an integer value.
This variable will hold the return value of the function joystick().
Put the cursor on the function name and either press F1 or right click on the mouse. For the latter, a pop-up menu will appear. Choose the last option, “Context Sensitive help”.
The Goldelox Internal Functions Reference Manual will open, if it has not been opened yet. Section 2.1.5 Joystick gives the following information.
IF statements can be used to evaluate the current status of the joystick.
The block can also be coded as:
For instructions on how to save a Designer 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
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
The uLCD-32PTU, uLCD-35DT, uOLED-96-G2, and/or uOLED-160-G2 display modules are commonly used as examples, but the procedure is the same for other displays.
The programming module (4D USB programming cable or uUSB-PA5) can be used to power the display.
Don’t forget the common ground connections.
The variable resistor is a 10-kiloohm potentiometer.
Here the display is placed on a development board which has a joystick. Note that aside from using the joystick function, the attached project also displays the analog readings of the IO1 pin. In the image below, the joystick is idle or in the “RELEASED” state. The analog reading is 255 (refer to the schematic for the joystick).
When the joystick is pressed, the state and analog reading are printed.
Below is the image when the state is“DOWN”.
Below are images of a setup using a 10-kiloohm potentiometer.