i2C Acknowledge - Device Detection

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

Moderator: Benj

Post Reply
User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times
Contact:

i2C Acknowledge - Device Detection

Post by Jay Dee »

Hi Guys,
Is there a way to detect if an i2C command has not been acknowledged ?
I have a working i2C LCD and Keypad setup, used for setup and diagnostics. However when this hardware is not attached, I wanted to the FlowCode to detect this a run a given default macro.
I could have another pin or something to detect the presence of the keyboard and LCD but would be good if I could utilise the acknowledge bit already present in the i2C datastream.
Any ideas? J.

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 Acknowledge - Device Detection

Post by LeighM »

Hi J

If you are using the I2C Master component, then the TransmitByte macro will return 0 if it gets an Ack from the slave device, 1 otherwise.
For the I2C based LCD components then I guess we could add a return status to the Start macro.
What are you using?

Regards,
Leigh

User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times
Contact:

Re: i2C Acknowledge - Device Detection

Post by Jay Dee »

Hi Leigh,
Yeah that's what I first thought but there does not seem to be a return variable for either the i2C Master or i2C LCD Start.
See example test attached
i2C_Ack_Confirmation_Test.fcfx
i2C Ack Confirm test
(6.03 KiB) Downloaded 286 times
have i missed something obvious?
J.

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 Acknowledge - Device Detection

Post by LeighM »

Hi J
As you noticed, the lcd_I2C component Start macro does not have a return, so maybe we could add one,
could be a week or two though as we are short of time at the moment!

The I2C Master could do it, but you would need to ...
Initialise
Start
TransmitByte, with the device address as parameter, test the return value (0=Ack, 1=Nak)
Stop

Although I'm not entirely sure if the I2CMaster and the lcd_I2C will happily co-exist on the same port/pins
I would guess that all should be well if you do the Master Init and test first, then (if all well) do the lcd_I2C Start

User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times
Contact:

Re: i2C Acknowledge - Device Detection

Post by Jay Dee »

Ah I see what your suggesting... sorry I was looking for a Return Byte withing the Initialise call.
OK, I'll see if I can make the suggestion work. cheers, J.

Busy you say... I can imagine why :lol: Keep up the good work.

Post Reply