I2C vs SMB : whats wrong?

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
MJU
Posts: 502
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 121 times
Been thanked: 108 times
Contact:

I2C vs SMB : whats wrong?

Post by MJU »

I have a sensor connected onto a Arduino Uno.

When I use the Arduino sketch the sensor works and returns data.
Smart as I am (??), I watched the SMB data from the Arduino with a logic analyser and try to copy the commands into Flowcode.
I use the I2C component with the option "Enable SMB" but the sensor doesn't give me an ACK...

Here is what I get returned after a START, ADDRESS/Write
I2C1.jpg
Arduino generated data: "Start - Address/Write" and an ACK..
(133.92 KiB) Downloaded 1444 times
Here is what the Arduino sketch returns...
I2C2.jpg
Flowcode generated data: "Start - Address/Write" and no Ack
(135.12 KiB) Downloaded 1444 times
Except from the small timing differences I see no difference.
How is it that the Flowcode generated code doesn't get an acknowledge?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: I2C vs SMB : whats wrong?

Post by Benj »

Hmm, Looks ok to me too.

Not sure what to suggest on this one?

The signal that acks has the data changing on the falling clock edge whereas the other seems to occasionally change in between the falling and rising edge.

MJU
Posts: 502
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 121 times
Been thanked: 108 times
Contact:

Re: I2C vs SMB : whats wrong?

Post by MJU »

Benj wrote:Hmm, Looks ok to me too.

Not sure what to suggest on this one?

The signal that acks has the data changing on the falling clock edge whereas the other seems to occasionally change in between the falling and rising edge.
And the NACK version is the Flowcode version..
Could it be that there is something wrong with the Flowcode I2C component?

The only difference between I2C and SMB is the timing of the ACK's?

MJU
Posts: 502
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 121 times
Been thanked: 108 times
Contact:

Re: I2C vs SMB : whats wrong?

Post by MJU »

I'm confused..

When I use the "SendByte Transaction" and I give the address : 0x5A it returns an ACK.
So the macro shifts the 0x5A and adds a 0 to complete the write request.
The sensor returns an ACK!

When I look at the data on my logic analyser I see that Flowcode sends 0x6D.. just prior to the ack.
0x5A shifted left and with a 0 behind for the "write" isn't 0x6D in my humble opinion?

Any suggestions?

MJU
Posts: 502
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 121 times
Been thanked: 108 times
Contact:

Re: I2C vs SMB : whats wrong?

Post by MJU »

Still hoping for a solution :cry:

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: I2C vs SMB : whats wrong?

Post by LeighM »

We could do with a little more information in order to help.
What sensor are you using? Could you post your Flowcode project?
Your previous comment ..
When I use the "SendByte Transaction" and I give the address : 0x5A it returns an ACK.
So the macro shifts the 0x5A and adds a 0 to complete the write request.
The sensor returns an ACK!
Does that mean that your project is now working?

MJU
Posts: 502
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 121 times
Been thanked: 108 times
Contact:

Re: I2C vs SMB : whats wrong?

Post by MJU »

LeighM wrote:We could do with a little more information in order to help.
What sensor are you using? Could you post your Flowcode project?
Your previous comment ..
Thank you Leigh,
I use the MLX90614 IR temp sensor: http://www.melexis.com/Infrared-Thermom ... 4-615.aspx

I've tried the Adafruit MLX90614 library and the MLXTEST sketch with it. This works fine.

When I try to make something with FC V6, and I send the address (0x5A) with FC I don't get an ACK, whereas when the Arduino sketch sends the 0x5A, the sensor always ACK's.
(see screenshots from the logic analyser).
This is when I use the "Transmit Byte" in the Flowcode macro.
When I use the "SendByte Transaction" in Flowcode and I send the address, it does ACK..

Both look the same on my logic analyser.
So the 0x5A (followed with a 0 for read) does not ACK with the Transmit Byte macro in FC6
0x05 with the SendByte macro does return an Ack.

When I use the "SendByte Transaction" and I give the address : 0x5A it returns an ACK.
So the macro shifts the 0x5A and adds a 0 to complete the write request.
The sensor returns an ACK!
LeighM wrote:Does that mean that your project is now working?
No when I use the "SendByte Transaction" I must send a 16bit address (address H and L), and it doesn't recognise the 16bit address..

I've made a Flowcode chart that sends all adresses from 0-255 but it never ACK's on any of them.
BenJ told this about the logic analyser screenshots..
Benj wrote:at acks has the data changing on the falling clock edge whereas the other seems to occasionally change in between the falling and rising edge.
Attachments
Test1.fcfx
(8.79 KiB) Downloaded 259 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: I2C vs SMB : whats wrong?

Post by LeighM »

Hi
Your test probably does not work because you do not have a Stop after each Transmit byte.

Looking at the datasheet, the protocol is quite complex, so the generic Flowcode I2C “Transaction” macros are not suitable.
You will need to build up a transaction yourself from the Start, TransmitByte, ReceiveByte and Stop macros.

From your previous notes, it looks like the device is responding OK to device address 0x5A,
so if you look at page 17 there is a read RAM word example, so for this you would need to call the following macros:
Start, TransmitByte(0xB4), TransmitByte(0x07), Restart, TransmitByte(0xB5), ReceiveByte(LSByte), ReceiveByte(MSByte), ReceiveByte(PEC), Stop

Hope that helps,
Leigh

MJU
Posts: 502
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 121 times
Been thanked: 108 times
Contact:

Re: I2C vs SMB : whats wrong?

Post by MJU »

LeighM wrote:Hi
Your test probably does not work because you do not have a Stop after each Transmit byte.

Looking at the datasheet, the protocol is quite complex, so the generic Flowcode I2C “Transaction” macros are not suitable.
You will need to build up a transaction yourself from the Start, TransmitByte, ReceiveByte and Stop macros.

From your previous notes, it looks like the device is responding OK to device address 0x5A,
so if you look at page 17 there is a read RAM word example, so for this you would need to call the following macros:
Start, TransmitByte(0xB4), TransmitByte(0x07), Restart, TransmitByte(0xB5), ReceiveByte(LSByte), ReceiveByte(MSByte), ReceiveByte(PEC), Stop

Hope that helps,
Leigh
Leigh, my hero of the day (or better, my hero of the month).

I tried to copy the Arduino commands to get the sensor working. That wasn't the best tactic I now know. :D
This works fine thank you!

Post Reply