Thales' cellular IoT products business is now part of Telit Cinterion, find out more.

You are here

Telit Cinterion IoT Developer Community

ConceptBoard: Java MultiADC

Tutorial, May 27, 2014 - 1:57pm, 8018 views

Concept Board: Java MultiADC
A quick example for using the Concept Board's ADC switch

Introduction

The library and demo application were created by student workers at the Gemalto M2M Application Engineering department in Berlin - first of all Roman Wedemeier.

Prerequisites

Hardware

• Concept Board connected to a Windows 7 PC

• Jumper cable

Software

• Eclipse Juno with MTJ installed

• Gemalto EHSx Software Development Kit

• MultiADC.java, AdcTest.java

Getting Started

Create a new project and import MultiADC.java and AdcTest.java. We will take a close look at the AdcTest class’s test routine:

  /**
	  * A simple test routine for the ADC and the ADC switch
	  * Iterates through the 4 ADC pins of the Concept Board and
	  * prints the values. 
	   */
	
	private void test() {
		int[] pins = {0,1,2,3};
		MultiADC multiAdc = null;
		
		try {
			multiAdc = new MultiADC("D2", pins);
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		int currentVal;
		System.out.println("Start\n");
		for (int i =0; i < pins.length;i++ ){
			currentVal = multiAdc.getValue(pins[i]);
			System.out.println("Pin: "+pins[i]+", Value: "+currentVal+"\n");
			System.out.println("--------------------------------------------");
			
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		
		try {
			multiAdc.release();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		System.out.println("End");
	} 

First we generate an array of the pin numbers we want to use (in this case 0 to 3).                                                         

Afterwards we create MultiADC from the co-processor's I2C address byte “D2” and array of pins. It is used for switch between multiple external ADCPins defined in pins

The for-loop from iterates through the pins and prints out the measured value which has been read by multiAdc.getValue(index).

In each iteration the applications sleeps for 1 second.

At the end of the application the multiAdc is closed by multiAdc.release().

Start test application

To start the test application connect the ADC pins as follows.

A0 to GND

A1 to 5V

A2 to 3.3V

Then start the application .

Your output should look like this:

Registering ip address "192.168.244.1" of remote debugging device...
Waiting for debug device registration of "IMP_NG_EHS5_REMOTE"...
Passing control to external device emulator...
Installing suite from: http://192.168.244.2:64590/AdcTester.jad

Start

Pin: 0, Value: 0

--------------------------------------------
Pin: 1, Value: 1144

--------------------------------------------
Pin: 2, Value: 793

--------------------------------------------
Pin: 3, Value: 0

--------------------------------------------
End

End of debug session. Emulator is closed!

Feel free to share your experience with the ADC and the test  Application :-)

Download File adctest.zip (zip | 3.59 KB)
Nice example! What in case the whole multiADC feature gets released? I can imagine that ADC is released, but is I2C selector also disabled so the control over ADC channels return to manual switch?
Hi, Via I2C you can release the ADC switch. So you can use the switches.

Very helpful.  Since we are using mutliple ADCs on the concept board, this is a great deal of help.  Except for my errors creating a new Midlet, it executed just as specified.

Roland

Roland

Hi,
I want to know if there is any way to connect a current sensor to the EHS6T LAN modem. The current sensor gives an analog value and the thing that I wanna do is convert this value to digital value. 

Ones I finished the convertion, I want to send the digital value to a specific phone number.

Should I use AT commands or java ??

Thanks for the help.

Author

Paul Mock's picture
Paul Mock