Go Down

Topic: Using I2C to read multiple values (Read 67 times) previous topic - next topic

Wonton64

Apr 16, 2018, 04:43 pm Last Edit: Apr 16, 2018, 04:49 pm by Wonton64
Following this thread(Float I2C) I have implemented the code to read a float into my sketch using an Arduino Micro. I'm using it in a custom 3D printer application and the Micro would be a slave device responsible for controlling a peripheral device. The Master would send over data regarding x and y changes, which the slave uses for calculations. The G Code the master would use would be
Code: [Select]
M260 A5 B65                    ; Send 'A' to address 5
M260 A0x7F B0x41               ; Send 'A' to address 7F (hex)
M260 A0 B82:101:112:82:97:112  ; Send 'RepRap' to address 0

RepRap Wiki
My question is, because I'm shaky on the i2c communication and byte manipulation in general, what is the best way to send over two values to the slave device? Would two M260 commands be the solution? Or, do those colons demarcate the byte values?

PaulS

Quote
Would two M260 commands be the solution?
Did you try that? If not, why not?

Quote
Or, do those colons demarcate the byte values?
No, they demarcate the slices of cheese.
The art of getting good answers lies in asking good questions.

Wonton64

Did you try that? If not, why not?
Because I was tasked with building a peripheral for a 3D printer, I'm not working on the printer itself, but I'd like to present options for integrating the peripheral.

cattledog

Quote
but I'd like to present options for integrating the peripheral.
I think you'd be better off "putting a stake in the ground" and telling the people sending the data how you want to to receive it. Let them negotiate for options if they can't do what you require.

What is the code for your sketch?

Go Up