I2C Loop-Back | Arduino Compatible Compiler for LabVIEW Discussions | Forum

Avatar
Please consider registering
guest
sp_LogInOut Log In sp_Registration Register
Register | Lost password?
Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Feed Topic RSS sp_TopicIcon
I2C Loop-Back
October 8, 2015
9:17 pm
Avatar
Jim.UF
Member
Members
Forum Posts: 17
Member Since:
September 24, 2015
sp_UserOfflineSmall Offline

Have been trying to morph the I2C Master/Slave examples into a loop-back configuration: Master -> Slave -> Master -> serial monitor.

Seems like the attached code should be close, but doesn’t work. I wonder about the I2C Write String vi in i2C Reply Interrupt; not sure about a constant for the slave address as trying to transmit to the Master.

Suggestions?

Jim

October 8, 2015
10:33 pm
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Can you post your code?

October 9, 2015
2:38 am
Avatar
Jim.UF
Member
Members
Forum Posts: 17
Member Since:
September 24, 2015
sp_UserOfflineSmall Offline

Sorry ... dragged them in but didn't see the 'start upload' button.

October 9, 2015
3:39 am
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Can you save for LV2014?

October 9, 2015
4:02 pm
Avatar
Jim.UF
Member
Members
Forum Posts: 17
Member Since:
September 24, 2015
sp_UserOfflineSmall Offline

2014 ver attached.

October 9, 2015
5:09 pm
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Ok there is a fundamental issue here.  Sending data back from a Slave to the Master is a little different because the Master has to initiate all transfers.  You cannot just reply back from the Slave when the Master sends a message.  You may want to read up a bit more on I2C Master Reader mode here.  But take a look at the DS1307 Real Time Clock.vi example, which is code for a Master.  Inside Read RTC Time and Format.vi the Master is requesting time info from a slave RTC device using the same method you would need to use.

On the Slave side, you need to create a Request Interrupt to capture requests from Master "Request From" messages.  This is very similar to setting up the Receive Interrupt but you use I2C Attach Request Interrupt.vi.  Then the Master has to request data from the slave using I2C Request From.vi.  This will cause the Request interrupt on the slave side to go off in which you can then transfer data back to the Master using I2C Write String.vi as you are now.  On the master side you would read all bytes after sending Request From.

October 9, 2015
6:36 pm
Avatar
Jim.UF
Member
Members
Forum Posts: 17
Member Since:
September 24, 2015
sp_UserOfflineSmall Offline

Steffan,
I had looked at the DS1307 Real Time Clock.vi but let it ‘slip away’; think I kind of rebelled against the I2C Request From.vi not 'telling' the slave what to send. The Write/Request/Read sequence could go into a subvi, but (I understand) would require a global variable to get to the reply. The RTC example is what I want to do anyway: get values from registers on an I2C slave.
I appreciate your help!
Jim

Forum Timezone: UTC 0
Most Users Ever Online: 100
Currently Online:
25
Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
miche91: 33
scottj: 28
scadao: 23
Member Stats:
Guest Posters: 5
Members: 202
Moderators: 0
Admins: 3
Forum Stats:
Groups: 1
Forums: 2
Topics: 266
Posts: 1222
Newest Members:
pujacontrol
Administrators: geadmin: 22, filipealtoe: 96, Steffan: 356