Modbus

Results 1 to 16 of 16

Thread: Modbus

  1. #1
    Member PlanetCNC's Avatar
    Join Date
    Mar 2017
    Location
    Slovenia
    Posts
    1312
    Downloads
    0
    Uploads
    0

    Default Modbus

    Mk3 controller always had support for transmitting Modbus commands.
    New Mk3/4 and Mk3 controllers with red 10pin connector also support receiving Modbus responses.

    We are developing new sets of commands that will greatly simplify Modbus usage.

    Does anybody use Modbus or wans to use it? What kind of devices do you have? Do you need master or slave implementation?

    Similar Threads:


  2. #2
    Member ScorpionTDL's Avatar
    Join Date
    Aug 2020
    Posts
    131
    Downloads
    0
    Uploads
    0

    Default Re: Modbus

    I know that the linux cnc people like to use Modbus to control the VFD for the spindle.
    This typically makes the 0-10V converter board obsolete. Makes for a better, more consistent RPM setting and could perhaps also provide feedback from the VFD to Planet for status reporting.

    However this needs to be a quiet close integration into the S command to be beneficial, don't know how easy this can be achieved. (can the S command scripted by the user at the moment?)

    While I have a modbus capable VFD (Omron MX2) I don't see the need personally at this point in time as I have everything setup in a working order. However I think proper Modbus support could be a selling point for people who are looking for a new system.



  3. #3
    Member Steler's Avatar
    Join Date
    May 2020
    Posts
    70
    Downloads
    0
    Uploads
    0

    Default Re: Modbus

    Hello,

    Interesting, I develop and use Modbus applications but for controlling temperature regulators.
    Many VFD use the Modbus protocol.
    Unless I am mistaken, I have never seen any presentation, possibility or example of the use of this protocol with MK3. Would it be possible to get some?

    My MK3 controller does not have a red 10pin connector, is it compatible?

    For my part, I would rather see the implementation in master mode, at least initially. The slave mode would imply having a system above to communicate, analyze, control TNG V2, which would be rather rare in the majority of our cases.

    if you are using a 10 pin connector i am assuming you are only using modbus RTU or ASCII, are you planning to implement modbus TCP?



  4. #4
    Member Spramon's Avatar
    Join Date
    Feb 2021
    Posts
    1
    Downloads
    0
    Uploads
    0

    Default Re: Modbus

    Quote Originally Posted by PlanetCNC View Post
    Mk3 controller always had support for transmitting Modbus commands.
    New Mk3/4 and Mk3 controllers with red 10pin connector also support receiving Modbus responses.

    We are developing new sets of commands that will greatly simplify Modbus usage.

    Does anybody use Modbus or wans to use it? What kind of devices do you have? Do you need master or slave implementation?
    My Mk3 board also don't have 10pin red connector (about 1 year old now). I think I will stick modbus but I'm more intrested about Ethercat any implemention plans



  5. #5
    Member PlanetCNC's Avatar
    Join Date
    Mar 2017
    Location
    Slovenia
    Posts
    1312
    Downloads
    0
    Uploads
    0

    Default Re: Modbus

    With new version write single coil (5) command can be sent like this:
    Code:
    (array,3000,0x11,0x05,0x00,0x00,0x01,0x00)
    (crc16,3000)
    M65 H0 Q3001 E#3000 R4001 D-1
    State of single coil (1) can be read like this:
    Code:
    (array,3000,0x11,0x01,0x00,0x00,0x01,0x00)
    (crc16,3000)
    M65 H0 Q3001 E#3000 R4001 D-1

    Returned data count is stored in parameter 4000, results are in 4001, 4002,...
    It can be printed to output window like this:
    Code:
    (print,-----)
    (print,0x#<4000,-2>)
    (print,0x#<4001,-2>)
    (print,0x#<4002,-2>)
    (print,0x#<4003,-2>)
    (print,0x#<4004,-2>)
    (print,0x#<4005,-2>)
    (print,0x#<4006,-2>)
    (print,0x#<4007,-2>)
    (print,0x#<4008,-2>)
    (print,0x#<4009,-2>)
    (print,0x#<4010,-2>)
    (print,0x#<4011,-2>)
    (print,0x#<4012,-2>)

    Old Mk3 without red connector can send commands via TX pin.



  6. #6
    Member ScorpionTDL's Avatar
    Join Date
    Aug 2020
    Posts
    131
    Downloads
    0
    Uploads
    0

    Default Re: Modbus

    is this working with the mk3/9 controller as well?



  7. #7
    Member PlanetCNC's Avatar
    Join Date
    Mar 2017
    Location
    Slovenia
    Posts
    1312
    Downloads
    0
    Uploads
    0

    Default Re: Modbus

    Yes, Mk3/9 is just another name for Mk3.

    When I receive some Modbus devices I'll create more examples.



  8. #8
    Activation process Highlandscnc's Avatar
    Join Date
    Aug 2018
    Posts
    1
    Downloads
    0
    Uploads
    0

    Default

    Quote Originally Posted by PlanetCNC View Post
    Yes, Mk3/9 is just another name for Mk3.

    When I receive some Modbus devices I'll create more examples.
    Have you made anymore examples? I'm very interested in
    Controlling our VFD via modbus if possible.

    Is there any further documentation of the Api ect... that
    Isn't currently shared on your website?

    Frank
    Spark Robotic



  9. #9
    Member Sparkrobotic's Avatar
    Join Date
    May 2019
    Posts
    8
    Downloads
    0
    Uploads
    0

    Default Re: Modbus

    The current G-Code documentation does not say anything about RX for M65

    M65 - Output TX
    Usage: M65 Q - Q = data send to TX
    M65 Q E - Q = parameter number of first data location
    - E = data count

    Send data to TX.

    M66 - Output I2C
    Usage: M66 H Q - H = I2C address in 8bit mode
    - Q = data send to I2C
    M66 H Q E <R> <D> - H = I2C address in 8bit mode
    - Q = parameter number of first data location
    - E = data count
    - R (optional) = parameter number for returned data
    - D (optional) = returned data count

    Send and receive data from I2C

    Frank

    Spark Robotic



  10. #10
    Member Sparkrobotic's Avatar
    Join Date
    May 2019
    Posts
    8
    Downloads
    0
    Uploads
    0

    Default Re: Modbus

    Here is a python example of what we would like to control via either your serial out or a stand alone USB-RS485 converter.

    https://github.com/drogenlied/pyHYControl

    Any guidance would be appreciated.

    Frank

    Spark Robotic.



  11. #11
    Member PlanetCNC's Avatar
    Join Date
    Mar 2017
    Location
    Slovenia
    Posts
    1312
    Downloads
    0
    Uploads
    0

    Default Re: Modbus

    Latest G-code manual states:

    M65 - Output Serial
    Usage: M65 H Q - H = Serial port (0 or 1)
    - Q = data send to serial interface


    M65 H Q E <R> <D> - H = Serial port (0 or 1)
    - Q = parameter number of first data location
    - E = data count
    - R (optional) = parameter number for returned data
    - D (optional) = returned data count
    Send data to serial interface.
    I know it is not much but it is something.

    We will create much more tutorial, examples and also hardware for Modbus. Currently I only have some routines for relay board
    Modbus RTU 8ch relay module RS485/TTL UART 8CH input 8CH out_chinalctech


    mb_addrread.gcode - read board address
    Code:
    (print,mb_addrread:)
    
    
    #<len> = 7
    
    
    (array, 3000, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01)
    (crc16, 3000)
    (arrclr, 4000, 16)
    ;o<mb_printdata> exec [3000]
    M65 H1 Q3001 E#3000 R4001 D#<len>
    o<mb_printdata> exec [4000]
    
    
    o<mb_check> exec [3000] [4000] [#<len>]
    o<rc> if[#<_result> NE 0]
      M99
    o<rc> endif
    
    
    #<addr> = #4005
    (print,  address read: #<addr>)
    (print,--------)
    M99
    mb_addrwrite.gcode - write board address
    Code:
    (print,mb_addrwrite: #1)
    
    
    #<len> = 11
    
    
    (array, 3000, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00)
    #3009 = #1
    (crc16, 3000)
    (arrclr, 4000, 16)
    ;o<mb_printdata> exec [3000]
    M65 H1 Q3001 E#3000 R4001 D#<len>
    o<mb_printdata> exec [4000]
    
    
    o<mb_check> exec [3000] [4000] [#<len>]
    o<rc> if[#<_result> NE 0]
      M99
    o<rc> endif
    
    
    #<addr> = #4009
    (print,  address write: #<addr>)
    (print,--------)
    M99
    mb_baudread.gcode - read current baudrate
    Code:
    (print,mb_baudread:)
    
    
    #<len> = 7
    
    
    (array, 3000, 0x00, 0x03, 0x03, 0xE8, 0x00, 0x01)
    #3001 = #1
    (crc16, 3000)
    (arrclr, 4000, 16)
    ;o<mb_printdata> exec [3000]
    M65 H1 Q3001 E#3000 R4001 D#<len>
    o<mb_printdata> exec [4000]
    
    
    o<mb_check> exec [3000] [4000] [#<len>]
    o<rc> if[#<_result> NE 0]
      M99
    o<rc> endif
    
    
    #<baud> = #4005
    o<chk> if[#<baud> EQ 2]
      #<baudnum> = 4800
    o<chk> elseif[#<baud> EQ 3]
      #<baudnum> = 9600
    o<chk> elseif[#<baud> EQ 4]
      #<baudnum> = 19200
    o<chk> endif
    (print,  baud rate read: #<baud>, #<baudnum>)
    (print,--------)
    M99
    mb_baudwrite.gcode - set new baudrate
    Code:
    (print,mb_baudwrite:)
    
    
    #<len> = 8
    
    
    (array, 3000, 0x00, 0x10, 0x03, 0xE9, 0x00, 0x01, 0x02, 0x00, 0x00)
    #3001 = #1
    #3009 = #2
    (crc16, 3000)
    (arrclr, 4000, 16)
    ;o<mb_printdata> exec [3000]
    M65 H1 Q3001 E#3000 R4001 D#<len>
    o<mb_printdata> exec [4000]
    
    
    o<mb_check> exec [3000] [4000] [#<len>]
    o<rc> if[#<_result> NE 0]
      M99
    o<rc> endif
    
    
    #<baud> = #2
    o<chk> if[#<baud> EQ 2]
      #<baudnum> = 4800
    o<chk> elseif[#<baud> EQ 3]
      #<baudnum> = 9600
    o<chk> elseif[#<baud> EQ 4]
      #<baudnum> = 19200
    o<chk> endif
    (print,  baud rate write: #<baud>, #<baudnum>)
    (print,--------)
    M99
    mb_check.gcode - helper routine for checking response
    Code:
    ;check length
    o<chk> if [#[#2] NE #3]
      (print,ERROR: expected length #3)
      #<_result> = 1
      M99
    o<chk> endif
    
    
    ;check response
    o<chk> if[#[#1+1] NE #[#2+1]]
      (print,ERROR: unexpected response address)
      #<_result> = 1
      M99
    o<chk> endif
    
    
    o<chk> if[#[#1+2] NE #[#2+2]]
      (print,ERROR: unexpected response command)
      #<_result> = 1
      M99
    o<chk> endif
    
    
    ;check crc
    #<crc11> = #[#2+1+#[#2] -2]
    #<crc12> = #[#2+1+#[#2] -1]
    #[#2+1+#[#2] -2] = 0
    #[#2+1+#[#2] -1] = 0
    #[#2] = [#[#2]-2]
    (crc16, #2)
    #<crc21> = #[#2+1+#[#2] -2]
    #<crc22> = #[#2+1+#[#2] -1]
    o<chk> if[[#<crc11> NE #<crc21>] OR [#<crc12> NE #<crc22>]]
      (print,ERROR CRC is 0x#<crc21,X>#<crc22,X>, expected 0x#<crc11,X>#<crc12,X>)
      #<_result> = 1
      M99
    o<chk> endif
    
    
    #<_result> = 0
    M99
    mb_printdata.gcode - helper routine for printing data
    Code:
    (print,Data @ #1: #[#1] bytes)
    #<cnt> = 0
    o<loop> while[#<cnt> LT #[#1]]
      #<val> = #[#1+1+#<cnt>]
      (print,  #<cnt>: 0x#<val,X>)
      #<cnt> = [#<cnt>+1]
    o<loop> endwhile
    M99
    mb_relay.gcode - set relay on/off
    Code:
    (print,mb_relay:)
    
    
    #<len> = 8
    
    
    (array, 3000, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00)
    #3001 = #1
    #3004 = #2
    o<chk> if[#3 GT 0]
    #3005 = 255
    o<chk> else
    #3005 = 0
    o<chk> endif
    (crc16, 3000)
    (arrclr, 4000, 16)
    ;o<mb_printdata> exec [3000]
    M65 H1 Q3001 E#3000 R4001 D#<len>
    o<mb_printdata> exec [4000]
    
    
    o<mb_check> exec [3000] [4000] [#<len>]
    o<rc> if[#<_result> NE 0]
      M99
    o<rc> endif
    
    
    (print,--------)
    M99
    mb_relayalloff.gcode - set all relays to off
    Code:
    (print,mb_relayalloff:)
    
    
    #<len> = 8
    
    
    (array, 3000, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x08, 0x01, 0x00)
    #3001 = #1
    (crc16, 3000)
    (arrclr, 4000, 16)
    ;o<mb_printdata> exec [3000]
    M65 H1 Q3001 E#3000 R4001 D#<len>
    o<mb_printdata> exec [4000]
    
    
    o<mb_check> exec [3000] [4000] [#<len>]
    o<rc> if[#<_result> NE 0]
      M99
    o<rc> endif
    
    
    (print,--------)
    M99
    mb_relayallon.gcode - set all relays to on
    Code:
    (print,mb_relayallon:)
    
    
    #<len> = 8
    
    
    (array, 3000, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x08, 0x01, 0xFF)
    #3001 = #1
    (crc16, 3000)
    (arrclr, 4000, 16)
    ;o<mb_printdata> exec [3000]
    M65 H1 Q3001 E#3000 R4001 D#<len>
    o<mb_printdata> exec [4000]
    
    
    o<mb_check> exec [3000] [4000] [#<len>]
    o<rc> if[#<_result> NE 0]
      M99
    o<rc> endif
    
    
    (print,--------)
    M99

    Here is an example of g-code that turns relays on/off one by one in a loop (address of my board is 2):
    Code:
    o<mb_relayalloff> exec [2]
    #<cnt> = 0
    #<onoff> = 1
    o<loop> repeat [160]
      o<mb_relay> exec [2] [#<cnt>] [#<onoff>]
      #<cnt> = [#<cnt> + 1]
      o<chk> if [#<cnt> GE 8]
        #<cnt> = 0
    	#<onoff> = [LNOT[#<onoff>]]
      o<chk> endif
      (print,#<cnt>    #<onoff> )
      G04 P0.1
    o<loop> endrepeat




  12. #12
    Member Sparkrobotic's Avatar
    Join Date
    May 2019
    Posts
    8
    Downloads
    0
    Uploads
    0

    Default

    Thank you for the reply I'll take a look.

    Frank

    Spark Robotic



  13. #13
    Member Sparkrobotic's Avatar
    Join Date
    May 2019
    Posts
    8
    Downloads
    0
    Uploads
    0

    Default

    Is it possible to transmit and receive without using
    G65. Inherently if a gcode is running we would not
    Be able to communicate modbus with g65.



  14. #14
    Member PlanetCNC's Avatar
    Join Date
    Mar 2017
    Location
    Slovenia
    Posts
    1312
    Downloads
    0
    Uploads
    0

    Default Re: Modbus

    You mean M65?



  15. #15
    Member Sparkrobotic's Avatar
    Join Date
    May 2019
    Posts
    8
    Downloads
    0
    Uploads
    0

    Default

    Quote Originally Posted by PlanetCNC View Post
    You mean M65?
    Yes m65 , g65 was a typo. Are the serial pins directly available
    Outside of gcode.



  16. #16
    Member PlanetCNC's Avatar
    Join Date
    Mar 2017
    Location
    Slovenia
    Posts
    1312
    Downloads
    0
    Uploads
    0

    Default Re: Modbus

    Currently not, working on it.



Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

Modbus

Modbus