problem reading I2C device
problem reading I2C device
problem reading I2C device
problem reading I2C device
problem reading I2C device
problem reading I2C device problem reading I2C device problem reading I2C device problem reading I2C device problem reading I2C device problem reading I2C device problem reading I2C device problem reading I2C device
problem reading I2C device problem reading I2C device
problem reading I2C device
Go Back  Xtreme Visual Basic Talk > > > problem reading I2C device


Reply
 
Thread Tools Display Modes
  #1  
Old 06-16-2010, 03:44 AM
akatsuki akatsuki is offline
Newcomer
 
Join Date: Apr 2008
Posts: 3
Question problem reading I2C device


I'm currently working on an I2C slave device - voltage monitor. The problem is I

need to configure first the device to read per channel. I'm using a Diolan dongle

as I2C master (http://www.diolan.com/i2c/doc/u2c_12_manual.0.2.0.pdf).

I have done this successfully using their custom software. I'm also calling the

API in my code.

Btw, I'm using ADS7828 chip (http://focus.ti.com/lit/ds/symlink/ads7828.pdf).

Here's the code:

Dim pMemoryAddress As U2C_LONG
Dim pBufferLength As U2C_WORD
Dim pTransaction As U2C_TRANSACTION

pTransaction.nSlaveDeviceAddress = &H4B 'IC voltage mon address
pTransaction.nMemoryAddressLength = 0
pTransaction.nMemoryAddress = pMemoryAddress 'all zero
pTransaction.nBufferLength = pBufferLength '2
pTransaction.Buffer(0) = &H23 'the channel in hex. I think I need to write this.

varvar = U2C_Write(hDevice, pTransaction)
varvar = U2C_Read(hDevice, pTransaction)

but im getting values like 3-5 (im expecting some large values or a hex).

Here's what I should get:
device address in hex: 8C
reading in hex: 0AD6 = 2774 (decimal)

Thanks for your help.
mark
Reply With Quote
  #2  
Old 06-16-2010, 08:20 AM
mkaras's Avatar
mkarasproblem reading I2C device mkaras is offline
Ultimate Contributor

Retired Leader
* Expert *
 
Join Date: Mar 2004
Location: Beaverton, OR
Posts: 1,874
Default

You probably need to call more API functions from your VB code than just the U2C_Write() and U2C_Read() routines.

When I quickly scanned the chapter 3 API function list I can see that you will also need to call and use functions including:
U2C_OpenDevice()
U2C_CloseDevice()
U2C_SetI2cFreq()
U2C_SetClockSynch()
U2C_SetClockSynchTimeout()

Use of the standard "app" (the Dolan Control Panel program) probably hides the use of these functions from the user. However when you replace the Control Program with your own software you need to provide the control structure around opening the device and setting up the I2C interface properly.

It also may be that the generic U2C_Write() and U2C_Read() routines will not work the ADS77828. This device requires a specific prototcol to be used to select the device, configure the channel selection and setup the A/D converter for making the conversion. The high level Read/Write routines may not permit the proper handshake sequence to be synthesized for communication with the converter. In this case you may have to resort to building up the proper protocol using the lower level routines including the following:

U2C_Start()
U2C_RepeatedStart()
U2C_Stop()
U2C_PutByte()
U2C_GetByte()
U2C_PutByteWithAck()
U2C_GetByteWithAck()
U2C_PutAck()
U2C_GetAck()

If you were able to communicate to the A/D converter with their ControlPanel program using the I2cRead and I2cWrite tool bars then you may have success using the higher level commands. Otherwise you'll have to resort to the lower level commands. Pay particular attention to the full protocol interface description for the device in Figure 3 of the data sheet.

When you start using the device and getting numbers back you should concentrate on validating the readings by setting the input to the A/D converter at voltage levels that should give you a 0x000 reading or a 0xFFF reading. This will allow you to gain confidence that you are successfully talking to the device. Another technique is to tie an input to the voltage reference output and read that channel for sanity check.

In your posting you made inference that you may be expecting back a HEX value or a decimal value. Please be aware that the numbers you get back from the A/D converter will be strings of bits (binary bits to be exact). How these bits are comprehended, grouped and formatted will determine how they are presented for people consumption. Do not get confused, like some beginners do, where you expect the device interface is passing back some text of the readings already in human readable format. Some devices you use may offer an ascii text based inteface but not this A/D converter.

You did not mention whether you built your own hardware for this A/D converter or are using some purchased module. Either way be sure to take heed of the notes in the data sheet regarding how successful application of this device requires much care in the circuit design and layout. The power supplies and reference are also going to take due diligence to ensure a satisfactorily functioning system. Also be aware that as with any sampled A/D measurement system (but not really covered in the data sheet) you may need to provide additional circuitry at the inputs to the A/D converter. Some reasons for this include:
- Providing low pass antialiasing filtering if the input signal has frequency components nearing half of your sampling frequency.
- Providing for a low impedance source to the A/D input. Connecting the A/D input into a circuit that has too high of impedance relative to the A/D input impedance will alter the readings you achieve from what is actually meant to be happening in the circuit.
- Providing for proper scaling of the input voltage to the A/D. This part converts voltages at the inputs which are constrained to be within the 0 to VDD range with conversions of reading between 0 to VREF. If you are trying to read voltages outside this range appropriate scaling and buffering circuitry will be needed. Opamps may be needed based upon the source impedance of the signals you are measuring.

Michael Karas
Reply With Quote
  #3  
Old 06-16-2010, 08:12 PM
akatsuki akatsuki is offline
Newcomer
 
Join Date: Apr 2008
Posts: 3
Cool

Hi Michael,

Thanks for your this very useful advice. Just to let you know, I have already called the basic APIs for opening and initializing the master device before doing the read/write function. I also tested it for another slave (a temp monitor) and the read function is working fine, since this one doesn't require some special config to do. Yes, I have already used their ControlPanel program and I am getting the desired reading using the Read and Write functions (assuming its calling the high level commands). I have also verified this versus the actual voltages going to the channels. Overall, I'm confident on the hardware. I may need to resort on the lower level commands later, will let you know of the progress. Btw, I think there's a sample code for the .net version to do this, but I don't have the tool to open it atm

br,
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
problem reading I2C device
problem reading I2C device
problem reading I2C device problem reading I2C device
problem reading I2C device
problem reading I2C device
problem reading I2C device problem reading I2C device problem reading I2C device problem reading I2C device problem reading I2C device problem reading I2C device problem reading I2C device
problem reading I2C device
problem reading I2C device
 
problem reading I2C device
problem reading I2C device
 
-->