Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using I2c of RAMPS 1.4 #4068

Closed
pankajbadatia opened this issue Jun 17, 2016 · 14 comments
Closed

using I2c of RAMPS 1.4 #4068

pankajbadatia opened this issue Jun 17, 2016 · 14 comments
Labels
C: Boards/Pins T: Question Questions, generally redirected to other groups.

Comments

@pankajbadatia
Copy link

Hi all I want to know how can i connect RAMPS as masster and other arduino as slave using I2c communication.
which code should i edit .
my slave address is 0x08
start bit 0x01
command bit 0x02
stop bit 0x17

@thinkyhead
Copy link
Member

thinkyhead commented Jun 17, 2016

With #3258 we added an i2c bus feature, which exists in RC6 and the current RCBugFix. Enable EXPERIMENTAL_I2CBUS in Configuration_adv.h and you can use it to experiment with sending and receiving bytes using GCode commands.

@thinkyhead thinkyhead added C: Boards/Pins T: Question Questions, generally redirected to other groups. labels Jun 17, 2016
@jbrazio jbrazio closed this as completed Jun 20, 2016
@pankajbadatia
Copy link
Author

Thank you .. I did it but i have confusion between sending hex value and byte or char

@jbrazio
Copy link
Contributor

jbrazio commented Jun 20, 2016

What is the confusion ?

@pankajbadatia
Copy link
Author

pankajbadatia commented Jun 20, 2016

address is in hex when

M155 A8 // slave address
M155 B1 // start bit
M155 B2 // command
M155 B23 // stop bit
M155 S1 // send 

it doesn't work . Is this correct way to send command??

@pankajbadatia
Copy link
Author

pankajbadatia commented Jun 20, 2016

 * ; Example #1
 * ; This macro send the string "Marlin" to the slave device with address 0x63
 * ; It uses multiple M155 commands with one B<base 10> arg
 * M155 A63  ; Target slave address
 * M155 B77  ; M
 * M155 B97  ; a
 * M155 B114 ; r
 * M155 B108 ; l
 * M155 B105 ; i
 * M155 B110 ; n
 * M155 S1   ; Send the current buffer

I am reffering this

@jbrazio
Copy link
Contributor

jbrazio commented Jun 20, 2016

It uses multiple M155 commands with one B<base 10> arg

M155 B77 the 77 is ASCII "M" in decimal (base 10).
In your case you only need to convert M155 B23 (base 16) to M155 B35 (base 10).

asciifull

@thinkyhead
Copy link
Member

thinkyhead commented Jun 20, 2016

confusion between sending hex value and byte or char
you only need to convert M155 B23 (base 16) to M155 B35

@pankajbadatia
Actually, it looks like you did the right conversions. 0x17 is 23 decimal.
What result do you expect when you send 8: 1, 2, 23?

…address is in hex when…

All values are expressed in decimal. So in your second example A63 should be A99.

; Example #1
; This macro send the string "Marlin" to the slave device with address 0x63
; It uses multiple M155 commands with one B<base 10> arg
M155 A99  ; 0x63 Target slave address
M155 B77  ; M
M155 B97  ; a
M155 B114 ; r
M155 B108 ; l
M155 B105 ; i
M155 B110 ; n
M155 S1   ; Send the current buffer

@jbrazio
Copy link
Contributor

jbrazio commented Jun 20, 2016

Scott, that's the example from the Configuration_adv.h.

@pankajbadatia
Copy link
Author

Does the ramp accept address in hex or decimal ??

@pankajbadatia
Copy link
Author

/* Start and end of packet markers These are
start of packet SOP
and end of packet EOP
of different microprocessor which i am using*/

#define PACKET_SOP (0x01u)
#define PACKET_EOP (0x17u)

/* any one can be used Commands set */
#define CMD_SET_OFF (0u)
#define CMD_SET_RED (1u)
#define CMD_SET_GREEN (2u)
#define CMD_SET_BLUE (3u)

Then which commands should i send

@thinkyhead
Copy link
Member

Scott, that's the example from the Configuration_adv.h.

And it's wrong, alas.

@thinkyhead
Copy link
Member

Does the ramp accept address in hex or decimal?

The M155 feature needs the address (A) to be specified in decimal — only digits from 0-9 are acceptable in GCode parameters.

@thinkyhead
Copy link
Member

thinkyhead commented Jun 22, 2016

Then which commands should i send ?

I'm just guessing here, but it looks like you have the right idea…

M155 A8  ; slave addr
M155 B1  ; PACKET_SOP
M155 B0  ; all off first
M155 B1  ; red
M155 B2  ; +green = yellow
M155 B23 ; PACKET_EOP
M155 S1  ; <send>

@github-actions
Copy link

github-actions bot commented Apr 7, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: Boards/Pins T: Question Questions, generally redirected to other groups.
Projects
None yet
Development

No branches or pull requests

3 participants