Get started with AVIDdirector 200 and I2C

4 views
Skip to first unread message

nicher

unread,
May 29, 2008, 5:12:12 AM5/29/08
to AVIDdirector-M2M
Hello everyone,

Our university has bought two AVIDdirector M2M Model 200 inclusive an
expansion module, a jumpstart board, GPRS, WiFi, Bluetooth and
Ethernet. We would like to connect an I2C-pressure sensor to this
system, but I don't know how to get started.

Has anyone some information, how to connect the pressure sensor to the
AVIDdirector? Furthermore, I need some information how to develop an
I2C-application. The pressure sensor listen on address 0x78. Can
anyone give me a small programm which writes and reads some bytes to
resp. from the I2C-bus?

Thanks a lot,
Nico

Rod Montrose[AVIDwireless]

unread,
May 29, 2008, 11:40:59 AM5/29/08
to AVIDdirector-M2M
Look in the M2M_IO.java source code - there's an example of reading
the on board temperature I2C sensor on the device. Its in the method
readBoardTemperature(). This uses the PSoC I2C functions direction
(Function 0x21) to access the I2C bus.

The I2C commands are written using byte arrays containing the commands
to write to the bus:

/** First a write to set the address inside the temp chip that we are
interested
* in. Note that the address of the temp sensor is 0x48--funny
coincidence
* that the PSoC I2C function is 0x48 also. The actual transmission to
the I2C
* bus is shifted left one and the read/write bit appended on at bit 0
to get a
* 90 (write) or 91 (read) as shown in the temp sensor data sheet. 21
is the
* control byte, which is a write of one byte with no stop. The byte
written
* is 0, which sets up the subsequent read to access the current
temperature
* register.
*/
private static byte[] initializeTCM75 = {0x48, 0x21, 0x48, 0x0};

/**
* Now a read from the register specified in the write. The 92 means
a read of
* two characters, continuing an operation done previously without a
stop.
*/
private static byte[] readTCM75temperature = {0x48, (byte)0x92, 0x48};


The code is:

// Initialize the temperature sensor to read the temperature
Hardware_API.PSoC_WrtReadByteArray(initializeTCM75, null);

// Then start the read operation to get the temperature
Hardware_API.PSoC_WrtReadByteArray(readTCM75temperature, null);

// And Perform the read operation and end the I2C operation
byte [] temperatureData = new byte[2];
int retryCounter = 0;
int returnDataLength = 0;
short status;
do {
status = Hardware_API.PSoC_ReadI2CData(temperatureData);
returnDataLength = status & 0x0f;
if (returnDataLength == 2) {
/* The temperature value is 9 bits long.
The status is 52, which is no errors having received two bytes. The
value
returned is 26 80, which after shifting around as shown in the data
sheet is
4D or 77. Each count is worth 0.5 deg C., so this is 38.5 deg c. */
int rawTemp = AvidUtil.byteArrayToInt(temperatureData, 0,
temperatureData.length);
int temp = rawTemp >> 7;
if (temp > 255) temp = 512 - temp; // perform twos compliment
temperature = ((float)temp) / 2.0f;
if (Logger.isDebug())
Logger.debugln("M2M_IO.readBoardTemperature","Temp = "+
temperature+" C (raw = "+temp+";"+rawTemp+" "+
AvidUtil.getByteArrayAsHexString(temperatureData,
0,temperatureData.length,',')+
" status="+AvidUtil.getUnsignedByteAsHexString(status)
+":"+retryCounter+")");
} else {
AvidUtil.waitHereMs(10);
retryCounter++;
}
} while ((returnDataLength == 0) && (retryCounter < 200));
if (returnDataLength == 0) throw new RuntimeException ("No data
returned from TCN75.
Status="+AvidUtil.getUnsignedByteAsHexString(status));



nicher

unread,
May 30, 2008, 9:18:20 AM5/30/08
to AVIDdirector-M2M
Hello Rod,

first thank you for your answer, but on which external pins can I
connect my i2c pressure sensor? We have bought an expansion module and
a jumpstart board.

Rod Montrose[AVIDwireless]

unread,
May 30, 2008, 1:08:35 PM5/30/08
to AVIDdirector-M2M
The I2C lines are available on the DB-37 connector:

25 I2C_SCL P1_7 I2C Serial Clock, Digital In/Out
26 I2C_SDA P1_5 I2C Serial Data, Digital In/Out

http://groups.google.com/group/aviddirector-m2m/web/model-200-db-37-expansion-i-o-connector

The Google Group page "How to Test a Jumpstart board" contains the
schematic and layout of the Jumpstart board you have.

http://groups.google.com/group/aviddirector-m2m/web/how-to-test-a-jumpstart-board

J5 and J3 (the Expansion connector) provide access to the I2C lines.
J3 was designed to allow quick prototyping of "Stamp" size I/O
adapters. The I/O Expansion board you have has the same layout as J3
and also provides access to the I2C pins on J5. The Expansion I/O
board is documented in the DB-37 Tech Note web page.

-- Rod

nicher

unread,
Jun 2, 2008, 6:48:19 AM6/2/08
to AVIDdirector-M2M
Hi Rod,

sorry but I don't find any information about the
readBoardTemperature()-method in the M2M_IO-file. Is it possible to
send me the complete file? Furthermore, you wrote that I must connect
the I2C pressure sensor to the lines 25 and 26, but which pinch cock
pins are that?

Nico

Rod Montrose

unread,
Jun 2, 2008, 1:33:34 PM6/2/08
to aviddire...@googlegroups.com
I don't know how well Google groups will handle this attachment.

Ensure you have PSoC software 2.15 or later on your device. The 'ver'
command will verify this:

root > ver
AVIDdirector-M2M Ver: AVIDdirector-M2M 1.8.4.0
ADM2MLib Ver 1.8.5.0(14.20.21.1.15.19.1) 2/07/08 5:41p File Date: 2/11/2008
5:01:14PM
M2MApp Ver 1.8.5.0(29.2.14.32.25) 2/06/08 10:08p File Date: 2/11/2008
10:53:33AM
PSoC Firmware Ver: 2.15
Imsys SNAP Ver: SNAP 1.0.9 (AVIDdirector-M2M 1.8.6)
Baseconfig Ver: Baseconfig 1.0.8 (AVIDdirector-M2M)
/system/snap.jar File Date: 2/11/2008 10:49:03AM Size: 117347
/system/snap.gpx File Date: 5/29/2008 3:39:39PM Size: 721932
Memory: Heap free: 836972/943712 SNAP RAM free: 5583928/8388608 Flash
free: 1390592/3473408

The 'PSoC Firmware Ver: 2.15' line lists this. If you have this you should
be able to do "m2m_io -t" to read the on board temperature

/root > m2mio -t
-t : Board temperatures = 28.5 C 83.3 F

Pins 25 and 26 refer to the DB-37 connector shown on page:

http://groups.google.com/group/aviddirector-m2m/web/model-200-db-37-expansio
n-i-o-connector

--- Rod Montrose

============================================
AVIDwirelessR
Empowering Critical Decisions - Anywhere, AnytimeT
Email: r...@avidwireless.com
Web: www.avidwireless.com


M2M_IO.java

nicher

unread,
Jun 4, 2008, 8:07:57 AM6/4/08
to AVIDdirector-M2M
Hi Rod,

I am sorry again, but the I2C bus access methods
Hardware_API.PSoC_WrtReadByteArray(initializeTCM75, null); and
PSoC_ReadI2CData(temperatureData) don't exists.

I downloaded the last AVIDwireless installer version 1.7.6.1 from the
Google Groups site. Furthermore, I didn't find any information about
these methods in the javadoc.

Thanks,
Nico

The PoSC version is 2.15.

nicher

unread,
Jun 23, 2008, 12:37:55 AM6/23/08
to AVIDdirector-M2M
Hi,

I still search for the
Hardware_API.PSoC_WrtReadByteArray(initializeTCM75, null); and
PSoC_ReadI2CData(temperatureData) methods. Does anyone know how to
work with AVIDirector and I2C?

Thanks,
Nico

nicher

unread,
Jul 17, 2008, 3:52:00 AM7/17/08
to AVIDdirector-M2M
Hi @all,

I found the problem ;-). The actual download file for starting
developing are not up to date which you can receive from this site.
The lib files ADM2MLib.jar and M2MApp.jar are to old for my
AVIDdirector Model 200, because they don't support the functions
Hardware_API.PSoC_WrtReadByteArray(initializeTCM75, null) and
PSoC_ReadI2CData(temperatureData) to write and read from the i2c
lines.

But I wondered, because the command "m2mio -t" which was posted by Rod
executes correctly. The result was the correct temperature on the
board. But as I loaded the example from Rod (see above) into Eclipse
the tow functions were highlighted red (it means there are errors).

The solution of this problem is, to copy the two JAR-files from the
microsystem to the computer and using this for developments.

But now I have some next questions.

What does each byte mean which is writen on the bus lines?

private static byte[] initializeSensor = { 0x48, 0x21, 0x48, 0x0 };
private static byte[] readSensorValue = { 0x48, (byte) 0x92, 0x48 };

How can I write this values (0x78 and 0x12) to the I2C bus line in own
step? The first byte is the address of my pressure sensor and the next
byte is the command which tells the pressure sensor to send the actual
pressure over the bus lines.

Thanks for help,
Nico
Reply all
Reply to author
Forward
0 new messages