From 19991488e7545091d1addcc2bc7247a406faedcc Mon Sep 17 00:00:00 2001 From: dtex Date: Thu, 12 Jan 2017 13:53:17 -0600 Subject: [PATCH 1/3] Revision to stepper-2.0 Drop member number from multiStepper commands. Comment updates. Change bias for exponent values to -17 --- stepper-2.0.md | 56 +++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/stepper-2.0.md b/stepper-2.0.md index 3dd12f7..029f25b 100644 --- a/stepper-2.0.md +++ b/stepper-2.0.md @@ -66,17 +66,16 @@ Protocol **Stepper step (relative move)** -Position is specified as a 32-bit signed long. +Steps to move is specified as a 32-bit signed long. The speed value is a float composed of a 23-bit significand (mantissa) and a 4-bit exponent -(biased -18 with an explicit 1's bit) and a sign bit. +(biased -17 with an explicit 1's bit) and a sign bit. |27 |26-23 |22-0 | |-----|--------|-----------| |sign |exponent|significant| |1 bit|4 bits |23 bits | - ``` 0 START_SYSEX (0xF0) 1 Stepper Command (0x62) @@ -100,7 +99,7 @@ Sets a stepper to a desired position based on the number of steps from the zero Position is specified as a 32-bit signed long. The speed value is float composed of a 23-bit significand (mantissa) and a 4-bit exponent -(biased -18 with an explicit 1's bit) and a sign bit. +(biased -17 with an explicit 1's bit) and a sign bit. |27 |26-23 |22-0 | |-----|--------|-----------| @@ -112,11 +111,11 @@ The speed value is float composed of a 23-bit significand (mantissa) and a 4-bit 1 Stepper Command (0x62) 2 to command (0x03) 3 device number (0-9) -4 num steps, bits 0-6 -5 num steps, bits 7-13 -6 num steps, bits 14-20 -7 num steps, bits 21-27 -8 num steps, bits 28-32 +4 position, bits 0-6 +5 position, bits 7-13 +6 position, bits 14-20 +7 position, bits 21-27 +8 position, bits 28-32 9 speed, bits 0-6 (steps per second) 10 speed, bits 7-13 11 speed, bits 14-20 @@ -179,7 +178,7 @@ When a limit pin (digital) is set to its limit state, movement in that direction **Stepper set acceleration** Sets the acceleration/deceleration in steps/sec^2. The accel value is composed of a 23-bit -significand (mantissa) and a 4-bit exponent (biased -18 with an explicit 1's bit) and a sign bit. +significand (mantissa) and a 4-bit exponent (biased -17 with an explicit 1's bit) and a sign bit. |27 |26-23 |22-0 | |-----|--------|-----------| @@ -223,21 +222,27 @@ Stepper instances that have been created with the stepper configuration command **MultiStepper to** +Sets each stepper in a group to a desired position based on the number of +steps from its zero position. Positions are specified as a 32-bit signed long. + +Stepper movements will be coordinated so that all arrive at their desired +position simultaneously. The duration of this move is based on which stepper +will take the longest given the change in position and the stepper's max speed. + ``` 0 START_SYSEX (0xF0) 1 Stepper Command (0x62) 2 multi to command (0x21) 3 group number (0-127) -4 member number (0-9) -5 num steps, bits 0-6 -6 num steps, bits 7-13 -7 num steps, bits 14-20 -8 num steps, bits 21-27 -9 num steps, bits 28-32 +4 position, bits 0-6 +5 position, bits 7-13 +6 position, bits 14-20 +7 position, bits 21-27 +8 position, bits 28-32 -*Optionally repeat 4 through 9 for each device in group* +*Repeat 4 through 8 for each device in group* -63 END_SYSEX (0xF7) +53 END_SYSEX (0xF7) ``` **MultiStepper stop** @@ -258,14 +263,13 @@ Sent when a move completes or stop is called. 1 Stepper Command (0x62) 2 multi stop reply command (0x24) 3 group number (0-127) -4 member number (0-9) -5 position, bits 0-6 -6 position, bits 7-13 -7 position, bits 14-20 -8 position, bits 21-27 -9 position, bits 28-32 +4 position, bits 0-6 +5 position, bits 7-13 +6 position, bits 14-20 +7 position, bits 21-27 +8 position, bits 28-32 -*Optionally repeat 4 through 9 for each device in group* +*Repeat 4 through 8 for each device in group* -63 END_SYSEX (0xF7) +53 END_SYSEX (0xF7) ``` From e7af98ed681bfd6e787bcbca043c191eb0a649fd Mon Sep 17 00:00:00 2001 From: dtex Date: Mon, 16 Jan 2017 11:20:35 -0600 Subject: [PATCH 2/3] Add detail around custom float format --- stepper-2.0.md | 94 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 72 insertions(+), 22 deletions(-) diff --git a/stepper-2.0.md b/stepper-2.0.md index 029f25b..b7bf49d 100644 --- a/stepper-2.0.md +++ b/stepper-2.0.md @@ -6,7 +6,10 @@ Current implementation supports 10 stepper motors at the same time (#[0-9]). Includes optional support for acceleration and deceleration of the motor. -Also includes multiStepper support which allows groups of steppers to be simultaneously passed different ```to``` values and the duration of their movements will match. Up to five multiStepper groups can be created. The total number of steppers is still limited to 10. +Also includes multiStepper support which allows groups of steppers to be simultaneously controlled. Up to five multiStepper groups can be created. The total number of steppers is still limited to 10. + +Stepper 2.0 sends and receives floats in a custom format described at the end +of this document. Example files: * Version 2.0 of the stepper protocol has not yet been implemented. @@ -68,13 +71,7 @@ Protocol Steps to move is specified as a 32-bit signed long. -The speed value is a float composed of a 23-bit significand (mantissa) and a 4-bit exponent -(biased -17 with an explicit 1's bit) and a sign bit. - -|27 |26-23 |22-0 | -|-----|--------|-----------| -|sign |exponent|significant| -|1 bit|4 bits |23 bits | +The speed value is a float passed using Stepper 2.0's custom float format described below. ``` 0 START_SYSEX (0xF0) @@ -98,13 +95,7 @@ The speed value is a float composed of a 23-bit significand (mantissa) and a 4-b Sets a stepper to a desired position based on the number of steps from the zero position. Position is specified as a 32-bit signed long. -The speed value is float composed of a 23-bit significand (mantissa) and a 4-bit exponent -(biased -17 with an explicit 1's bit) and a sign bit. - -|27 |26-23 |22-0 | -|-----|--------|-----------| -|sign |exponent|significant| -|1 bit|4 bits |23 bits | +The speed value is a float passed using Stepper 2.0's custom float format described below. ``` 0 START_SYSEX (0xF0) @@ -177,13 +168,8 @@ When a limit pin (digital) is set to its limit state, movement in that direction **Stepper set acceleration** -Sets the acceleration/deceleration in steps/sec^2. The accel value is composed of a 23-bit -significand (mantissa) and a 4-bit exponent (biased -17 with an explicit 1's bit) and a sign bit. - -|27 |26-23 |22-0 | -|-----|--------|-----------| -|sign |exponent|significant| -|1 bit|4 bits |23 bits | +Sets the acceleration/deceleration in steps/sec^2. The accel value is passed +using Stepper 2.0's custom float format described below. ``` @@ -273,3 +259,67 @@ Sent when a move completes or stop is called. 53 END_SYSEX (0xF7) ``` + +Stepper 2 Custom Float Format +--- + +Floats sent and received by Stepper 2 are composed of a 23-bit significand (mantissa) +and a 4-bit, base 10 exponent (biased -17 with an explicit 1's bit) and a sign bit. + +|27 |26-23 |22-0 | +|-----|--------|-----------| +|sign |exponent|significant| +|1 bit|4 bits |23 bits | + +Those values allow a range from 8.388608*10^-11 to 83886.08. + +**Example 1: 1 step per hour** + +1 step per hour = 1 step / 60 minutes / 60 seconds = 0.000277... steps per second + +The largest integer that can be represented in 23 bits is 8388608 so the +significand will be limited to 6 or 7 digits. In this case 2777778. + +The exponent is 4 bits which limits the range to 0-15, but we subtract +17 from that value on the receiving end to give us a range from -17 to -2. In +this example we pass 7 to give us a -10 value in the exponent. + +| | Decimal| Binary | +|-----------------------|--------|------------------------| +|Sign (bit 27) | 0| 0| +|Exponent (bits 26-23) | 7| 0110| +|Significand (bits 22-0)| 2777778| 01010100110001010110010| + +Values in firmata are passed in the 7 least significant bits of each message byte +so we will be passing in 4 bytes: + +| | Binary | Hex | +|-------------------------------------------|---------|-----| +| Sign, Exponent and 2 most significant bits| 00011001| 0x19| +| Next most significant bits | 00101001| 0x29| +| Next most significant bits | 01000101| 0x45| +| Least most significant bits | 00110010| 0x32| + + +**Example 2: 100 steps per second** + +We have to pad our significand on the right with four zeros to get our full +precision. That makes the significand 1000000 and our exponent value will be -4. +Since the value we send will be biased -17 on the receiving end, we send 13 in +the exponent. + +| | Decimal| Binary | +|-----------------------|--------|------------------------| +|Sign (bit 27) | 0| 0| +|Exponent (bits 26-23) | 13| 1101| +|Significand (bits 22-0)| 1000000| 00011110100001001000000| + +Values in firmata are passed in the 7 least significant bits of each message byte +so we would be passing in 4 bytes: + +| | Binary | Hex | +|-------------------------------------------|---------|-----| +| Sign, Exponent and 2 most significant bits| 00110100| 0x29| +| Next most significant bits | 00111101| 0x29| +| Next most significant bits | 00000100| 0x45| +| Least most significant bits | 01000000| 0x32| From f5a9926948f738d5831d75aed9d926fe897cf419 Mon Sep 17 00:00:00 2001 From: dtex Date: Wed, 18 Jan 2017 22:29:21 -0600 Subject: [PATCH 3/3] Break out maxSpeed and pulseWidth --- stepper-2.0.md | 51 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/stepper-2.0.md b/stepper-2.0.md index b7bf49d..043564d 100644 --- a/stepper-2.0.md +++ b/stepper-2.0.md @@ -39,23 +39,20 @@ Protocol XXXXXX0 = no enable pin XXXXXX1 = has enable pin) -5 minPulseWidth (0-127 measured in us) -6 num steps-per-revolution LSB -7 num steps-per-revolution MSB -8 maxSpeed LSB -9 maxSpeed MSB -10 motorPin1 or directionPin number (0-127) -11 motorPin2 or stepPin number (0-127) -12 [when interface >= 0x0110000] motorPin3 (0-127) -13 [when interface >= 0x1000000] motorPin4 (0-127) -14 [when interface && 0x0000001] enablePin (0-127) -15 [optional] pins to invert (lower 5 bits = pins: +5 num steps-per-revolution LSB +6 num steps-per-revolution MSB +7 motorPin1 or directionPin number (0-127) +8 motorPin2 or stepPin number (0-127) +9 [when interface >= 0x0110000] motorPin3 (0-127) +10 [when interface >= 0x1000000] motorPin4 (0-127) +11 [when interface && 0x0000001] enablePin (0-127) +12 [optional] pins to invert (lower 5 bits = pins: XXXXXX1 = invert motorPin1 XXXXX1X = invert motorPin2 XXXX1XX = invert motorPin3 XXX1XXX = invert motorPin4 XX1XXXX = invert enablePin) -16 END_SYSEX (0xF7) +13 END_SYSEX (0xF7) ``` **Stepper zero** @@ -184,6 +181,36 @@ using Stepper 2.0's custom float format described below. 8 END_SYSEX (0xF7) ``` +**Stepper set maxSpeed** + +Sets the maximum speed in steps per second. . The speed value is passed +using Stepper 2.0's custom float format described below. + +``` +0 START_SYSEX (0xF0) +1 Stepper Command (0x62) +2 set acceleration command (0x09) +3 device number (0-9) (Supports up to 10 motors) +4 maxSpeed, bits 0-6 (maxSpeed in steps per sec) +5 maxSpeed, bits 7-13 +6 maxSpeed, bits 14-20 +7 maxSpeed, bits 21-28 +8 END_SYSEX (0xF7) +``` + +**Stepper set pulse width** + +Adds a delay for each step in microseconds + +``` +0 START_SYSEX (0xF0) +1 Stepper Command (0x62) +2 set minPulseWidth command (0x0A) +3 device number (0-9) (Supports up to 10 motors) +4 minPulseWidth (minimum pulse width in microseconds) +5 END_SYSEX (0xF7) +``` + **MultiStepper configuration** Stepper instances that have been created with the stepper configuration command above can be added to a multiStepper group. Groups can be sent a list of devices/positions in a single command and their movements will be coordinated to begin and end simultaneously. Note that multiStepper does not support acceleration or deceleration.