i2C Acknowledge - Device Detection

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

Moderator: Benj

User avatar
Jay Dee
Posts: 359
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 116 times
Been thanked: 139 times
Contact:

i2C Acknowledge - Device Detection

Postby Jay Dee » Wed Jul 06, 2016 10:22 pm

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: 1920
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 461 times
Been thanked: 650 times
Contact:

Re: i2C Acknowledge - Device Detection

Postby LeighM » Thu Jul 07, 2016 2:22 pm

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: 359
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 116 times
Been thanked: 139 times
Contact:

Re: i2C Acknowledge - Device Detection

Postby Jay Dee » Thu Jul 07, 2016 7:31 pm

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 139 times

have i missed something obvious?
J.

User avatar
LeighM
Matrix Staff
Posts: 1920
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 461 times
Been thanked: 650 times
Contact:

Re: i2C Acknowledge - Device Detection

Postby LeighM » Fri Jul 08, 2016 8:59 am

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: 359
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 116 times
Been thanked: 139 times
Contact:

Re: i2C Acknowledge - Device Detection

Postby Jay Dee » Fri Jul 15, 2016 8:53 pm

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.
These users thanked the author Jay Dee for the post:
LeighM (Fri Jul 15, 2016 8:58 pm)
Rating: 5.26%