Ruida

The educational technology and digital learning wiki
Revision as of 08:29, 26 May 2020 by Tatarize (talk | contribs) (Created page with "= Introduction = Ruida controllers are laser cutter controller boards with several beefier features. They are built for lasering, and run a download and execute scheme. They...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Introduction

Ruida controllers are laser cutter controller boards with several beefier features. They are built for lasering, and run a download and execute scheme. They are natively supported by RDWorks (which is free) and supported by Lightburn (Proprietary, $80). They have a control panel that can often display the program to be run and perform jogging operations. There have been a number of reverse engineering and supporting operations.

Ruida controllers can control 4 axises. These are X, Y, Z, and U.

Protocol

The laser can be controlled through a few different means. It accepts USB files in an .rd format, it can be set to listen for UDP packets on port 50200, and can directly transfer files via USB to the device.

UDP

UDP packets requires an extra 16 bit checksum for each packet. Since UDP can lose packets it requires an ACK reply after every packet. The checksum doesn't require any special operations it's literally just the lower 16 bits sum of the value of each byte in the packet. Beyond those differences the remaining elements are Ruida commands which follow a fairly well understood structure.

The first two bytes of any UDP packet are LSB checksum. This response to this is either 0xCC Checksum match or 0xCF checksum fail. On fail the packet must be resent. Too long of a time will cause a time out.

In UDP the packet size is limited to 1474 bytes. However most modern versions simply cut at around 1000 bytes. These cuts are permitted to occur mid-command but modernly do not do that. They cut at command boundaries.

USB

There are two methods of USB transfer, direct transfer with a USB device between the machine and computer, and through the use of a thumb drive.


Swizzling

All packet data is lightly swizzled at the byte level. The checksum is calculated preswizzle.

Swizzling:

       b ^= (b >> 7) & 0xFF
       b ^= (b << 7) & 0xFF
       b ^= (b >> 7) & 0xFF
       b ^= 0xB0
       b ^= 0x38
       b = (b + 1) & 0xFF

Unswizzling:

       b = (b - 1) & 0xFF
       b ^= 0xB0
       b ^= 0x38
       b ^= (b >> 7) & 0xFF
       b ^= (b << 7) & 0xFF
       b ^= (b >> 7) & 0xFF
       return b

The general algorithm swaps the first and last digit, xors the data and adds 1. The reverse unswizzling requires subtracting one, xor, and swapping the first and last digit. In the presented code the swap is done there with an xor swap.

Ruida Encoding

Each command in Ruida starts with a a high bit meaning all bytes sent that are 0x80 or above are commands. All other bytes consequently cannot use that bit. This leads to the two other main unit types.

  • One byte integer.
  • 14 bit signed integer.
  • 14 bit unsigned integer.
  • 32 bit signed number
  • 32 bit unsigned number.

The 32 bit numbers require 5 bytes (5 * 7 bits) which gives 35 bits. The top three are simply ignored.

Values

Absolute Coordinate. This is stored as a signed 32 bit integer 5 byte integer. The distance is in micrometers.

Relative Coordinate. This is stored as a signed 14 bit integer 2 byte integer. The distance is in micrometers.

0x88 Move To Absolute

0x88 is 2 absolute coordinate for X and Y. The command is:

  • 88 XX XX XX XX XX YY YY YY YY YY -- 11 bytes.

0x89 Move To Relative

0x89 is 2 relative coordinates for x and Y. The command is:

  • 89 XX XX YY YY - 5 bytes.

0xA8 Cut To Absolute

0xA8 is 2 absolute coordinates for X and Y. The command is:

0xA8 XX XX XX XX XX YY YY YY YY YY -- 11 bytes.

0xA9 Cut To Relative

0xA9 is 2 relative coordinates for x and Y. The command is:

  • A9 XX XX YY YY - 5 bytes.

0xAA Horizontal Cut To Relative

0xAA is 1 relative coordinate for X. The command is:

AA XX XX - 3 bytes

0xAB Vertical Cut To Relative

0xAB is 1 relative coordinate for Y. The command is:

AB YY YY - 3 bytes

0xC6 Set Property

0xC6 sets a particular properties some are known, some are not.

  • 0x01 <Power> -- Sets Power1 Minimum.
  • 0x02 <Power> -- Sets Power1 Maximum.
  • 0x05 <2 bytes> -- Unknown.
  • 0x07 <2 bytes> -- Unknown.
  • 0x08 <2 bytes> -- Unknown.
  • 0x15 -- Unknown
  • 0x16 -- Unknown
  • 0x21 <Power> -- Sets Power2 Minimum.
  • 0x22 <Power> -- Sets Power2 Maximum.
  • 0x31 <3 bytes> - Unknown. #1 in sequence
  • 0x32 <3 bytes> - Unknown. #2 in sequence
  • 0x35 <3 bytes> - Unknown. #5 in sequence
  • 0x36 <3 bytes> - Unknown. #6 in sequence
  • 0x37 <3 bytes> - Unknown. #7 in sequence
  • 0x38 <3 bytes> - Unknown. #8 in sequence
  • 0x41 <3 bytes> - Unknown. #4 in sequence
  • 0x42 <3 bytes> - Unknown. #5 in sequence

0xC9 Set Speed

0xC9 set the speed. Speeds are in micrometers / sec.

  • 0x02 <Speed> - 7 bytes
  • 0x04 0x00 <Speed> - 8 bytes

0xCA Unknown Set Coords?

  • 0x01 <1 byte>
  • 0x02 <1 byte>
  • 0x03 <1 byte>
  • 0x06 <5 bytes> -- 7 bytes
  • 0x10 <1 byte>
  • 0x22 <1 byte>
  • 0x41 <2 bytes> -- 4 bytes.

0xCC ACK

Acknowledgment from Machine.

0xCD ERROR

Error from the machine

0xD7 Finishing

A few bytes sequences are finishing bytes. D7 is seen at the end. It's not clear what it does. It doesn't have any payload.

0xD8 Unknown Program

These elements are only seen when planning on starting some programmed cuts.

  • 0x00 -- #5 seen in sequence.
  • 0x12 -- #1 seen in sequence.
  • 0x2C -- Home the Z axis.
  • 0x2D -- Home the U axis.
  • 0x2E -- Focus.

=== 0xD9 Jog Move.