Skip to content

Arduino serial interface to main desktop portocal

Matty edited this page Apr 11, 2018 · 13 revisions

The main will application will send in 2 bytes of data to Arduino. These byte will incorporate the operation and the device to control. This will be decoded on the Arduino to find the operation and the device based on the following:

We have 16 bits to work with:

  • Bits 0-2 indicate the stepper id according to the following:
    • X_AXIS_TOP = 0
    • X_AXIS_BOTTOM = 1
    • Z_AXIS_TOP = 2
    • Z_AXIS_BOTTOM =3
    • Y_AXIS = 4
  • Bit 3-4 indicate the operation:
    • Home the stepper= 0
    • Move the stepper forward= 1
    • Move the stepper backward= 2
    • Stop the stepper=3
  • Bit 5-7 unused
  • Bit 8-15 will be the length stepper motor will move mm. This means you can only move 255mm or 25.5cm at a time.

For each command the Arduino will send back to the main application the status of the operations. Meaning if the operation is successful or not. if the operation is successful Arduino will return the the new state of the affected device.

The first byte will contain the error code and the device affected.

  • Bits 0-2 indicate the stepper id according to the following:
    • X_AXIS_TOP = 0
    • X_AXIS_BOTTOM = 1
    • Z_AXIS_TOP = 2
    • Z_AXIS_BOTTOM =3
    • Y_AXIS = 4
  • Bit 3 is not used for now and reserved for new devices.
  • Bits 4-7 will will contain the error code (as unsigned number and later will be converted to signed by the main application). Error codes to be returned:
    • SUCCESS = 0,
    • RECEIVED_FEWER_THANTWO_BYTES = -1,
    • INVALID_OPERATION = -2,
    • INVALID_DEVICE = -3,
    • COULD_NOT_PERFORM_OPERATION = -4,
    • COULD_NOT_DECODE_BYTES = -5,

the first byte sent will the status code and the second byte will be the new state of the device affected. It

Clone this wiki locally