HerkuleXLib  1.1
Arduino library to drive HerkuleX DRS-0101 and DRS-0201
Static Public Member Functions | List of all members
HkxUnitConversion Class Reference

Class to manage unit conversions. More...

#include <HkxCommunication.h>

Static Public Member Functions

static int16_t voltageRawToValue (uint8_t voltageRaw)
 Voltage from raw to value. More...
 
static uint8_t voltageValueToRaw (int16_t voltageValue)
 Voltage from value to raw. More...
 
static int16_t temperatureRawToValue (uint8_t temperatureRaw)
 Temperature from raw to value. More...
 
static uint8_t temperatureValueToRaw (int16_t temperatureValue)
 Temperature from value to raw. More...
 
static int16_t angleRawToValue (int16_t angleRaw)
 Angle from raw to value. More...
 
static int16_t angleValueToRaw (int16_t angleValue)
 Angle from value to raw. More...
 
static int16_t positionRawToValue (uint16_t positionRaw)
 Position from raw to value. More...
 
static uint16_t positionValueToRaw (int16_t positionValue)
 Position from value to raw. More...
 
static int16_t velocityRawToValue (int16_t velocityRaw)
 Velocity from raw to value. More...
 
static int16_t velocityValueRaw (int16_t velocityValue)
 Velocity from value to raw. More...
 
static uint16_t timeRawToValue (uint8_t timeRaw)
 Time from raw to value. More...
 
static uint8_t timeValueToRaw (uint16_t timeValue)
 Time from value to raw. More...
 
static uint16_t slopeRawToValue (uint16_t slopeRaw)
 Slope from raw to value. More...
 
static uint16_t slopeValueToRaw (uint16_t slopeValue)
 Slope from value to raw. More...
 
static hkxBaudrate baudrateRawToValue (uint8_t baudrateRaw)
 Baud rate from raw to value. More...
 
static uint8_t baudrateValueToRaw (hkxBaudrate baudrate)
 Baud rate from value to raw. More...
 

Detailed Description

Class to manage unit conversions.

This class manages the unit conversions between raw values as sent by the servo and physical quantity.

Member Function Documentation

static int16_t HkxUnitConversion::angleRawToValue ( int16_t  angleRaw)
inlinestatic

Angle from raw to value.

Conversion from raw (servo unit) to value (physical quantity) of the angle.

\[ angle = raw \times 0.326 [degree] \]

Parameters
[in]angleRaw: angle in raw unit.
Returns
the angle in 10^-1 degrees.
static int16_t HkxUnitConversion::angleValueToRaw ( int16_t  angleValue)
inlinestatic

Angle from value to raw.

Conversion from value (physical quantity) to raw (servo unit) of the angle.

\[ angle = raw \times 0.326 [degree] \]

Parameters
[in]angleValue: angle in 10^-1 degrees.
Returns
the angle in raw unit.
static hkxBaudrate HkxUnitConversion::baudrateRawToValue ( uint8_t  baudrateRaw)
inlinestatic

Baud rate from raw to value.

Conversion from raw (servo unit) to value (physical quantity) of the baud rate.

---------------------------------------------------------------------------------------------------------
| hkxBaudrate | HKX_57600 | HKX_115200 | HKX_200000 | HKX_250000 | HKX_400000 | HKX_500000 | HKX_666666 |
---------------------------------------------------------------------------------------------------------
|  baud rate  |   57600   |   115200   |   200000   |   250000   |   400000   |   500000   |   666666   |
---------------------------------------------------------------------------------------------------------
|  raw value  |   0x22    |    0x10    |    0x09    |    0x07    |    0x04    |    0x03    |    0x02    | 
--------------------------------------------------------------------------------------------------------- 
Parameters
[in]baudrateRaw: baudrateRaw in raw unit.
Returns
the baud rate in bps (bytes per second).
static uint8_t HkxUnitConversion::baudrateValueToRaw ( hkxBaudrate  baudrate)
inlinestatic

Baud rate from value to raw.

Conversion from value (physical quantity) to raw (servo unit) of the baud rate.

---------------------------------------------------------------------------------------------------------
| hkxBaudrate | HKX_57600 | HKX_115200 | HKX_200000 | HKX_250000 | HKX_400000 | HKX_500000 | HKX_666666 |
---------------------------------------------------------------------------------------------------------
|  baud rate  |   57600   |   115200   |   200000   |   250000   |   400000   |   500000   |   666666   |
---------------------------------------------------------------------------------------------------------
|  raw value  |   0x22    |    0x10    |    0x09    |    0x07    |    0x04    |    0x03    |    0x02    | 
--------------------------------------------------------------------------------------------------------- 
Parameters
[in]baudrate: baud rate in bps (bytes per second).
Returns
the baudrate in raw unit.
static int16_t HkxUnitConversion::positionRawToValue ( uint16_t  positionRaw)
inlinestatic

Position from raw to value.

Conversion from raw (servo unit) to value (physical quantity) of the angle position. The angle position refers to the figure p.32 of the user manual: 512 (raw) = 0°, 0 (raw) = -166.7°, 1023 (raw) = 166.7°.

\[ position = (raw - 512) \times 0.326 [degree] \]

Parameters
[in]positionRaw: position in raw unit.
Returns
the position in 10^-1 degrees (reference to the central position).
static uint16_t HkxUnitConversion::positionValueToRaw ( int16_t  positionValue)
inlinestatic

Position from value to raw.

Conversion from value (physical quantity) to raw (servo unit) of the angle position. The angle position refers to the figure p.32 of the user manual: 512 (raw) = 0°, 0 (raw) = -166.7°, 1023 (raw) = 166.7°.

\[ position = (raw - 512) \times 0.326 [degree] \]

Parameters
[in]positionValue: position in 10^-1 degrees (reference to the central position).
Returns
the position in raw unit.
static uint16_t HkxUnitConversion::slopeRawToValue ( uint16_t  slopeRaw)
inlinestatic

Slope from raw to value.

Conversion from raw (servo unit) to value (physical quantity) of the PWM/angle slope.

\[ slope = \frac{raw}{256 \times 0.326} [PWM/degree] \]

Warning
Caution should be taken with the slope raw value:
  • 0 => no slope (infinity slope),
  • 1 => minimum slope,
  • 32767 maximum value for a slope
Parameters
[in]slopeRaw: slope in raw unit.
Returns
the slope in 10^-2 PWM/degree.
static uint16_t HkxUnitConversion::slopeValueToRaw ( uint16_t  slopeValue)
inlinestatic

Slope from value to raw.

Conversion from value (physical quantity) to raw (servo unit) of the PWM/angle slope.

\[ slope = raw \times 256 \times 0.326 [PWM/degree] \]

Warning
Caution should be taken with the slope raw value:
  • 0 => no slope (infinity slope),
  • 1 => minimum slope,
  • 32767 maximum value for a slope
Parameters
[in]slopeValue: slope in 10^-2 PWM/degree.
Returns
the slope in raw unit.
static int16_t HkxUnitConversion::temperatureRawToValue ( uint8_t  temperatureRaw)
inlinestatic

Temperature from raw to value.

Conversion from raw (servo unit) to value (physical quantity) of the temperature. See the conversion table p.55 of the user manual for more details.

Parameters
[in]temperatureRaw: temperature in raw unit.
Returns
the temperature in 10^-2 °C (degree Celsius).
static uint8_t HkxUnitConversion::temperatureValueToRaw ( int16_t  temperatureValue)
inlinestatic

Temperature from value to raw.

Conversion from value (physical quantity) to raw (servo unit) of the temperature. See the conversion table p.55 of the user manual for more details.

Parameters
[in]temperatureValue: temperature 10^-2 °C (degree Celsius).
Returns
the temperature in raw unit.
static uint16_t HkxUnitConversion::timeRawToValue ( uint8_t  timeRaw)
inlinestatic

Time from raw to value.

Conversion from raw (servo unit) to value (physical quantity) of the time.

\[ time = raw \times 11.2 [millisecond] \]

Parameters
[in]timeRaw: time in raw unit.
Returns
the time in milliseconds.
static uint8_t HkxUnitConversion::timeValueToRaw ( uint16_t  timeValue)
inlinestatic

Time from value to raw.

Conversion from value (physical quantity) to raw (servo unit) of the time.

\[ time = raw \times 11.2 [millisecond] \]

Parameters
[in]timeValue: time in degrees/second.
Returns
the time in raw unit.
static int16_t HkxUnitConversion::velocityRawToValue ( int16_t  velocityRaw)
inlinestatic

Velocity from raw to value.

Conversion from raw (servo unit) to value (physical quantity) of the angle velocity.

\[ velocity = raw \times 29.09 [degree/second] \]

Parameters
[in]velocityRaw: velocity in raw unit.
Returns
the angle velocity in degrees/second.
static int16_t HkxUnitConversion::velocityValueRaw ( int16_t  velocityValue)
inlinestatic

Velocity from value to raw.

Conversion from value (physical quantity) to raw (servo unit) of the angle velocity.

\[ velocity = raw \times 29.09 [degree/second] \]

Parameters
[in]velocityValue: velocity in degrees/second.
Returns
the velocity in raw unit.
static int16_t HkxUnitConversion::voltageRawToValue ( uint8_t  voltageRaw)
inlinestatic

Voltage from raw to value.

Conversion from raw (servo unit) to value (physical quantity) of the voltage.

\[ voltage = raw \times 0.074 [volts] \]

Parameters
[in]voltageRaw: voltage in raw unit.
Returns
the voltage in millivolts.
static uint8_t HkxUnitConversion::voltageValueToRaw ( int16_t  voltageValue)
inlinestatic

Voltage from value to raw.

Conversion from value (physical quantity) to raw (servo unit) of the voltage.

\[ voltage = raw \times 0.074 [volts] \]

Parameters
[in]voltageValue: voltage in millivolts.
Returns
the voltage in raw unit.

The documentation for this class was generated from the following file: