6 Commits
27 changed files with 857 additions and 653 deletions

No files matched your search

+1 -12
View File
@@ -1,6 +1,4 @@
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage. name: Build Software
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
name: Build Software and create release on tag
on: on:
push: push:
@@ -18,9 +16,6 @@ env:
jobs: jobs:
build: build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@@ -35,19 +30,13 @@ jobs:
run: ls && cd pico-sdk && git submodule update --init && cd .. run: ls && cd pico-sdk && git submodule update --init && cd ..
- name: Configure and run CMake for Hardware Rev 0.3 - name: Configure and run CMake for Hardware Rev 0.3
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/Software/build-Rev-0_3 -S ${{github.workspace}}/Software -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DPICO_BOARD=RP2040-Decoder-board-Rev-0_3 run: cmake -B ${{github.workspace}}/Software/build-Rev-0_3 -S ${{github.workspace}}/Software -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DPICO_BOARD=RP2040-Decoder-board-Rev-0_3
- name: Build for Hardware Rev 0.3 - name: Build for Hardware Rev 0.3
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/Software/build-Rev-0_3 --config ${{env.BUILD_TYPE}} run: cmake --build ${{github.workspace}}/Software/build-Rev-0_3 --config ${{env.BUILD_TYPE}}
- name: Configure and run CMake for Hardware Rev 1.0 - name: Configure and run CMake for Hardware Rev 1.0
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/Software/build-Rev-1_0 -S ${{github.workspace}}/Software -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DPICO_BOARD=RP2040-Decoder-board-Rev-1_0 run: cmake -B ${{github.workspace}}/Software/build-Rev-1_0 -S ${{github.workspace}}/Software -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DPICO_BOARD=RP2040-Decoder-board-Rev-1_0
- name: Build for Hardware Rev 1.0 - name: Build for Hardware Rev 1.0
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/Software/build-Rev-1_0 --config ${{env.BUILD_TYPE}} run: cmake --build ${{github.workspace}}/Software/build-Rev-1_0 --config ${{env.BUILD_TYPE}}
+1 -1
View File
@@ -1,4 +1,4 @@
name: Doxygen Action name: Generate documentation doxygen/breathe/sphinx and deploy on gh-pages/gh-pages-dev
on: on:
push: push:
+63 -22
View File
@@ -1,4 +1,4 @@
name: pcb_image name: Render PCB images and rotating mp4
on: on:
push: push:
branches: branches:
@@ -9,62 +9,103 @@ on:
- 'KiCad/**' # Trigger if any file in the 'KiCad' directory changes - 'KiCad/**' # Trigger if any file in the 'KiCad' directory changes
jobs: jobs:
render-image: render-images:
name: render-image name: render-images
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Check out the repo - name: Check out the repo
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Render PCB image - name: Render PCB image and .mp4 (Rev 1.0)
uses: linalinn/kicad-render@main uses: linalinn/kicad-render@main
with: with:
pcb_file: KiCad/Rev_1_0/RP2040-Decoder.kicad_pcb pcb_file: KiCad/Rev_1_0/RP2040-Decoder.kicad_pcb
output_path: ${{ github.workspace }}/images output_path: ${{ github.workspace }}/images_rev_1_0
animation: gif animation: mp4
- name: Upload images as artifact - name: Render PCB image and .mp4 (Rev 0.3)
uses: linalinn/kicad-render@main
with:
pcb_file: KiCad/Rev_0_3/RP2040-Decoder.kicad_pcb
output_path: ${{ github.workspace }}/images_rev_0_3
animation: mp4
- name: Upload images and mp4 as artifact (Rev 1.0)
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: pcb-images name: pcb-images_rev_1_0
path: images/ path: images_rev_1_0/
- name: Upload images and mp4 as artifact (Rev 0.3)
uses: actions/upload-artifact@v4
with:
name: pcb-images_rev_0_3
path: images_rev_0_3/
deploy-pages-main: deploy-pages-main:
if: github.ref == 'refs/heads/main' # Only deploy on 'main' branch if: github.ref == 'refs/heads/main' # Only deploy on 'main' branch
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: render-image needs: render-images
steps: steps:
- name: Download pcb-images artifact - name: Download pcb-images_rev_1_0 artifact
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
name: pcb-images name: pcb-images_rev_1_0
path: images/ path: images_rev_1_0/
- name: Download pcb-images_rev_0_3 artifact
uses: actions/download-artifact@v4
with:
name: pcb-images_rev_0_3
path: images_rev_0_3/
- name: Deploy - name: Deploy
uses: peaceiris/actions-gh-pages@v3 uses: peaceiris/actions-gh-pages@v3
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./images publish_dir: ./images_rev_1_0
publish_branch: gh-pages # Specify the target branch (gh-pages in this case) publish_branch: gh-pages # Specify the target branch (gh-pages in this case)
destination_dir: img destination_dir: img_rev_1_0
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./images_rev_0_3
publish_branch: gh-pages # Specify the target branch (gh-pages in this case)
destination_dir: img_rev_0_3
deploy-pages-dev: deploy-pages-dev:
if: github.ref == 'refs/heads/dev' # Only deploy on 'dev' branch if: github.ref == 'refs/heads/dev' # Only deploy on 'dev' branch
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: render-image needs: render-images
steps: steps:
- name: Download pcb-images artifact - name: Download pcb-images_rev_1_0 artifact
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
name: pcb-images name: pcb-images_rev_1_0
path: images/ path: images_rev_1_0/
- name: Deploy - name: Download pcb-images_rev_0_3 artifact
uses: actions/download-artifact@v4
with:
name: pcb-images_rev_0_3
path: images_rev_0_3/
- name: Deploy Rev 1.0
uses: peaceiris/actions-gh-pages@v3 uses: peaceiris/actions-gh-pages@v3
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./images publish_dir: ./images_rev_1_0
publish_branch: gh-pages-dev # Specify the target branch (gh-pages-dev in this case) publish_branch: gh-pages-dev # Specify the target branch (gh-pages-dev in this case)
destination_dir: img destination_dir: img_rev_1_0
- name: Deploy Rev 0.3
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./images_rev_0_3
publish_branch: gh-pages-dev # Specify the target branch (gh-pages-dev in this case)
destination_dir: img_rev_0_3
+1 -1
View File
@@ -1,4 +1,4 @@
name: Build Software and create release on tag name: Build Software and create prerelease on tag
on: on:
push: push:
+4 -1
View File
@@ -37,6 +37,9 @@ So suggestions on how to improve things and bug reports are always much apprecia
The wiki is also work in progress and will be updated to be as comprehensive as possible. The wiki is also work in progress and will be updated to be as comprehensive as possible.
------------ ------------
![rotating gif of RP2040-Decoder](https://raw.githubusercontent.com/gab-k/RP2040-Decoder/refs/heads/gh-pages-dev/img/rotating.gif) <div style="display: flex; justify-content: space-between; align-items: center;">
<img src="https://raw.githubusercontent.com/gab-k/RP2040-Decoder/refs/heads/gh-pages-dev/img/top.png" alt="Image 1" style="width: 50%;"/>
<img src="https://raw.githubusercontent.com/gab-k/RP2040-Decoder/refs/heads/gh-pages-dev/img/bottom.png" alt="Image 2" style="width: 50%;"/>
</div>
+2 -2
View File
@@ -79,13 +79,13 @@ endif()
# limit the frequency of log outputs—such as logging only every 100th iteration. # limit the frequency of log outputs—such as logging only every 100th iteration.
# - Note that with UART logging enabled, PICO_DEFAULT_UART_TX_PIN and PICO_DEFAULT_UART_RX_PIN are disabled for decoder functions. # - Note that with UART logging enabled, PICO_DEFAULT_UART_TX_PIN and PICO_DEFAULT_UART_RX_PIN are disabled for decoder functions.
# These pins are used for UART communication. Disabling is done automatically in RP2040-Decoder-board.h or RP2040-Decoder-board-legacy.h respectively. # These pins are used for UART communication. Disabling is done automatically in RP2040-Decoder-board.h or RP2040-Decoder-board-legacy.h respectively.
set(LOGLEVEL 1) set(LOGLEVEL 0)
# Additionally, the LOG_WAIT parameter can be configured to make the controller wait for user input via stdio before continuing. # Additionally, the LOG_WAIT parameter can be configured to make the controller wait for user input via stdio before continuing.
# This is useful for ensuring that all stdio logging outputs are captured. # This is useful for ensuring that all stdio logging outputs are captured.
# If disabled, there may not be enough time to connect the serial terminal before most of the logging has already been completed. # If disabled, there may not be enough time to connect the serial terminal before most of the logging has already been completed.
set(LOG_WAIT 0) set(LOG_WAIT 0)
# Modify the below lines to enable/disable output over UART and/or USB # Modify the below lines to enable/disable output over UART and/or USB
set(STDIO_USB_ENABLED 1) set(STDIO_USB_ENABLED 0)
set(STDIO_UART_ENABLED 0) set(STDIO_UART_ENABLED 0)
# Leave those two unmodified # Leave those two unmodified
pico_enable_stdio_uart(RP2040-Decoder ${STDIO_UART_ENABLED}) pico_enable_stdio_uart(RP2040-Decoder ${STDIO_UART_ENABLED})
+5 -6
View File
@@ -62,9 +62,8 @@ uint8_t CV_ARRAY_DEFAULT [CV_ARRAY_SIZE] = {
0b00000000, //CV_44 - 0b00000000, //CV_44 -
0b00000000, //CV_45 - 0b00000000, //CV_45 -
0b00000000, //CV_46 - 0b00000000, //CV_46 -
// TODO: Update controller CVs
// Speed controller - Configuration ///////////////////////////////////////////////////////////////////////////////// // Speed controller - Configuration /////////////////////////////////////////////////////////////////////////////////
0b00110010, //CV_47 - Feed-forward gain k_ff = CV_47/10000 Default = 50 -> 0.005 // 0b11100110, //CV_47 - Feed-forward factor k_ff in % = CV_47/255 Default = 230 -> 0.902 = 90.2% //
0b00001010, //CV_48 - PID Control low pass filter time constant (tau) in ms // 0b00001010, //CV_48 - PID Control low pass filter time constant (tau) in ms //
0b00000101, //CV_49 - PID Control sampling time t in ms // 0b00000101, //CV_49 - PID Control sampling time t in ms //
0b00011001, //CV_50 - PID Control I_Factor = CV_50/10 Default = 25 -> 2.5 // 0b00011001, //CV_50 - PID Control I_Factor = CV_50/10 Default = 25 -> 2.5 //
@@ -213,10 +212,10 @@ uint8_t CV_ARRAY_DEFAULT [CV_ARRAY_SIZE] = {
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0b00000001, //CV_174 - Additional motor-PWM clock divider. 0b00000001, //CV_174 - Additional motor-PWM clock divider.
0b00000111, //CV_175 - speed_helper timer delay - can be used to adjust accel/decel rate 0b00000111, //CV_175 - speed_helper timer delay - can be used to adjust accel/decel rate
0b00000000, //CV_176 - Base-PWM forward bits 8-15 0b00000000, //CV_176 -
0b00000000, //CV_177 - Base-PWM forward bits 0-7 0b00000000, //CV_177 -
0b00000000, //CV_178 - Base-PWM reverse bits 15-8 0b00000000, //CV_178 -
0b00000000, //CV_179 - Base-PWM reverse bits 0-7 0b00000000, //CV_179 -
0b00000000, //CV_180 - 0b00000000, //CV_180 -
0b00000000, //CV_181 - 0b00000000, //CV_181 -
0b00000000, //CV_182 - 0b00000000, //CV_182 -
-8
View File
@@ -785,14 +785,6 @@ int main() {
watchdog_update(); watchdog_update();
} }
busy_wait_ms(100);
// Check for error calling flash_safe_execute_core_init() on core1
if(get_error_state() & FLASH_SAFE_EXECUTE_CORE_INIT_FAILURE){
panic("Error calling flash_safe_execute_core_init() on core1!"); //TODO: test
}
// Check CV array for factory state of flash or missing ADC offset setup // Check CV array for factory state of flash or missing ADC offset setup
cv_setup_check(); cv_setup_check();
+54
View File
@@ -9,22 +9,74 @@
#include "shared.h" #include "shared.h"
#include "CV.h" #include "CV.h"
/**
* @def MESSAGE_3_BYTES
* @brief Comparison bitmask for detecting 3 byte long DCC messages/packets
*/
#define MESSAGE_3_BYTES 0b11111111110000000000000000000000000001 #define MESSAGE_3_BYTES 0b11111111110000000000000000000000000001
/**
* @def MESSAGE_MASK_3_BYTES
* @brief Bitmask for detecting 3 byte long DCC messages/packets, input_bit_buffer is bitwise ANDed with the mask
*/
#define MESSAGE_MASK_3_BYTES 0b11111111111000000001000000001000000001 #define MESSAGE_MASK_3_BYTES 0b11111111111000000001000000001000000001
/**
* @def MESSAGE_4_BYTES
* @brief Comparison bitmask for detecting 4 byte long DCC messages/packets
*/
#define MESSAGE_4_BYTES 0b11111111110000000000000000000000000000000000001 #define MESSAGE_4_BYTES 0b11111111110000000000000000000000000000000000001
/**
* @def MESSAGE_MASK_4_BYTES
* @brief Bitmask for detecting 4 byte long DCC messages/packets, input_bit_buffer is bitwise ANDed with the mask
*/
#define MESSAGE_MASK_4_BYTES 0b11111111111000000001000000001000000001000000001 #define MESSAGE_MASK_4_BYTES 0b11111111111000000001000000001000000001000000001
/**
* @def MESSAGE_5_BYTES
* @brief Comparison bitmask for detecting 5 byte long DCC messages/packets
*/
#define MESSAGE_5_BYTES 0b11111111110000000000000000000000000000000000000000000001 #define MESSAGE_5_BYTES 0b11111111110000000000000000000000000000000000000000000001
/**
* @def MESSAGE_MASK_5_BYTES
* @brief Bitmask for detecting 5 byte long DCC messages/packets, input_bit_buffer is bitwise ANDed with the mask
*/
#define MESSAGE_MASK_5_BYTES 0b11111111111000000001000000001000000001000000001000000001 #define MESSAGE_MASK_5_BYTES 0b11111111111000000001000000001000000001000000001000000001
/**
* @def INVALID_PACKAGE
* @brief Return value of detect_dcc_packet() when the packet is invalid, meaning no packet was detected
*/
#define INVALID_PACKAGE SIZE_MAX #define INVALID_PACKAGE SIZE_MAX
/**
* @def RING_BUFFER_PACKETS
* @brief First dimension of dcc ring buffer array - meaning RING_BUFFER_PACKETS can be retained inside the buffer
*/
#define RING_BUFFER_PACKETS 8 #define RING_BUFFER_PACKETS 8
/**
* @def RING_BUFFER_BYTES
* @brief Secoond dimension of dcc ring buffer array - meaning each packet can have a maximum size of RING_BUFFER_BYTES
*/
#define RING_BUFFER_BYTES 5 #define RING_BUFFER_BYTES 5
/**
* @def FLASH_CMD_READ_JEDEC_ID
* @brief Constant value of 0x9F used as a JEDEC ID read command for reading the JEDEC ID of a winbond flash memory chip
*/
#define FLASH_CMD_READ_JEDEC_ID 0x9F #define FLASH_CMD_READ_JEDEC_ID 0x9F
/**
* @def FLASH_TIMEOUT_IN_MS
* @brief Timeout value for flash access
*/
#define FLASH_TIMEOUT_IN_MS 500 #define FLASH_TIMEOUT_IN_MS 500
/**
* @def ADC_CALIBRATION_ITERATIONS
* @brief Iterations for measuring adc offset
*/
#define ADC_CALIBRATION_ITERATIONS 8192 #define ADC_CALIBRATION_ITERATIONS 8192
/**
* @def WATCHDOG_TIMER_IN_MS
* @brief Watchdog timer setting, watchdog update needs to be called every WATCHDOG_TIMER_IN_MS milliseconds, otherwise decoder resets itself.
*/
#define WATCHDOG_TIMER_IN_MS 5000 #define WATCHDOG_TIMER_IN_MS 5000
/*! /*!
@@ -53,6 +105,7 @@ const uint32_t clr_bit_arr[6] = {
* *
* This structure is used to store the data and length of a DCC packet. * This structure is used to store the data and length of a DCC packet.
* *
* @typedef dcc_packet_t
* @struct dcc_packet_t * @struct dcc_packet_t
* *
* @param data An array of bytes representing the DCC packet data. * @param data An array of bytes representing the DCC packet data.
@@ -71,6 +124,7 @@ typedef struct dcc_packet_t {
* This structure is used to manage a ring buffer that stores DCC packets. * This structure is used to manage a ring buffer that stores DCC packets.
* It contains an array of packets and indices for writing and reading. * It contains an array of packets and indices for writing and reading.
* *
* @typedef dcc_ring_buffer_t
* @struct dcc_ring_buffer_t * @struct dcc_ring_buffer_t
*/ */
typedef struct dcc_ring_buffer_t { typedef struct dcc_ring_buffer_t {
+10 -10
View File
@@ -147,7 +147,7 @@ float get_kp(const controller_parameter_t *const ctrl_par) {
uint16_t get_initial_level(controller_parameter_t *const ctrl_par){ uint16_t get_initial_level(controller_parameter_t *const ctrl_par){
uint32_t sum = 0; uint32_t sum = 0;
uint32_t i = 0; uint32_t i = 0;
while (i < 16) { while (i < BASE_PWM_ARR_LEN) {
if (ctrl_par->startup.base_pwm_arr[i] > 0) { if (ctrl_par->startup.base_pwm_arr[i] > 0) {
sum += ctrl_par->startup.base_pwm_arr[i]; sum += ctrl_par->startup.base_pwm_arr[i];
i++; i++;
@@ -177,11 +177,11 @@ void controller_startup_mode(controller_parameter_t *const ctrl_par) {
// Save level value in array // Save level value in array
ctrl_par->startup.base_pwm_arr[ctrl_par->startup.base_pwm_arr_i] = ctrl_par->startup.level; ctrl_par->startup.base_pwm_arr[ctrl_par->startup.base_pwm_arr_i] = ctrl_par->startup.level;
// Update index // Update index
ctrl_par->startup.base_pwm_arr_i = (ctrl_par->startup.base_pwm_arr_i+1)%16; ctrl_par->startup.base_pwm_arr_i = (ctrl_par->startup.base_pwm_arr_i+1)%BASE_PWM_ARR_LEN;
// Set ramp_up_mode flag to true // Set ramp_up_mode flag to true
ctrl_par->mode = PID_MODE; ctrl_par->mode = PID_MODE;
// multiply with constant value of 0.9 and set as current feed forward value for pid mode // Multiply with k_ff constant and set as current feed forward value
ctrl_par->feed_fwd = 0.9f * (float)ctrl_par->startup.level; ctrl_par->feed_fwd = ctrl_par->startup.k_ff * (float)ctrl_par->startup.level;
} }
} }
@@ -229,7 +229,6 @@ void controller_pid_mode(controller_parameter_t *const ctrl_par) {
} }
// General controller function gets called every x milliseconds where x is CV_49 i.e. sampling time (pid->t) // General controller function gets called every x milliseconds where x is CV_49 i.e. sampling time (pid->t)
// TODO: Consider fixed point arithmetic to improve performance...
void controller_general(controller_parameter_t * ctrl_par) { void controller_general(controller_parameter_t * ctrl_par) {
// Change in direction -> reset previous derivative, error and integral parts and pwm_base_done // Change in direction -> reset previous derivative, error and integral parts and pwm_base_done
const bool direction_changed = get_direction_of_speed_step(speed_step_target) != const bool direction_changed = get_direction_of_speed_step(speed_step_target) !=
@@ -275,11 +274,16 @@ void init_controller(controller_parameter_t *const ctrl_par) {
LOG(1, "Motor controller initialization...\n") LOG(1, "Motor controller initialization...\n")
// General controller variables // General controller variables
ctrl_par->mode = STARTUP_MODE; ctrl_par->mode = STARTUP_MODE;
ctrl_par->measurement = 0.0f;
ctrl_par->measurement_prev = 0.0f;
ctrl_par->measurement_corrected = 0.0f;
ctrl_par->setpoint = 0;
ctrl_par->feed_fwd = 0; ctrl_par->feed_fwd = 0;
// Startup controller variables // Startup controller variables
ctrl_par->startup.level = 0; ctrl_par->startup.level = 0;
ctrl_par->startup.base_pwm_arr_i = 0; ctrl_par->startup.base_pwm_arr_i = 0;
ctrl_par->startup.k_ff = (float) CV_ARRAY_FLASH[46]/255;
for (int i = 0; i < BASE_PWM_ARR_LEN; ++i) { for (int i = 0; i < BASE_PWM_ARR_LEN; ++i) {
ctrl_par->startup.base_pwm_arr[i] = 0; ctrl_par->startup.base_pwm_arr[i] = 0;
} }
@@ -331,11 +335,6 @@ void init_controller(controller_parameter_t *const ctrl_par) {
ctrl_par->pid.k_p_m_1 = (ctrl_par->pid.k_p_y_1 - ctrl_par->pid.k_p_y_0) / ctrl_par->pid.k_p_x_1; ctrl_par->pid.k_p_m_1 = (ctrl_par->pid.k_p_y_1 - ctrl_par->pid.k_p_y_0) / ctrl_par->pid.k_p_x_1;
ctrl_par->pid.k_p_m_2 = (ctrl_par->pid.k_p_y_2 - ctrl_par->pid.k_p_y_1) / ctrl_par->pid.k_p_x_2; ctrl_par->pid.k_p_m_2 = (ctrl_par->pid.k_p_y_2 - ctrl_par->pid.k_p_y_1) / ctrl_par->pid.k_p_x_2;
// General Controller initialization
ctrl_par->measurement = 0.0f;
ctrl_par->measurement_prev = 0.0f;
ctrl_par->measurement_corrected = 0.0f;
ctrl_par->setpoint = 0;
LOG(1, "Motor controller initialization done!\n") LOG(1, "Motor controller initialization done!\n")
} }
@@ -356,6 +355,7 @@ void core1_entry() {
flash_safe_execute_core_init_done = flash_safe_execute_core_init(); flash_safe_execute_core_init_done = flash_safe_execute_core_init();
if (flash_safe_execute_core_init_done != true){ if (flash_safe_execute_core_init_done != true){
set_error(FLASH_SAFE_EXECUTE_CORE_INIT_FAILURE); set_error(FLASH_SAFE_EXECUTE_CORE_INIT_FAILURE);
panic("Error calling flash_safe_execute_core_init() on core1!");
return; return;
} }
+90 -60
View File
@@ -8,78 +8,108 @@
#pragma once #pragma once
#include "shared.h" #include "shared.h"
/**
* @def BASE_PWM_ARR_LEN
* @brief The length of the base PWM array.
*
* This macro defines the length of the base PWM ring buffer array.
*/
#define BASE_PWM_ARR_LEN 16 #define BASE_PWM_ARR_LEN 16
/**
* @brief Enumeration for controller operating modes.
*
* Defines the two controller operating modes.
*
* @enum controller_mode_t
*/
typedef enum { typedef enum {
STARTUP_MODE, STARTUP_MODE, /**< Controller startup mode state */
PID_MODE, PID_MODE, /**< Controller pid mode state */
} controller_mode_t; } controller_mode_t;
/**
* @brief Structure for startup controller parameters and variables.
*
* This structure defines the parameters and variables used in the startup
* controller, including the latest PWM level, base pwm level ring buffer array and the respective ring buffer index.
*
* @typedef startup_parameters_t
* @struct startup_parameters_t
*/
typedef struct startup_parameters_t { typedef struct startup_parameters_t {
uint16_t level; uint16_t level; /**< Latest level */
uint16_t base_pwm_arr[BASE_PWM_ARR_LEN]; uint16_t base_pwm_arr[BASE_PWM_ARR_LEN]; /**< base pwm ring buffer array */
uint16_t base_pwm_arr_i; uint16_t base_pwm_arr_i; /**< base pwm ring buffer array index */
float k_ff; /**< Feed forward factor */
}startup_parameters_t; }startup_parameters_t;
/**
* @brief Structure for PID controller parameters and variables.
*
* This structure defines the parameters and variables used in the PID
* controller, including gains, error tracking, integrator limits, ...
*
* @typedef pid_parameters_t
* @struct pid_parameters_t
*/
typedef struct pid_parameters_t{ typedef struct pid_parameters_t{
// PID Controller variables // PID Controller variables
float k_i; // Integral gain float k_i; /**< Integral gain */
float k_d; // Derivative gain float k_d; /**< Derivative gain */
float t; // Sampling time float t; /**< Sampling time */
float tau; // Low-pass-filter time constant float tau; /**< Low-pass-filter time constant */
float ci_0; // (k_i*t)/2 float ci_0; /**< (k_i*t)/2 */
float cd_0; // (k_d*2)/(2*tau+t) float cd_0; /**< (k_d*2)/(2*tau+t) */
float cd_1; // (2*tau-t)/(2*tau+t) float cd_1; /**< (2*tau-t)/(2*tau+t) */
float int_lim_max; // max limit for integrator float int_lim_max; /**< max limit for integrator */
float int_lim_min; // min limit for integrator float int_lim_min; /**< min limit for integrator */
float max_output; // max possible pwm output value float max_output; /**< max possible pwm output value */
float k_p; // Proportional gain float k_p; /**< Proportional gain */
float e; // Error float e; /**< Error */
float e_prev; // Previous Error float e_prev; /**< Previous Error */
float i_prev; // Previous Integral Value float i_prev; /**< Previous Integral Value */
float d_prev; // Previous Derivative Value float d_prev; /**< Previous Derivative Value */
// Variable gain variables // Variable gain variables - See gain scheduling documentation for more details
float k_p_x_1_shift; float k_p_x_1_shift; /**< Effectively defines where x1 is shifted from 0% of max setpoint to 100% of max setpoint */
float k_p_x_1; float k_p_x_1; /**< x1 */
float k_p_x_2; float k_p_x_2; /**< x2 */
float k_p_y_0; float k_p_y_0; /**< y0 = KP @ x0 */
float k_p_y_1; float k_p_y_1; /**< y1 = KP @ x1 */
float k_p_y_2; float k_p_y_2; /**< y2 = KP @ x2 */
float k_p_m_1; float k_p_m_1; /**< slope from (x0, y0) to (x1, y1) */
float k_p_m_2; float k_p_m_2; /**< slope from (x1, y1) to (x2, y2) */
} pid_parameter_t; } pid_parameters_t;
/**
* @brief Structure for various controller parameters.
*
* This structure defines the highest level general controller parameters, including
* General settings (setpoint, mode), startup controller settings struct, PID controller struct, and measurement data.
*
* @typedef controller_parameter_t
* @struct controller_parameter_t
*/
typedef struct controller_parameter_t{ typedef struct controller_parameter_t{
/*! // General controller parameters
* General Variables controller_mode_t mode; /**< Current controller mode */
*/ float feed_fwd; /**< Current feed forward value set by startup controller */
controller_mode_t mode; // Controller mode uint32_t setpoint; /**< Current setpoint */
float feed_fwd; // Feed forward value uint16_t speed_table[127]; /**< Array with setpoint values corresponding to every speed step */
uint32_t setpoint; // Current setpoint // Startup controller parameters
uint16_t speed_table[127]; // Array with setpoint values corresponding to every speed step startup_parameters_t startup; /**< Struct for startup controller specific variables */
// PID controller parameters
/*! pid_parameters_t pid; /**< Struct for PID controller specific variables */
* Startup controller mode specific variables // Measurement variables
*/ float measurement; /**< Latest measurement value */
startup_parameters_t startup; float measurement_prev; /**< Previous measurement value */
float measurement_corrected; /**< Corrected measurement value (measurement - adc_offset = measurement_corrected) */
/*! float adc_offset; /**< ADC offset value */
* PID Controller variables uint8_t msr_delay_in_us; /**< Delay before V_EMF is measured */
*/ uint8_t msr_total_iterations; /**< Amount of samples */
pid_parameter_t pid; uint8_t l_side_arr_cutoff; /**< Discarded outlier samples (left side) */
uint8_t r_side_arr_cutoff; /**< Discarded outlier samples (right side) */
/*!
* Measurement Variables
*/
float measurement; // Newest Measurement value
float measurement_prev; // Previous Measurement
float measurement_corrected; // measurement - adc_offset = measurement_corrected
float adc_offset; // ADC offset value
uint8_t msr_delay_in_us; // Delay before VEMF Measurement
uint8_t msr_total_iterations; // Amount of samples
uint8_t l_side_arr_cutoff; // Discarded samples (left side)
uint8_t r_side_arr_cutoff; // Discarded samples (right side)
} controller_parameter_t; } controller_parameter_t;
+2 -2
View File
@@ -6,12 +6,12 @@
#include "shared.h" #include "shared.h"
// TODO: Implement enum typedef for speed steps, also getter and setter functions checking validity of speed step values. // TODO: Implement getter and setter functions for speed steps, checking validity of speed step values.
speed_step_t speed_step_target = SPEED_STEP_REVERSE_STOP; speed_step_t speed_step_target = SPEED_STEP_REVERSE_STOP;
speed_step_t speed_step_target_prev = SPEED_STEP_REVERSE_STOP; speed_step_t speed_step_target_prev = SPEED_STEP_REVERSE_STOP;
bool cv_setup_check_done = false; bool cv_setup_check_done = false;
bool flash_safe_execute_core_init_done = false; bool flash_safe_execute_core_init_done = false;
static error_t error_state = 0; error_t error_state = 0;
// Functions in shared.c are accessed by both cores // Functions in shared.c are accessed by both cores
+390 -270
View File
@@ -19,6 +19,15 @@
#include "hardware/watchdog.h" #include "hardware/watchdog.h"
#include "hardware/exception.h" #include "hardware/exception.h"
/**
* @brief Logs a message with a specified log level.
*
* This macro logs a message if the specified log level is less than or equal to the global LOGLEVEL.
* The log message includes the core number and the time since boot in milliseconds.
*
* @param level The log level of the message.
* @param ... The format string and arguments for the log message.
*/
#define LOG(level, ...) { \ #define LOG(level, ...) { \
if (level <= LOGLEVEL) { \ if (level <= LOGLEVEL) { \
printf("[core%u @ %u ms] ", get_core_num(), to_ms_since_boot(get_absolute_time())); \ printf("[core%u @ %u ms] ", get_core_num(), to_ms_since_boot(get_absolute_time())); \
@@ -26,298 +35,381 @@
} \ } \
} }
// Constant Value of 125 x 10^6 /**
* @def _125M
* @brief Constant value representing 125 million (125 x 10^6).
*/
#define _125M 125000000 #define _125M 125000000
/**
* @enum error_t
* @brief Enumeration of error codes used in the system.
*
* This enumeration defines various error codes that can be encountered
* during the execution of the program. Each error code is represented
* as a bit flag, allowing multiple errors to be combined using bitwise
* operations.
*
*/
typedef enum { typedef enum {
FLASH_SAFE_EXECUTE_CORE_INIT_FAILURE = (1<<0), FLASH_SAFE_EXECUTE_CORE_INIT_FAILURE = (1<<0), /**< Indicates a failure during the initialization of the flash safe execute mode. */
FLASH_SAFE_EXECUTE_ERASE_FAILURE = (1<<1), FLASH_SAFE_EXECUTE_ERASE_FAILURE = (1<<1), /**< Indicates a failure during the erase operation in flash safe execute mode. */
FLASH_SAFE_EXECUTE_PROGRAM_FAILURE = (1<<2), FLASH_SAFE_EXECUTE_PROGRAM_FAILURE = (1<<2), /**< Indicates a failure during the program operation in flash safe execute mode. */
FLASH_SIZE_READBACK_FAILURE = (1<<3), FLASH_SIZE_READBACK_FAILURE = (1<<3), /**< Indicates a failure in reading back the flash size. */
STDIO_INIT_FAILURE = (1<<4), STDIO_INIT_FAILURE = (1<<4), /**< Indicates a failure during the initialization of stdio. */
REBOOT_BY_WATCHDOG = (1<<5), REBOOT_BY_WATCHDOG = (1<<5), /**< Indicates that the system rebooted due to the watchdog timer. */
INVALID_DIRECTION = (1<<6), INVALID_DIRECTION = (1<<6), /**< Indicates an invalid direction was specified. */
} error_t; } error_t;
/**
* @enum direction_t
* @brief Enumeration for motor direction.
*
*/
typedef enum { typedef enum {
DIRECTION_FORWARD = 1, DIRECTION_FORWARD = 1, /**< Represents the forward direction */
DIRECTION_REVERSE = 0, DIRECTION_REVERSE = 0, /**< Represents the reverse direction. */
} direction_t; } direction_t;
//TODO: Continue implementation of speed step enum /**
* @brief Enum to define all speed steps.
*
*/
typedef enum { typedef enum {
SPEED_STEP_REVERSE_STOP = 0x00, // 00000000bin 000dec SPEED_STEP_REVERSE_STOP = 0x00, /**< 00000000bin 000dec */
SPEED_STEP_REVERSE_EMERGENCY_STOP = 0x01, // 00000001bin 001dec SPEED_STEP_REVERSE_EMERGENCY_STOP = 0x01, /**< 00000001bin 001dec */
SPEED_STEP_REVERSE_001 = 0x02, // 00000010bin 002dec SPEED_STEP_REVERSE_001 = 0x02, /**< 00000010bin 002dec */
SPEED_STEP_REVERSE_002 = 0x03, // 00000011bin 003dec SPEED_STEP_REVERSE_002 = 0x03, /**< 00000011bin 003dec */
SPEED_STEP_REVERSE_003 = 0x04, // 00000100bin 004dec SPEED_STEP_REVERSE_003 = 0x04, /**< 00000100bin 004dec */
SPEED_STEP_REVERSE_004 = 0x05, // 00000101bin 005dec SPEED_STEP_REVERSE_004 = 0x05, /**< 00000101bin 005dec */
SPEED_STEP_REVERSE_005 = 0x06, // 00000110bin 006dec SPEED_STEP_REVERSE_005 = 0x06, /**< 00000110bin 006dec */
SPEED_STEP_REVERSE_006 = 0x07, // 00000111bin 007dec SPEED_STEP_REVERSE_006 = 0x07, /**< 00000111bin 007dec */
SPEED_STEP_REVERSE_007 = 0x08, // 00001000bin 008dec SPEED_STEP_REVERSE_007 = 0x08, /**< 00001000bin 008dec */
SPEED_STEP_REVERSE_008 = 0x09, // 00001001bin 009dec SPEED_STEP_REVERSE_008 = 0x09, /**< 00001001bin 009dec */
SPEED_STEP_REVERSE_009 = 0x0A, // 00001010bin 010dec SPEED_STEP_REVERSE_009 = 0x0A, /**< 00001010bin 010dec */
SPEED_STEP_REVERSE_010 = 0x0B, // 00001011bin 011dec SPEED_STEP_REVERSE_010 = 0x0B, /**< 00001011bin 011dec */
SPEED_STEP_REVERSE_011 = 0x0C, // 00001100bin 012dec SPEED_STEP_REVERSE_011 = 0x0C, /**< 00001100bin 012dec */
SPEED_STEP_REVERSE_012 = 0x0D, // 00001101bin 013dec SPEED_STEP_REVERSE_012 = 0x0D, /**< 00001101bin 013dec */
SPEED_STEP_REVERSE_013 = 0x0E, // 00001110bin 014dec SPEED_STEP_REVERSE_013 = 0x0E, /**< 00001110bin 014dec */
SPEED_STEP_REVERSE_014 = 0x0F, // 00001111bin 015dec SPEED_STEP_REVERSE_014 = 0x0F, /**< 00001111bin 015dec */
SPEED_STEP_REVERSE_015 = 0x10, // 00010000bin 016dec SPEED_STEP_REVERSE_015 = 0x10, /**< 00010000bin 016dec */
SPEED_STEP_REVERSE_016 = 0x11, // 00010001bin 017dec SPEED_STEP_REVERSE_016 = 0x11, /**< 00010001bin 017dec */
SPEED_STEP_REVERSE_017 = 0x12, // 00010010bin 018dec SPEED_STEP_REVERSE_017 = 0x12, /**< 00010010bin 018dec */
SPEED_STEP_REVERSE_018 = 0x13, // 00010011bin 019dec SPEED_STEP_REVERSE_018 = 0x13, /**< 00010011bin 019dec */
SPEED_STEP_REVERSE_019 = 0x14, // 00010100bin 020dec SPEED_STEP_REVERSE_019 = 0x14, /**< 00010100bin 020dec */
SPEED_STEP_REVERSE_020 = 0x15, // 00010101bin 021dec SPEED_STEP_REVERSE_020 = 0x15, /**< 00010101bin 021dec */
SPEED_STEP_REVERSE_021 = 0x16, // 00010110bin 022dec SPEED_STEP_REVERSE_021 = 0x16, /**< 00010110bin 022dec */
SPEED_STEP_REVERSE_022 = 0x17, // 00010111bin 023dec SPEED_STEP_REVERSE_022 = 0x17, /**< 00010111bin 023dec */
SPEED_STEP_REVERSE_023 = 0x18, // 00011000bin 024dec SPEED_STEP_REVERSE_023 = 0x18, /**< 00011000bin 024dec */
SPEED_STEP_REVERSE_024 = 0x19, // 00011001bin 025dec SPEED_STEP_REVERSE_024 = 0x19, /**< 00011001bin 025dec */
SPEED_STEP_REVERSE_025 = 0x1A, // 00011010bin 026dec SPEED_STEP_REVERSE_025 = 0x1A, /**< 00011010bin 026dec */
SPEED_STEP_REVERSE_026 = 0x1B, // 00011011bin 027dec SPEED_STEP_REVERSE_026 = 0x1B, /**< 00011011bin 027dec */
SPEED_STEP_REVERSE_027 = 0x1C, // 00011100bin 028dec SPEED_STEP_REVERSE_027 = 0x1C, /**< 00011100bin 028dec */
SPEED_STEP_REVERSE_028 = 0x1D, // 00011101bin 029dec SPEED_STEP_REVERSE_028 = 0x1D, /**< 00011101bin 029dec */
SPEED_STEP_REVERSE_029 = 0x1E, // 00011110bin 030dec SPEED_STEP_REVERSE_029 = 0x1E, /**< 00011110bin 030dec */
SPEED_STEP_REVERSE_030 = 0x1F, // 00011111bin 031dec SPEED_STEP_REVERSE_030 = 0x1F, /**< 00011111bin 031dec */
SPEED_STEP_REVERSE_031 = 0x20, // 00100000bin 032dec SPEED_STEP_REVERSE_031 = 0x20, /**< 00100000bin 032dec */
SPEED_STEP_REVERSE_032 = 0x21, // 00100001bin 033dec SPEED_STEP_REVERSE_032 = 0x21, /**< 00100001bin 033dec */
SPEED_STEP_REVERSE_033 = 0x22, // 00100010bin 034dec SPEED_STEP_REVERSE_033 = 0x22, /**< 00100010bin 034dec */
SPEED_STEP_REVERSE_034 = 0x23, // 00100011bin 035dec SPEED_STEP_REVERSE_034 = 0x23, /**< 00100011bin 035dec */
SPEED_STEP_REVERSE_035 = 0x24, // 00100100bin 036dec SPEED_STEP_REVERSE_035 = 0x24, /**< 00100100bin 036dec */
SPEED_STEP_REVERSE_036 = 0x25, // 00100101bin 037dec SPEED_STEP_REVERSE_036 = 0x25, /**< 00100101bin 037dec */
SPEED_STEP_REVERSE_037 = 0x26, // 00100110bin 038dec SPEED_STEP_REVERSE_037 = 0x26, /**< 00100110bin 038dec */
SPEED_STEP_REVERSE_038 = 0x27, // 00100111bin 039dec SPEED_STEP_REVERSE_038 = 0x27, /**< 00100111bin 039dec */
SPEED_STEP_REVERSE_039 = 0x28, // 00101000bin 040dec SPEED_STEP_REVERSE_039 = 0x28, /**< 00101000bin 040dec */
SPEED_STEP_REVERSE_040 = 0x29, // 00101001bin 041dec SPEED_STEP_REVERSE_040 = 0x29, /**< 00101001bin 041dec */
SPEED_STEP_REVERSE_041 = 0x2A, // 00101010bin 042dec SPEED_STEP_REVERSE_041 = 0x2A, /**< 00101010bin 042dec */
SPEED_STEP_REVERSE_042 = 0x2B, // 00101011bin 043dec SPEED_STEP_REVERSE_042 = 0x2B, /**< 00101011bin 043dec */
SPEED_STEP_REVERSE_043 = 0x2C, // 00101100bin 044dec SPEED_STEP_REVERSE_043 = 0x2C, /**< 00101100bin 044dec */
SPEED_STEP_REVERSE_044 = 0x2D, // 00101101bin 045dec SPEED_STEP_REVERSE_044 = 0x2D, /**< 00101101bin 045dec */
SPEED_STEP_REVERSE_045 = 0x2E, // 00101110bin 046dec SPEED_STEP_REVERSE_045 = 0x2E, /**< 00101110bin 046dec */
SPEED_STEP_REVERSE_046 = 0x2F, // 00101111bin 047dec SPEED_STEP_REVERSE_046 = 0x2F, /**< 00101111bin 047dec */
SPEED_STEP_REVERSE_047 = 0x30, // 00110000bin 048dec SPEED_STEP_REVERSE_047 = 0x30, /**< 00110000bin 048dec */
SPEED_STEP_REVERSE_048 = 0x31, // 00110001bin 049dec SPEED_STEP_REVERSE_048 = 0x31, /**< 00110001bin 049dec */
SPEED_STEP_REVERSE_049 = 0x32, // 00110010bin 050dec SPEED_STEP_REVERSE_049 = 0x32, /**< 00110010bin 050dec */
SPEED_STEP_REVERSE_050 = 0x33, // 00110011bin 051dec SPEED_STEP_REVERSE_050 = 0x33, /**< 00110011bin 051dec */
SPEED_STEP_REVERSE_051 = 0x34, // 00110100bin 052dec SPEED_STEP_REVERSE_051 = 0x34, /**< 00110100bin 052dec */
SPEED_STEP_REVERSE_052 = 0x35, // 00110101bin 053dec SPEED_STEP_REVERSE_052 = 0x35, /**< 00110101bin 053dec */
SPEED_STEP_REVERSE_053 = 0x36, // 00110110bin 054dec SPEED_STEP_REVERSE_053 = 0x36, /**< 00110110bin 054dec */
SPEED_STEP_REVERSE_054 = 0x37, // 00110111bin 055dec SPEED_STEP_REVERSE_054 = 0x37, /**< 00110111bin 055dec */
SPEED_STEP_REVERSE_055 = 0x38, // 00111000bin 056dec SPEED_STEP_REVERSE_055 = 0x38, /**< 00111000bin 056dec */
SPEED_STEP_REVERSE_056 = 0x39, // 00111001bin 057dec SPEED_STEP_REVERSE_056 = 0x39, /**< 00111001bin 057dec */
SPEED_STEP_REVERSE_057 = 0x3A, // 00111010bin 058dec SPEED_STEP_REVERSE_057 = 0x3A, /**< 00111010bin 058dec */
SPEED_STEP_REVERSE_058 = 0x3B, // 00111011bin 059dec SPEED_STEP_REVERSE_058 = 0x3B, /**< 00111011bin 059dec */
SPEED_STEP_REVERSE_059 = 0x3C, // 00111100bin 060dec SPEED_STEP_REVERSE_059 = 0x3C, /**< 00111100bin 060dec */
SPEED_STEP_REVERSE_060 = 0x3D, // 00111101bin 061dec SPEED_STEP_REVERSE_060 = 0x3D, /**< 00111101bin 061dec */
SPEED_STEP_REVERSE_061 = 0x3E, // 00111110bin 062dec SPEED_STEP_REVERSE_061 = 0x3E, /**< 00111110bin 062dec */
SPEED_STEP_REVERSE_062 = 0x3F, // 00111111bin 063dec SPEED_STEP_REVERSE_062 = 0x3F, /**< 00111111bin 063dec */
SPEED_STEP_REVERSE_063 = 0x40, // 01000000bin 064dec SPEED_STEP_REVERSE_063 = 0x40, /**< 01000000bin 064dec */
SPEED_STEP_REVERSE_064 = 0x41, // 01000001bin 065dec SPEED_STEP_REVERSE_064 = 0x41, /**< 01000001bin 065dec */
SPEED_STEP_REVERSE_065 = 0x42, // 01000010bin 066dec SPEED_STEP_REVERSE_065 = 0x42, /**< 01000010bin 066dec */
SPEED_STEP_REVERSE_066 = 0x43, // 01000011bin 067dec SPEED_STEP_REVERSE_066 = 0x43, /**< 01000011bin 067dec */
SPEED_STEP_REVERSE_067 = 0x44, // 01000100bin 068dec SPEED_STEP_REVERSE_067 = 0x44, /**< 01000100bin 068dec */
SPEED_STEP_REVERSE_068 = 0x45, // 01000101bin 069dec SPEED_STEP_REVERSE_068 = 0x45, /**< 01000101bin 069dec */
SPEED_STEP_REVERSE_069 = 0x46, // 01000110bin 070dec SPEED_STEP_REVERSE_069 = 0x46, /**< 01000110bin 070dec */
SPEED_STEP_REVERSE_070 = 0x47, // 01000111bin 071dec SPEED_STEP_REVERSE_070 = 0x47, /**< 01000111bin 071dec */
SPEED_STEP_REVERSE_071 = 0x48, // 01001000bin 072dec SPEED_STEP_REVERSE_071 = 0x48, /**< 01001000bin 072dec */
SPEED_STEP_REVERSE_072 = 0x49, // 01001001bin 073dec SPEED_STEP_REVERSE_072 = 0x49, /**< 01001001bin 073dec */
SPEED_STEP_REVERSE_073 = 0x4A, // 01001010bin 074dec SPEED_STEP_REVERSE_073 = 0x4A, /**< 01001010bin 074dec */
SPEED_STEP_REVERSE_074 = 0x4B, // 01001011bin 075dec SPEED_STEP_REVERSE_074 = 0x4B, /**< 01001011bin 075dec */
SPEED_STEP_REVERSE_075 = 0x4C, // 01001100bin 076dec SPEED_STEP_REVERSE_075 = 0x4C, /**< 01001100bin 076dec */
SPEED_STEP_REVERSE_076 = 0x4D, // 01001101bin 077dec SPEED_STEP_REVERSE_076 = 0x4D, /**< 01001101bin 077dec */
SPEED_STEP_REVERSE_077 = 0x4E, // 01001110bin 078dec SPEED_STEP_REVERSE_077 = 0x4E, /**< 01001110bin 078dec */
SPEED_STEP_REVERSE_078 = 0x4F, // 01001111bin 079dec SPEED_STEP_REVERSE_078 = 0x4F, /**< 01001111bin 079dec */
SPEED_STEP_REVERSE_079 = 0x50, // 01010000bin 080dec SPEED_STEP_REVERSE_079 = 0x50, /**< 01010000bin 080dec */
SPEED_STEP_REVERSE_080 = 0x51, // 01010001bin 081dec SPEED_STEP_REVERSE_080 = 0x51, /**< 01010001bin 081dec */
SPEED_STEP_REVERSE_081 = 0x52, // 01010010bin 082dec SPEED_STEP_REVERSE_081 = 0x52, /**< 01010010bin 082dec */
SPEED_STEP_REVERSE_082 = 0x53, // 01010011bin 083dec SPEED_STEP_REVERSE_082 = 0x53, /**< 01010011bin 083dec */
SPEED_STEP_REVERSE_083 = 0x54, // 01010100bin 084dec SPEED_STEP_REVERSE_083 = 0x54, /**< 01010100bin 084dec */
SPEED_STEP_REVERSE_084 = 0x55, // 01010101bin 085dec SPEED_STEP_REVERSE_084 = 0x55, /**< 01010101bin 085dec */
SPEED_STEP_REVERSE_085 = 0x56, // 01010110bin 086dec SPEED_STEP_REVERSE_085 = 0x56, /**< 01010110bin 086dec */
SPEED_STEP_REVERSE_086 = 0x57, // 01010111bin 087dec SPEED_STEP_REVERSE_086 = 0x57, /**< 01010111bin 087dec */
SPEED_STEP_REVERSE_087 = 0x58, // 01011000bin 088dec SPEED_STEP_REVERSE_087 = 0x58, /**< 01011000bin 088dec */
SPEED_STEP_REVERSE_088 = 0x59, // 01011001bin 089dec SPEED_STEP_REVERSE_088 = 0x59, /**< 01011001bin 089dec */
SPEED_STEP_REVERSE_089 = 0x5A, // 01011010bin 090dec SPEED_STEP_REVERSE_089 = 0x5A, /**< 01011010bin 090dec */
SPEED_STEP_REVERSE_090 = 0x5B, // 01011011bin 091dec SPEED_STEP_REVERSE_090 = 0x5B, /**< 01011011bin 091dec */
SPEED_STEP_REVERSE_091 = 0x5C, // 01011100bin 092dec SPEED_STEP_REVERSE_091 = 0x5C, /**< 01011100bin 092dec */
SPEED_STEP_REVERSE_092 = 0x5D, // 01011101bin 093dec SPEED_STEP_REVERSE_092 = 0x5D, /**< 01011101bin 093dec */
SPEED_STEP_REVERSE_093 = 0x5E, // 01011110bin 094dec SPEED_STEP_REVERSE_093 = 0x5E, /**< 01011110bin 094dec */
SPEED_STEP_REVERSE_094 = 0x5F, // 01011111bin 095dec SPEED_STEP_REVERSE_094 = 0x5F, /**< 01011111bin 095dec */
SPEED_STEP_REVERSE_095 = 0x60, // 01100000bin 096dec SPEED_STEP_REVERSE_095 = 0x60, /**< 01100000bin 096dec */
SPEED_STEP_REVERSE_096 = 0x61, // 01100001bin 097dec SPEED_STEP_REVERSE_096 = 0x61, /**< 01100001bin 097dec */
SPEED_STEP_REVERSE_097 = 0x62, // 01100010bin 098dec SPEED_STEP_REVERSE_097 = 0x62, /**< 01100010bin 098dec */
SPEED_STEP_REVERSE_098 = 0x63, // 01100011bin 099dec SPEED_STEP_REVERSE_098 = 0x63, /**< 01100011bin 099dec */
SPEED_STEP_REVERSE_099 = 0x64, // 01100100bin 100dec SPEED_STEP_REVERSE_099 = 0x64, /**< 01100100bin 100dec */
SPEED_STEP_REVERSE_100 = 0x65, // 01100101bin 101dec SPEED_STEP_REVERSE_100 = 0x65, /**< 01100101bin 101dec */
SPEED_STEP_REVERSE_101 = 0x66, // 01100110bin 102dec SPEED_STEP_REVERSE_101 = 0x66, /**< 01100110bin 102dec */
SPEED_STEP_REVERSE_102 = 0x67, // 01100111bin 103dec SPEED_STEP_REVERSE_102 = 0x67, /**< 01100111bin 103dec */
SPEED_STEP_REVERSE_103 = 0x68, // 01101000bin 104dec SPEED_STEP_REVERSE_103 = 0x68, /**< 01101000bin 104dec */
SPEED_STEP_REVERSE_104 = 0x69, // 01101001bin 105dec SPEED_STEP_REVERSE_104 = 0x69, /**< 01101001bin 105dec */
SPEED_STEP_REVERSE_105 = 0x6A, // 01101010bin 106dec SPEED_STEP_REVERSE_105 = 0x6A, /**< 01101010bin 106dec */
SPEED_STEP_REVERSE_106 = 0x6B, // 01101011bin 107dec SPEED_STEP_REVERSE_106 = 0x6B, /**< 01101011bin 107dec */
SPEED_STEP_REVERSE_107 = 0x6C, // 01101100bin 108dec SPEED_STEP_REVERSE_107 = 0x6C, /**< 01101100bin 108dec */
SPEED_STEP_REVERSE_108 = 0x6D, // 01101101bin 109dec SPEED_STEP_REVERSE_108 = 0x6D, /**< 01101101bin 109dec */
SPEED_STEP_REVERSE_109 = 0x6E, // 01101110bin 110dec SPEED_STEP_REVERSE_109 = 0x6E, /**< 01101110bin 110dec */
SPEED_STEP_REVERSE_110 = 0x6F, // 01101111bin 111dec SPEED_STEP_REVERSE_110 = 0x6F, /**< 01101111bin 111dec */
SPEED_STEP_REVERSE_111 = 0x70, // 01110000bin 112dec SPEED_STEP_REVERSE_111 = 0x70, /**< 01110000bin 112dec */
SPEED_STEP_REVERSE_112 = 0x71, // 01110001bin 113dec SPEED_STEP_REVERSE_112 = 0x71, /**< 01110001bin 113dec */
SPEED_STEP_REVERSE_113 = 0x72, // 01110010bin 114dec SPEED_STEP_REVERSE_113 = 0x72, /**< 01110010bin 114dec */
SPEED_STEP_REVERSE_114 = 0x73, // 01110011bin 115dec SPEED_STEP_REVERSE_114 = 0x73, /**< 01110011bin 115dec */
SPEED_STEP_REVERSE_115 = 0x74, // 01110100bin 116dec SPEED_STEP_REVERSE_115 = 0x74, /**< 01110100bin 116dec */
SPEED_STEP_REVERSE_116 = 0x75, // 01110101bin 117dec SPEED_STEP_REVERSE_116 = 0x75, /**< 01110101bin 117dec */
SPEED_STEP_REVERSE_117 = 0x76, // 01110110bin 118dec SPEED_STEP_REVERSE_117 = 0x76, /**< 01110110bin 118dec */
SPEED_STEP_REVERSE_118 = 0x77, // 01110111bin 119dec SPEED_STEP_REVERSE_118 = 0x77, /**< 01110111bin 119dec */
SPEED_STEP_REVERSE_119 = 0x78, // 01111000bin 120dec SPEED_STEP_REVERSE_119 = 0x78, /**< 01111000bin 120dec */
SPEED_STEP_REVERSE_120 = 0x79, // 01111001bin 121dec SPEED_STEP_REVERSE_120 = 0x79, /**< 01111001bin 121dec */
SPEED_STEP_REVERSE_121 = 0x7A, // 01111010bin 122dec SPEED_STEP_REVERSE_121 = 0x7A, /**< 01111010bin 122dec */
SPEED_STEP_REVERSE_122 = 0x7B, // 01111011bin 123dec SPEED_STEP_REVERSE_122 = 0x7B, /**< 01111011bin 123dec */
SPEED_STEP_REVERSE_123 = 0x7C, // 01111100bin 124dec SPEED_STEP_REVERSE_123 = 0x7C, /**< 01111100bin 124dec */
SPEED_STEP_REVERSE_124 = 0x7D, // 01111101bin 125dec SPEED_STEP_REVERSE_124 = 0x7D, /**< 01111101bin 125dec */
SPEED_STEP_REVERSE_125 = 0x7E, // 01111110bin 126dec SPEED_STEP_REVERSE_125 = 0x7E, /**< 01111110bin 126dec */
SPEED_STEP_REVERSE_126 = 0x7F, // 01111111bin 127dec SPEED_STEP_REVERSE_126 = 0x7F, /**< 01111111bin 127dec */
SPEED_STEP_FORWARD_STOP = 0x80, /**< 10000000bin 128dec */
SPEED_STEP_FORWARD_STOP = 0x80, // 10000000bin 128dec SPEED_STEP_FORWARD_EMERGENCY_STOP = 0x81, /**< 10000001bin 129dec */
SPEED_STEP_FORWARD_EMERGENCY_STOP = 0x81, // 10000001bin 129dec SPEED_STEP_FORWARD_001 = 0x82, /**< 10000010bin 130dec */
SPEED_STEP_FORWARD_001 = 0x82, // 10000010bin 130dec SPEED_STEP_FORWARD_002 = 0x83, /**< 10000011bin 131dec */
SPEED_STEP_FORWARD_002 = 0x83, // 10000011bin 131dec SPEED_STEP_FORWARD_003 = 0x84, /**< 10000100bin 132dec */
SPEED_STEP_FORWARD_003 = 0x84, // 10000100bin 132dec SPEED_STEP_FORWARD_004 = 0x85, /**< 10000101bin 133dec */
SPEED_STEP_FORWARD_004 = 0x85, // 10000101bin 133dec SPEED_STEP_FORWARD_005 = 0x86, /**< 10000110bin 134dec */
SPEED_STEP_FORWARD_005 = 0x86, // 10000110bin 134dec SPEED_STEP_FORWARD_006 = 0x87, /**< 10000111bin 135dec */
SPEED_STEP_FORWARD_006 = 0x87, // 10000111bin 135dec SPEED_STEP_FORWARD_007 = 0x88, /**< 10001000bin 136dec */
SPEED_STEP_FORWARD_007 = 0x88, // 10001000bin 136dec SPEED_STEP_FORWARD_008 = 0x89, /**< 10001001bin 137dec */
SPEED_STEP_FORWARD_008 = 0x89, // 10001001bin 137dec SPEED_STEP_FORWARD_009 = 0x8A, /**< 10001010bin 138dec */
SPEED_STEP_FORWARD_009 = 0x8A, // 10001010bin 138dec SPEED_STEP_FORWARD_010 = 0x8B, /**< 10001011bin 139dec */
SPEED_STEP_FORWARD_010 = 0x8B, // 10001011bin 139dec SPEED_STEP_FORWARD_011 = 0x8C, /**< 10001100bin 140dec */
SPEED_STEP_FORWARD_011 = 0x8C, // 10001100bin 140dec SPEED_STEP_FORWARD_012 = 0x8D, /**< 10001101bin 141dec */
SPEED_STEP_FORWARD_012 = 0x8D, // 10001101bin 141dec SPEED_STEP_FORWARD_013 = 0x8E, /**< 10001110bin 142dec */
SPEED_STEP_FORWARD_013 = 0x8E, // 10001110bin 142dec SPEED_STEP_FORWARD_014 = 0x8F, /**< 10001111bin 143dec */
SPEED_STEP_FORWARD_014 = 0x8F, // 10001111bin 143dec SPEED_STEP_FORWARD_015 = 0x90, /**< 10010000bin 144dec */
SPEED_STEP_FORWARD_015 = 0x90, // 10010000bin 144dec SPEED_STEP_FORWARD_016 = 0x91, /**< 10010001bin 145dec */
SPEED_STEP_FORWARD_016 = 0x91, // 10010001bin 145dec SPEED_STEP_FORWARD_017 = 0x92, /**< 10010010bin 146dec */
SPEED_STEP_FORWARD_017 = 0x92, // 10010010bin 146dec SPEED_STEP_FORWARD_018 = 0x93, /**< 10010011bin 147dec */
SPEED_STEP_FORWARD_018 = 0x93, // 10010011bin 147dec SPEED_STEP_FORWARD_019 = 0x94, /**< 10010100bin 148dec */
SPEED_STEP_FORWARD_019 = 0x94, // 10010100bin 148dec SPEED_STEP_FORWARD_020 = 0x95, /**< 10010101bin 149dec */
SPEED_STEP_FORWARD_020 = 0x95, // 10010101bin 149dec SPEED_STEP_FORWARD_021 = 0x96, /**< 10010110bin 150dec */
SPEED_STEP_FORWARD_021 = 0x96, // 10010110bin 150dec SPEED_STEP_FORWARD_022 = 0x97, /**< 10010111bin 151dec */
SPEED_STEP_FORWARD_022 = 0x97, // 10010111bin 151dec SPEED_STEP_FORWARD_023 = 0x98, /**< 10011000bin 152dec */
SPEED_STEP_FORWARD_023 = 0x98, // 10011000bin 152dec SPEED_STEP_FORWARD_024 = 0x99, /**< 10011001bin 153dec */
SPEED_STEP_FORWARD_024 = 0x99, // 10011001bin 153dec SPEED_STEP_FORWARD_025 = 0x9A, /**< 10011010bin 154dec */
SPEED_STEP_FORWARD_025 = 0x9A, // 10011010bin 154dec SPEED_STEP_FORWARD_026 = 0x9B, /**< 10011011bin 155dec */
SPEED_STEP_FORWARD_026 = 0x9B, // 10011011bin 155dec SPEED_STEP_FORWARD_027 = 0x9C, /**< 10011100bin 156dec */
SPEED_STEP_FORWARD_027 = 0x9C, // 10011100bin 156dec SPEED_STEP_FORWARD_028 = 0x9D, /**< 10011101bin 157dec */
SPEED_STEP_FORWARD_028 = 0x9D, // 10011101bin 157dec SPEED_STEP_FORWARD_029 = 0x9E, /**< 10011110bin 158dec */
SPEED_STEP_FORWARD_029 = 0x9E, // 10011110bin 158dec SPEED_STEP_FORWARD_030 = 0x9F, /**< 10011111bin 159dec */
SPEED_STEP_FORWARD_030 = 0x9F, // 10011111bin 159dec SPEED_STEP_FORWARD_031 = 0xA0, /**< 10100000bin 160dec */
SPEED_STEP_FORWARD_031 = 0xA0, // 10100000bin 160dec SPEED_STEP_FORWARD_032 = 0xA1, /**< 10100001bin 161dec */
SPEED_STEP_FORWARD_032 = 0xA1, // 10100001bin 161dec SPEED_STEP_FORWARD_033 = 0xA2, /**< 10100010bin 162dec */
SPEED_STEP_FORWARD_033 = 0xA2, // 10100010bin 162dec SPEED_STEP_FORWARD_034 = 0xA3, /**< 10100011bin 163dec */
SPEED_STEP_FORWARD_034 = 0xA3, // 10100011bin 163dec SPEED_STEP_FORWARD_035 = 0xA4, /**< 10100100bin 164dec */
SPEED_STEP_FORWARD_035 = 0xA4, // 10100100bin 164dec SPEED_STEP_FORWARD_036 = 0xA5, /**< 10100101bin 165dec */
SPEED_STEP_FORWARD_036 = 0xA5, // 10100101bin 165dec SPEED_STEP_FORWARD_037 = 0xA6, /**< 10100110bin 166dec */
SPEED_STEP_FORWARD_037 = 0xA6, // 10100110bin 166dec SPEED_STEP_FORWARD_038 = 0xA7, /**< 10100111bin 167dec */
SPEED_STEP_FORWARD_038 = 0xA7, // 10100111bin 167dec SPEED_STEP_FORWARD_039 = 0xA8, /**< 10101000bin 168dec */
SPEED_STEP_FORWARD_039 = 0xA8, // 10101000bin 168dec SPEED_STEP_FORWARD_040 = 0xA9, /**< 10101001bin 169dec */
SPEED_STEP_FORWARD_040 = 0xA9, // 10101001bin 169dec SPEED_STEP_FORWARD_041 = 0xAA, /**< 10101010bin 170dec */
SPEED_STEP_FORWARD_041 = 0xAA, // 10101010bin 170dec SPEED_STEP_FORWARD_042 = 0xAB, /**< 10101011bin 171dec */
SPEED_STEP_FORWARD_042 = 0xAB, // 10101011bin 171dec SPEED_STEP_FORWARD_043 = 0xAC, /**< 10101100bin 172dec */
SPEED_STEP_FORWARD_043 = 0xAC, // 10101100bin 172dec SPEED_STEP_FORWARD_044 = 0xAD, /**< 10101101bin 173dec */
SPEED_STEP_FORWARD_044 = 0xAD, // 10101101bin 173dec SPEED_STEP_FORWARD_045 = 0xAE, /**< 10101110bin 174dec */
SPEED_STEP_FORWARD_045 = 0xAE, // 10101110bin 174dec SPEED_STEP_FORWARD_046 = 0xAF, /**< 10101111bin 175dec */
SPEED_STEP_FORWARD_046 = 0xAF, // 10101111bin 175dec SPEED_STEP_FORWARD_047 = 0xB0, /**< 10110000bin 176dec */
SPEED_STEP_FORWARD_047 = 0xB0, // 10110000bin 176dec SPEED_STEP_FORWARD_048 = 0xB1, /**< 10110001bin 177dec */
SPEED_STEP_FORWARD_048 = 0xB1, // 10110001bin 177dec SPEED_STEP_FORWARD_049 = 0xB2, /**< 10110010bin 178dec */
SPEED_STEP_FORWARD_049 = 0xB2, // 10110010bin 178dec SPEED_STEP_FORWARD_050 = 0xB3, /**< 10110011bin 179dec */
SPEED_STEP_FORWARD_050 = 0xB3, // 10110011bin 179dec SPEED_STEP_FORWARD_051 = 0xB4, /**< 10110100bin 180dec */
SPEED_STEP_FORWARD_051 = 0xB4, // 10110100bin 180dec SPEED_STEP_FORWARD_052 = 0xB5, /**< 10110101bin 181dec */
SPEED_STEP_FORWARD_052 = 0xB5, // 10110101bin 181dec SPEED_STEP_FORWARD_053 = 0xB6, /**< 10110110bin 182dec */
SPEED_STEP_FORWARD_053 = 0xB6, // 10110110bin 182dec SPEED_STEP_FORWARD_054 = 0xB7, /**< 10110111bin 183dec */
SPEED_STEP_FORWARD_054 = 0xB7, // 10110111bin 183dec SPEED_STEP_FORWARD_055 = 0xB8, /**< 10111000bin 184dec */
SPEED_STEP_FORWARD_055 = 0xB8, // 10111000bin 184dec SPEED_STEP_FORWARD_056 = 0xB9, /**< 10111001bin 185dec */
SPEED_STEP_FORWARD_056 = 0xB9, // 10111001bin 185dec SPEED_STEP_FORWARD_057 = 0xBA, /**< 10111010bin 186dec */
SPEED_STEP_FORWARD_057 = 0xBA, // 10111010bin 186dec SPEED_STEP_FORWARD_058 = 0xBB, /**< 10111011bin 187dec */
SPEED_STEP_FORWARD_058 = 0xBB, // 10111011bin 187dec SPEED_STEP_FORWARD_059 = 0xBC, /**< 10111100bin 188dec */
SPEED_STEP_FORWARD_059 = 0xBC, // 10111100bin 188dec SPEED_STEP_FORWARD_060 = 0xBD, /**< 10111101bin 189dec */
SPEED_STEP_FORWARD_060 = 0xBD, // 10111101bin 189dec SPEED_STEP_FORWARD_061 = 0xBE, /**< 10111110bin 190dec */
SPEED_STEP_FORWARD_061 = 0xBE, // 10111110bin 190dec SPEED_STEP_FORWARD_062 = 0xBF, /**< 10111111bin 191dec */
SPEED_STEP_FORWARD_062 = 0xBF, // 10111111bin 191dec SPEED_STEP_FORWARD_063 = 0xC0, /**< 11000000bin 192dec */
SPEED_STEP_FORWARD_063 = 0xC0, // 11000000bin 192dec SPEED_STEP_FORWARD_064 = 0xC1, /**< 11000001bin 193dec */
SPEED_STEP_FORWARD_064 = 0xC1, // 11000001bin 193dec SPEED_STEP_FORWARD_065 = 0xC2, /**< 11000010bin 194dec */
SPEED_STEP_FORWARD_065 = 0xC2, // 11000010bin 194dec SPEED_STEP_FORWARD_066 = 0xC3, /**< 11000011bin 195dec */
SPEED_STEP_FORWARD_066 = 0xC3, // 11000011bin 195dec SPEED_STEP_FORWARD_067 = 0xC4, /**< 11000100bin 196dec */
SPEED_STEP_FORWARD_067 = 0xC4, // 11000100bin 196dec SPEED_STEP_FORWARD_068 = 0xC5, /**< 11000101bin 197dec */
SPEED_STEP_FORWARD_068 = 0xC5, // 11000101bin 197dec SPEED_STEP_FORWARD_069 = 0xC6, /**< 11000110bin 198dec */
SPEED_STEP_FORWARD_069 = 0xC6, // 11000110bin 198dec SPEED_STEP_FORWARD_070 = 0xC7, /**< 11000111bin 199dec */
SPEED_STEP_FORWARD_070 = 0xC7, // 11000111bin 199dec SPEED_STEP_FORWARD_071 = 0xC8, /**< 11001000bin 200dec */
SPEED_STEP_FORWARD_071 = 0xC8, // 11001000bin 200dec SPEED_STEP_FORWARD_072 = 0xC9, /**< 11001001bin 201dec */
SPEED_STEP_FORWARD_072 = 0xC9, // 11001001bin 201dec SPEED_STEP_FORWARD_073 = 0xCA, /**< 11001010bin 202dec */
SPEED_STEP_FORWARD_073 = 0xCA, // 11001010bin 202dec SPEED_STEP_FORWARD_074 = 0xCB, /**< 11001011bin 203dec */
SPEED_STEP_FORWARD_074 = 0xCB, // 11001011bin 203dec SPEED_STEP_FORWARD_075 = 0xCC, /**< 11001100bin 204dec */
SPEED_STEP_FORWARD_075 = 0xCC, // 11001100bin 204dec SPEED_STEP_FORWARD_076 = 0xCD, /**< 11001101bin 205dec */
SPEED_STEP_FORWARD_076 = 0xCD, // 11001101bin 205dec SPEED_STEP_FORWARD_077 = 0xCE, /**< 11001110bin 206dec */
SPEED_STEP_FORWARD_077 = 0xCE, // 11001110bin 206dec SPEED_STEP_FORWARD_078 = 0xCF, /**< 11001111bin 207dec */
SPEED_STEP_FORWARD_078 = 0xCF, // 11001111bin 207dec SPEED_STEP_FORWARD_079 = 0xD0, /**< 11010000bin 208dec */
SPEED_STEP_FORWARD_079 = 0xD0, // 11010000bin 208dec SPEED_STEP_FORWARD_080 = 0xD1, /**< 11010001bin 209dec */
SPEED_STEP_FORWARD_080 = 0xD1, // 11010001bin 209dec SPEED_STEP_FORWARD_081 = 0xD2, /**< 11010010bin 210dec */
SPEED_STEP_FORWARD_081 = 0xD2, // 11010010bin 210dec SPEED_STEP_FORWARD_082 = 0xD3, /**< 11010011bin 211dec */
SPEED_STEP_FORWARD_082 = 0xD3, // 11010011bin 211dec SPEED_STEP_FORWARD_083 = 0xD4, /**< 11010100bin 212dec */
SPEED_STEP_FORWARD_083 = 0xD4, // 11010100bin 212dec SPEED_STEP_FORWARD_084 = 0xD5, /**< 11010101bin 213dec */
SPEED_STEP_FORWARD_084 = 0xD5, // 11010101bin 213dec SPEED_STEP_FORWARD_085 = 0xD6, /**< 11010110bin 214dec */
SPEED_STEP_FORWARD_085 = 0xD6, // 11010110bin 214dec SPEED_STEP_FORWARD_086 = 0xD7, /**< 11010111bin 215dec */
SPEED_STEP_FORWARD_086 = 0xD7, // 11010111bin 215dec SPEED_STEP_FORWARD_087 = 0xD8, /**< 11011000bin 216dec */
SPEED_STEP_FORWARD_087 = 0xD8, // 11011000bin 216dec SPEED_STEP_FORWARD_088 = 0xD9, /**< 11011001bin 217dec */
SPEED_STEP_FORWARD_088 = 0xD9, // 11011001bin 217dec SPEED_STEP_FORWARD_089 = 0xDA, /**< 11011010bin 218dec */
SPEED_STEP_FORWARD_089 = 0xDA, // 11011010bin 218dec SPEED_STEP_FORWARD_090 = 0xDB, /**< 11011011bin 219dec */
SPEED_STEP_FORWARD_090 = 0xDB, // 11011011bin 219dec SPEED_STEP_FORWARD_091 = 0xDC, /**< 11011100bin 220dec */
SPEED_STEP_FORWARD_091 = 0xDC, // 11011100bin 220dec SPEED_STEP_FORWARD_092 = 0xDD, /**< 11011101bin 221dec */
SPEED_STEP_FORWARD_092 = 0xDD, // 11011101bin 221dec SPEED_STEP_FORWARD_093 = 0xDE, /**< 11011110bin 222dec */
SPEED_STEP_FORWARD_093 = 0xDE, // 11011110bin 222dec SPEED_STEP_FORWARD_094 = 0xDF, /**< 11011111bin 223dec */
SPEED_STEP_FORWARD_094 = 0xDF, // 11011111bin 223dec SPEED_STEP_FORWARD_095 = 0xE0, /**< 11100000bin 224dec */
SPEED_STEP_FORWARD_095 = 0xE0, // 11100000bin 224dec SPEED_STEP_FORWARD_096 = 0xE1, /**< 11100001bin 225dec */
SPEED_STEP_FORWARD_096 = 0xE1, // 11100001bin 225dec SPEED_STEP_FORWARD_097 = 0xE2, /**< 11100010bin 226dec */
SPEED_STEP_FORWARD_097 = 0xE2, // 11100010bin 226dec SPEED_STEP_FORWARD_098 = 0xE3, /**< 11100011bin 227dec */
SPEED_STEP_FORWARD_098 = 0xE3, // 11100011bin 227dec SPEED_STEP_FORWARD_099 = 0xE4, /**< 11100100bin 228dec */
SPEED_STEP_FORWARD_099 = 0xE4, // 11100100bin 228dec SPEED_STEP_FORWARD_100 = 0xE5, /**< 11100101bin 229dec */
SPEED_STEP_FORWARD_100 = 0xE5, // 11100101bin 229dec SPEED_STEP_FORWARD_101 = 0xE6, /**< 11100110bin 230dec */
SPEED_STEP_FORWARD_101 = 0xE6, // 11100110bin 230dec SPEED_STEP_FORWARD_102 = 0xE7, /**< 11100111bin 231dec */
SPEED_STEP_FORWARD_102 = 0xE7, // 11100111bin 231dec SPEED_STEP_FORWARD_103 = 0xE8, /**< 11101000bin 232dec */
SPEED_STEP_FORWARD_103 = 0xE8, // 11101000bin 232dec SPEED_STEP_FORWARD_104 = 0xE9, /**< 11101001bin 233dec */
SPEED_STEP_FORWARD_104 = 0xE9, // 11101001bin 233dec SPEED_STEP_FORWARD_105 = 0xEA, /**< 11101010bin 234dec */
SPEED_STEP_FORWARD_105 = 0xEA, // 11101010bin 234dec SPEED_STEP_FORWARD_106 = 0xEB, /**< 11101011bin 235dec */
SPEED_STEP_FORWARD_106 = 0xEB, // 11101011bin 235dec SPEED_STEP_FORWARD_107 = 0xEC, /**< 11101100bin 236dec */
SPEED_STEP_FORWARD_107 = 0xEC, // 11101100bin 236dec SPEED_STEP_FORWARD_108 = 0xED, /**< 11101101bin 237dec */
SPEED_STEP_FORWARD_108 = 0xED, // 11101101bin 237dec SPEED_STEP_FORWARD_109 = 0xEE, /**< 11101110bin 238dec */
SPEED_STEP_FORWARD_109 = 0xEE, // 11101110bin 238dec SPEED_STEP_FORWARD_110 = 0xEF, /**< 11101111bin 239dec */
SPEED_STEP_FORWARD_110 = 0xEF, // 11101111bin 239dec SPEED_STEP_FORWARD_111 = 0xF0, /**< 11110000bin 240dec */
SPEED_STEP_FORWARD_111 = 0xF0, // 11110000bin 240dec SPEED_STEP_FORWARD_112 = 0xF1, /**< 11110001bin 241dec */
SPEED_STEP_FORWARD_112 = 0xF1, // 11110001bin 241dec SPEED_STEP_FORWARD_113 = 0xF2, /**< 11110010bin 242dec */
SPEED_STEP_FORWARD_113 = 0xF2, // 11110010bin 242dec SPEED_STEP_FORWARD_114 = 0xF3, /**< 11110011bin 243dec */
SPEED_STEP_FORWARD_114 = 0xF3, // 11110011bin 243dec SPEED_STEP_FORWARD_115 = 0xF4, /**< 11110100bin 244dec */
SPEED_STEP_FORWARD_115 = 0xF4, // 11110100bin 244dec SPEED_STEP_FORWARD_116 = 0xF5, /**< 11110101bin 245dec */
SPEED_STEP_FORWARD_116 = 0xF5, // 11110101bin 245dec SPEED_STEP_FORWARD_117 = 0xF6, /**< 11110110bin 246dec */
SPEED_STEP_FORWARD_117 = 0xF6, // 11110110bin 246dec SPEED_STEP_FORWARD_118 = 0xF7, /**< 11110111bin 247dec */
SPEED_STEP_FORWARD_118 = 0xF7, // 11110111bin 247dec SPEED_STEP_FORWARD_119 = 0xF8, /**< 11111000bin 248dec */
SPEED_STEP_FORWARD_119 = 0xF8, // 11111000bin 248dec SPEED_STEP_FORWARD_120 = 0xF9, /**< 11111001bin 249dec */
SPEED_STEP_FORWARD_120 = 0xF9, // 11111001bin 249dec SPEED_STEP_FORWARD_121 = 0xFA, /**< 11111010bin 250dec */
SPEED_STEP_FORWARD_121 = 0xFA, // 11111010bin 250dec SPEED_STEP_FORWARD_122 = 0xFB, /**< 11111011bin 251dec */
SPEED_STEP_FORWARD_122 = 0xFB, // 11111011bin 251dec SPEED_STEP_FORWARD_123 = 0xFC, /**< 11111100bin 252dec */
SPEED_STEP_FORWARD_123 = 0xFC, // 11111100bin 252dec SPEED_STEP_FORWARD_124 = 0xFD, /**< 11111101bin 253dec */
SPEED_STEP_FORWARD_124 = 0xFD, // 11111101bin 253dec SPEED_STEP_FORWARD_125 = 0xFE, /**< 11111110bin 254dec */
SPEED_STEP_FORWARD_125 = 0xFE, // 11111110bin 254dec SPEED_STEP_FORWARD_126 = 0xFF, /**< 11111111bin 255dec */
SPEED_STEP_FORWARD_126 = 0xFF, // 11111111bin 255dec
} speed_step_t; } speed_step_t;
extern repeating_timer_t pid_control_timer; /**
extern repeating_timer_t speed_helper_timer; * @brief Pointer to the uint8_t array in flash which stores the CVs.
*/
extern const uint8_t *CV_ARRAY_FLASH; extern const uint8_t *CV_ARRAY_FLASH;
/**
* @brief Target speed step for the decoder.
*
* This external variable represents the desired speed step that the decoder
* should aim to achieve.
*/
extern speed_step_t speed_step_target; extern speed_step_t speed_step_target;
/**
* @brief Previous target speed step.
*
* This variable holds the previous target speed step value for the decoder.
* It is used to keep track of the last speed step that was set.
*/
extern speed_step_t speed_step_target_prev; extern speed_step_t speed_step_target_prev;
/**
* @brief Indicates whether the CV setup check has been completed.
*
* This flag is used to track the status of the CV setup check.
* When the check is done, this variable should is set to true by core 0.
*/
extern bool cv_setup_check_done; extern bool cv_setup_check_done;
/**
* @brief Indicates whether the core initialization for safe flash execution is complete.
*
* This flag is used to signal the completion of the flash safe execute core initialization.
* When the initialization is done this variable is set to true by core 1.
*/
extern bool flash_safe_execute_core_init_done; extern bool flash_safe_execute_core_init_done;
/**
* @brief Global variable to hold the current error state.
*
* This variable is used to track the error state.
*/
extern error_t error_state;
/**
* @brief Entry point for the second core (core 1).
*
* This function is the entry point for the second core, basically the main() of core1.
*/
void core1_entry(); void core1_entry();
/**
* @brief Retrieves a 32-bit Configuration Variable (CV) starting from the specified index.
*
* This function reads and returns a 32-bit CV value from the given starting index.
*
* @param CV_start_index The starting index of the 32-bit CV to be retrieved.
* @return The 32-bit CV value.
*/
uint32_t get_32bit_CV (uint16_t CV_start_index); uint32_t get_32bit_CV (uint16_t CV_start_index);
/**
* @brief Retrieves a 16-bit Configuration Variable (CV) value starting from the specified index.
*
* This function reads and returns a 16-bit CV value from the given starting index.
*
* @param CV_start_index The starting index of the 16-bit CV to be retrieved.
* @return The 16-bit CV value starting from the specified index.
*/
uint16_t get_16bit_CV (uint16_t CV_start_index); uint16_t get_16bit_CV (uint16_t CV_start_index);
/*! /*!
* @brief Calculates the direction based on a speed step byte. * @brief Calculates the direction based on a speed step byte.
* *
@@ -346,15 +438,43 @@ uint16_t get_16bit_CV (uint16_t CV_start_index);
* | 254 | 1111 1110 | Forward | Speed step 125 | * | 254 | 1111 1110 | Forward | Speed step 125 |
* | 255 | 1111 1111 | Forward | Speed step 126 | * | 255 | 1111 1111 | Forward | Speed step 126 |
* *
* also see @ref speed_step_t for available steps.
*
* @param speed_step The speed step byte. * @param speed_step The speed step byte.
* @return `DIRECTION_FORWARD` for forward direction, `DIRECTION_REVERSE` for reverse direction. * @return `DIRECTION_FORWARD` for forward direction, `DIRECTION_REVERSE` for reverse direction.
*/ */
direction_t get_direction_of_speed_step(speed_step_t speed_step); direction_t get_direction_of_speed_step(speed_step_t speed_step);
/**
* @brief Sets a specific error.
*
* This function sets a specific error to the error_state variable.
*
* @param err The error code to set.
*/
void set_error(error_t err); void set_error(error_t err);
/**
* @brief Clears the specified error.
*
* This function resets the error state for the given error code.
*
* @param err The error code to be cleared.
*/
void clear_error(error_t err); void clear_error(error_t err);
/**
* @brief Clears all error flags or statuses in the system.
*
* Clears error_state variable
*/
void clear_all_errors(); void clear_all_errors();
/**
* @brief Retrieves the current error state.
*
* This function returns the current error state of the system.
*
* @return error_t The current error state.
*/
error_t get_error_state(); error_t get_error_state();
@@ -8,8 +8,9 @@ You can choose any PCB manufacturer you like. The PCB is designed to fit with JL
2. Production files? 2. Production files?
---------------------------------- ----------------------------------
The latest release includes the production files for JLCPCB, which includes the Gerber files, BOM, and Pick and Place files. You can find the latest release `here <https://github.com/gab-k/RP2040-Decoder/releases>`_.
In order to export the production files (Gerber/BOM/Pick and Place), you need `KiCad <https://www.kicad.org/download/>`_ which is open source. In order to manually export the production files (Gerber/BOM/Pick and Place), you need `KiCad <https://www.kicad.org/download/>`_ which is open source.
In case you are ordering from JLCPCB it is recommended to use the `Fabrication-Toolkit KiCad plugin by bennymeg <https://github.com/bennymeg/Fabrication-Toolkit>`_ In case you are ordering from JLCPCB it is recommended to use the `Fabrication-Toolkit KiCad plugin by bennymeg <https://github.com/bennymeg/Fabrication-Toolkit>`_
.. _building_the_software: .. _building_the_software:
@@ -17,13 +18,17 @@ In case you are ordering from JLCPCB it is recommended to use the `Fabrication-T
3. Building the software 3. Building the software
---------------------------------- ----------------------------------
If you got a RP2040-Decoder with USB the easiest way to get the RP2040-Decoder up and running is to just use the precompiled .uf2 file and ignore the rest of this section. If you got a RP2040-Decoder with USB the easiest way to get the RP2040-Decoder up and running is to just use the precompiled .uf2 file in the latest `release <https://github.com/gab-k/RP2040-Decoder/releases>`_ and skip to :ref:`flashing_the_software`.
However sometimes you might want to build by yourself, be it for debugging or to make your own modifications to the source code. However sometimes you might want to build by yourself, be it for debugging or to make your own modifications to the source code.
The easiest way to do this is to just use `Visual Studio Code <https://code.visualstudio.com/>`_ and the Raspberry Pi Pico extension. The easiest way to do this is to just use `Visual Studio Code <https://code.visualstudio.com/>`_ and the `Raspberry Pi Pico extension <https://marketplace.visualstudio.com/items?itemName=raspberry-pi.raspberry-pi-pico>`_.
The `official documentation <https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf#vscode-extension>`_ of the Pi Pico does a great job of explaining this in detail. The `official documentation <https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf#vscode-extension>`_ of the Pi Pico does a great job of explaining this in detail.
Note: If you are building for Hardware Rev 0.3 or below change the board defintion in your CMakeLists.txt file to: "RP2040-Decoder-board-legacy.h" .. note::
- Make sure to choose the correct board definition file in your CMakeLists.txt file for example ``RP2040-Decoder-board-Rev-1_0`` for Hardware Rev 1.0.
- In VSCode open the "Software" subdirectory for the extension to detect you project automatically.
.. _flashing_the_software:
4. Flashing the software 4. Flashing the software
---------------------------------- ----------------------------------
@@ -43,15 +48,18 @@ For RP2040-Decoders without USB the only way of flashing the software is via SWD
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
When first plugged in the RP2040 boots into Mass Storage Device mode. To flash the software, you need to drag the '.uf2' file onto the disk using any file explorer. When first plugged in the RP2040 boots into Mass Storage Device mode. To flash the software, you need to drag the '.uf2' file onto the disk using any file explorer.
This will write the file to the Flash and restart the RP2040. This will write the file to the Flash and restart the RP2040.
In case you want to repeat the flasing process, temporarily connect the solder bridge called JP1 on the back side of the board and power cycle the device. In case you want to repeat the flashing process, hold the button SW1 while re-plugging the decoder into your computer. The decoder should now show as a Mass Storage Device again.
This procedure is also described in the `Raspberry Pi Pico Datasheet Chapter 4.1 <https://datasheets.raspberrypi.com/pico/pico-datasheet.pdf#_programming_the_flash>`_ This procedure is also described in the `Raspberry Pi Pico Datasheet Chapter 4.1 <https://datasheets.raspberrypi.com/pico/pico-datasheet.pdf#_programming_the_flash>`_
.. _flashing_the_software_swd:
4.2. Flashing the software via SWD 4.2. Flashing the software via SWD
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Flashing via SWD is a little more complicated but also comes with great advantages in terms of debugging. Flashing via SWD is a little more complicated but also comes with great advantages in terms of debugging.
The book on `Getting started with Raspberry Pi Pico-series <https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf>`_ does a great job of explaining how debugging works. The book on `Getting started with Raspberry Pi Pico-series <https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf>`_ does a great job of explaining how debugging works.
As already suggested in :ref:`3. <building_the_software>` it is recommended to use the `Visual Studio Code Extension <https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf#vscode-extension>`_. As already suggested in :ref:`building_the_software` it is recommended to use the `Visual Studio Code Extension <https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf#vscode-extension>`_.
Most relevant in the book are `Chapter 4.3. Debug <https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf#_debug>`_ and `Appendix A: Debugprobe <https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf#debugprobe_section>`_ The most relevant sections in the book are `Chapter 4.3. Debug <https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf#_debug>`_ and `Appendix A: Debugprobe <https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf#debugprobe_section>`_
5. Wiring 5. Wiring
---------------------------------- ----------------------------------
@@ -110,10 +110,6 @@ Complete Schematic
Complete Schematic Complete Schematic
BOM & Alternative Parts
==============================
please see **PLACEHOLDER-AUTOGENERATED-BOM** for the complete BOM.
.. _wiring_rev_0_3: .. _wiring_rev_0_3:
@@ -112,10 +112,6 @@ Complete Schematic
Complete Schematic Complete Schematic
BOM & Alternative Parts
==============================
please see **PLACEHOLDER-AUTOGENERATED-BOM** for the complete BOM.
.. _wiring_rev_1_0: .. _wiring_rev_1_0:
+1 -2
View File
@@ -10,8 +10,7 @@ RP2040-Decoder Documentation
:maxdepth: 3 :maxdepth: 3
:caption: Contents: :caption: Contents:
other/getting_started gs/getting_started
hardware/index hardware/index
software/index software/index
other/index other/index
other/troubleshooting
-202
View File
@@ -1,202 +0,0 @@
# Configuration Variables (CV)
## Note
CV.h contains default values for every CV. When your board is still "factory new" these values are automatically written into flash. CV_65 == 255 indicates a factory condition and resets all CVs to default. Alternatively to reset all CVs to default a value of 8 can be written to CV8. Also note that index 0 in the CV array corresponds with CV_1, index 1 corresponds with CV_2 and so forth. This list only contains CVs that are in use.
## Speed step configuration
![Speed Table](https://github.com/gab-k/RP2040-Decoder/blob/main/docs/svg/speed_table.svg)
* V_min = CV_2
* V_mid = CV_6 * 16
* V_max = CV_5 * 16
The illustration above shows how the speed steps can be configured using the corresponding CVs. The red * represents V_min which is always at speed step 1, the green * shows V_mid at speed step 64 and the blue * shows V_max at speed step 126.
## CV List
### CV_1 - Basic address
Short DCC address
### CV_2 - V_min
Min motor voltage/speed
### CV_3 - Acceleration rate
CV_3*CV_175 = Time for one discrete speed step change in ms
### CV_4 - Deceleration rate
CV_4*CV_175 = Time for one discrete speed step change in ms
### CV_5 - V_max
Max motor voltage/speed - V_max = CV_5 * 16
### CV_6 - V_mid
Mid motor voltage/speed - V_max = CV_6 * 16
### CV_7 - Version No. (Read-Only)
Rev 0.3 = 1
Writing a value of 7 triggers am ADC offset adjustment.
### CV_8 - Manufacturer (Read-Only)
Default = "13" = Public Domain & Do-It-Yourself Decoders
Writing a value of 8 resets all CV values to the default values in CV.h.
This will also happen if CV_65 == "255" == "0xFF".
### CV_9 - Motor PWM Frequency
f in Hz = CV_9 * 100 + 10000
### CV_11 - Packet timeout
If no package is received for x seconds (x = CV_11) the decoder will automatically stop the motor (Emergency Stop).
### CV_12 - Permitted operating modes
Currently DCC Digital mode is the only supported mode.
### CV_17 & CV_18 - 14-Bit extended/long address
Address is only used if bit5 has a value of "1" in CV_29.
![Long Address](https://github.com/gab-k/RP2040-Decoder/blob/main/docs/svg/Long_address.svg)
Bit15 and bit14 which correspond to bit7 and bit6 of CV_17 are always "1". CV_17 = "192" & CV_18 = "0" is also not a valid address. Otherwise the valid value range of CV_17 ranges from "192" to "231" and "0" to "255" for CV_18 respectively.
### CV_29 - Decoder Configuration
Bit0 is used to reverse direction i.e. "0" = normal, "1" = reverse.
Bit5 switches between basic and extended addressing modes i.e. "0" = basic address, "1" = extended address.
The other 6 bits are currently not in use and therefore irrelevant.
### CV_31 & CV_32 - Extended CV pointer (Read-Only)
Not in use.
### CV_47 - Feed-forward gain k_ff
k_ff defines the correction behavior with regard to the y2 variable. High values for k_ff lead to a faster change in the variable. Values for k_ff that are too high can lead to oscillations.
k_ff = CV_47/10000
### CV_48 - Filter time constant (tau) in ms
The time constant tau characterizes the low-pass filter which is connected downstream in the D component of the PID controller
### CV_49 - PID Control sampling time t in ms
Every t seconds the pid_control() function gets called to compute the new control output
### CV_50 - PID Control I Factor
Integral gain factor of the PID-Controller
### CV_51 - PID Control D Factor
Derivative gain factor of the PID-Controller
### CV_52 & CV_53 - PID Integral Limits
Maximum and minimum integral part values
### CV_54 & CV_55 - Gain scheduling config k_p @ x0
CV_54 - High Byte -- CV_55 - Low Byte
### CV_56 & CV_57 - Gain scheduling config k_p @ x1
CV_56 - High Byte -- CV_57 - Low Byte
### CV_58 & CV_59 - Gain scheduling config k_p @ x2
CV_58 - High Byte -- CV_59 - Low Byte
### CV_60 - Gain scheduling config x1 shift percentage
Determines position of x1 in percent -> x1 shift in % ≙ CV_60/255
### CV_61 - Measurement Iterations
Total amount of BEMF-Voltage measurement iterations
### CV_62 - Measurement Delay
BEMF-Voltage measurement delay
### CV_63 & CV_64 - Measurement array cutoffs
CV_63 determines how many elements from the left side (beginning with index 0) of the array will be discarded while CV_64 determines how many elements from the right side (beginning from highest index) will be discarded.
### CV_65 - New flash variable
Each Byte of the factory new flash chip should have a inital state of "0xFF". This will be checked for in the beginning of core0.c (see cv_setup_check()). When CV_65 == "255" == "0xFF" the default config (CV.h) will be written to flash. Alternatively a reset to default can be done by either writing "8" to CV_8 or writing "255" to CV_65 which then triggers a reset on startup.
### CV_112, CV_113, CV_114, CV_115 - GPIO PWM Configuration
PWM enabled "1" - PWM disabled "0"
### CV_116 to CV_171 - PWM Slice configuration
![GPIO Slices](https://github.com/gab-k/RP2040-Decoder/blob/main/docs/svg/GPIO_slices.svg)
Every slice controls two independent output channels, duty cycle from 0% to 100% inclusive and can be configured with several parameters:
* Wrap (16Bit): Sets the slice time period of x cycles - effectively determining the frequency
* Clock Divider: Additional clock divider
* Level Channel A / Level Channel B - (16Bit each): Determining how many of the x cycles the signal is at a high level - effectively determining the duty cycle
To see which CVs correspond to which slice and channel, it is advisable to use CV.h as a reference
The PWM-frequency is calculated as follows: f<sub>PWM</sub> = 125 MHz / [ (CV<sub>clk_div</sub> + 1) * (CV<sub>wrap</sub> + 1) ]
The duty-cycle can be calculated as follows: D = CV<sub>Level</sub> / CV<sub>wrap</sub> + 1
**Example configuration - (AUX2: PWM-Frequency f<sub>PWM</sub> = 10kHz; Duty-cycle D = 20%):**
AUX1 => GPIO25 => Slice 4 / Channel B => Wrap: CV_144 & CV_145; Clock-divider: CV_146; Level(B): CV_149 & CV_150
=> f<sub>PWM</sub> = 10kHz = 125 MHz / [ (0 + 1) * (12499 + 1) ];
=> CV_144 = 110000, CV_145 = 11010011, CV_146 = 0; --- (Note: "12499<sub>dec</sub>" = "11000011010011<sub>bin</sub>")
=> CV<sub>Level</sub> = CV_149 & CV_150 = D * (CV<sub>wrap</sub> + 1) = 0.2 * 12500 = 2500
=> CV_149 = 1001, CV_150 = 11000100; --- (Note: "2500<sub>dec</sub>" = "100111000100<sub>bin</sub>")
Another configuration which also achieves 10kHz and D = 20% would be CV<sub>clk_div</sub> = 10, CV<sub>wrap</sub> = 1249, CV<sub>Level</sub> = 250.
A more detailed explanation regarding PWM can be found in the [RP2040-Datasheet - Chapter 4.5](https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf).
### CV_172 - ADC Offset
If CV_172 = "0xFF" = "255" there will be a measurement procedure on startup
### CV_173 - ADC offset measurement cycles
Determines how many ADC offset measurement iterations are done.
### CV_174 - Additional motor-PWM clock divider.
Additional Clock Divider - works the same as any GPIO clock divider
### CV_175 - speed_helper timer delay
This timer delay can be used to change the time between two speed steps. So basically an additional option to adjust the deceleration and acceleration rate.
### CV_176, CV_177, CV_178, CV_179 - Base PWM Level used in feed-forward control
CV_176 - High Byte forward -- CV_177 - Low Byte forward -- CV_178 - High Byte reverse -- CV_179 - Low Byte reverse
These values are equivalent to y1(forward) and y1(reverse) mentioned [here](https://github.com/gab-k/RP2040-Decoder/wiki/Software-description#feed-forward). Writing "0" to all four CVs schedules a new calibration on startup.
### CV_257 to CV_512 - Function Mapping CVs
The switching status of the outputs depends both on the function instruction received and on the current direction of travel. That means you can, for example, use a function to switch two or more outputs or, as is usual with headlights, switch them depending on the direction of travel. For configuration, 32 bits (corresponding to the GPIOs) are available for each function in each direction of travel.
+126
View File
@@ -0,0 +1,126 @@
Configuration Variables (CV)
============================
.. note::
- ``CV.h`` contains default values for every CV. When your board is still "factory new" these values are automatically written into flash. ``CV_65 == 255`` indicates a factory condition and resets all CVs to default.
- Index 0 in the CV array corresponds with ``CV_1``, index 1 corresponds with ``CV_2`` and so forth.
Reset all CVs
------------------------
To reset all CVs to default, a value of ``8`` can be written to ``CV8``. Alternatively write a value of ``255`` to ``CV_65`` this will also reset all CVs to default, but only after power cycling the decoder.
Speed step configuration
------------------------
.. figure:: ../../../svg/sw/speed_table.svg
:alt: Speed Table
:align: center
Speed Table
* :math:`v_{min} = CV_{2}`
* :math:`v_{mid} = 16 \cdot CV_{6}`
* :math:`v_{max} = 16 \cdot CV_{5}`
The figure above shows how the speed steps can be configured using the corresponding CVs. The red * represents :math:`v_{min}` which is always at speed step 1, the green * shows :math:`v_{mid}` at speed step 63, and the blue * shows :math:`v_{max}` at speed step 126.
CV List
-------
:math:`CV_{1}` - Basic address
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Short DCC address
:math:`CV_{2}` - :math:`v_{min}`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Min motor voltage/speed is: :math:`v_{min} = CV_{2}`
:math:`CV_{3}` - Acceleration rate
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The time for one discrete acceleration time step can be calculated as :math:`CV_{3} \cdot CV_{175}`.
.. note:: Base speed steps are always 128/126 steps.
:math:`CV_{4}` - Deceleration rate
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The time for one discrete deceleration time step can be calculated as :math:`CV_{4} \cdot CV_{175}`.
.. note:: Base speed steps are always 128/126 steps.
:math:`CV_{5}` - :math:`v_{max}`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Max motor voltage/speed is calculated as: :math:`v_{max} = 16 \cdot CV_{5}`
:math:`CV_{6}` - :math:`v_{mid}`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mid motor voltage/speed is calculated as: :math:`v_{mid} = 16 \cdot CV_{6}`
:math:`CV_{7}` - Version No. (Read-Only)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Writing a value of ``7`` triggers an ADC offset adjustment.
:math:`CV_{8}` - Manufacturer (Read-Only)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Default = ``13`` = Public Domain & Do-It-Yourself Decoders
Even though :math:`CV_{8}` is defined as a Read-only CV, writing a value of ``8`` resets all CV values to the default values in ``CV.h``.
:math:`CV_{9}` - Motor PWM Frequency
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:math:`f_{PWM_{MOTOR}} = (CV_9 \cdot 100 + 10000) \, Hz`
:math:`CV_{11}` - Packet timeout
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If no package is received for :math:`x = CV_{11}` seconds the decoder will automatically stop the motor (Emergency Stop).
:math:`CV_{12}` - Permitted operating modes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Currently, DCC Digital mode is the only supported mode.
:math:`CV_{17}` & :math:`CV_{18}` - 14-Bit extended/long address
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Address is only used if bit5 of :math:`CV_{29}` has a value of ``1``.
.. image:: ../../../svg/sw/Long_address.svg
:alt: Long Address
:align: center
Bit15 and bit14 which correspond to bit7 and bit6 of :math:`CV_{17}` are always ``1``. :math:`CV_{17} = 192` & :math:`CV_{18} = 0` is also not a valid address.
Otherwise, the valid value range of :math:`CV_{17}` ranges from ``192`` to ``231`` and ``0`` to ``255`` for :math:`CV_{18}` respectively.
:math:`CV_{29}` - Decoder Configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Bit0 is can be used to reverse motor direction, i.e., ``0`` = normal, ``1`` = reverse.
Bit5 switches between basic and extended addressing modes, i.e., ``0`` = basic address, ``1`` = extended address.
The other 6 bits are currently not in use and therefore irrelevant.
:math:`CV_{31}` & :math:`CV_{32}` - Extended CV pointer (Read-Only)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Not in use.
:math:`CV_{116}` to :math:`CV_{171}` - PWM Slice configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. image:: ../../../svg/sw/GPIO_slices.svg
:alt: GPIO Slices
:align: center
Every slice controls two independent output channels, duty cycle from 0% to 100% inclusive, and can be configured with several parameters:
* Wrap (16Bit): Sets the slice time period of x cycles - effectively determining the frequency
* Clock Divider: Additional clock divider
* Level Channel A / Level Channel B (16Bit each): Determining how many of the x cycles the signal is at a high level - effectively determining the duty cycle
To see which CVs correspond to which slice and channel, it is advisable to use ``CV.h`` as a reference.
The PWM frequency is calculated as follows: :math:`f_{PWM} = \frac{125 \, \text{MHz}}{(CV_{\text{clk_div}} + 1) \cdot (CV_{\text{wrap}} + 1)}`
The duty-cycle can be calculated as follows: :math:`D = \frac{CV_{\text{Level}}}{CV_{\text{wrap}} + 1}`
A more detailed explanation regarding PWM can be found in the `RP2040-Datasheet - Chapter 4.5 <https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf>`_.
@@ -0,0 +1,23 @@
Debugging and Logging
==================================
For logging and debugging you have to build the software yourself. This is explained here: :ref:`building_the_software`
.. _debugging_via_swd:
Debugging via SWD
----------------------------------
Please refer to :ref:`flashing_the_software_swd`.
.. _logging:
Logging
----------------------------------
Logging can be enabled in ``CMakeLists.txt``, and is available with two interfaces:
- Logging via UART RX/TX pins (GPIO0/GPIO1 by default)
- Logging via USB CDC/ACM
Additionally you can make the decoder wait for input via serial port by setting LOG_WAIT to 1. For more details please see comments inside ``CMakeLists.txt``.
+2 -1
View File
@@ -5,5 +5,6 @@ Other
:maxdepth: 2 :maxdepth: 2
:caption: Contents: :caption: Contents:
CV_list
troubleshooting troubleshooting
debug_logging
CV_list
@@ -1,14 +0,0 @@
# Troubleshooting
To narrow down the issue when your decoder is not working as expected, you can do the following:
Check the power supply of the decoder:
* +3V3 to GND should be 3.3V
* +V to GND should be somewhere in the range of around +10V to +20V
* If you dont measure the correct voltages, try to [measure Track Voltage](https://dccwiki.com/Measuring_Track_Voltage)
Check your motor:
* Desolder your motor and try the motor with a analog power supply 0...+-16V to check if the motor is working or not (desolder the wires because the decoder doesn't like voltage on these pins!)
Reset:
* Try to reset the decoder by writing a value of 8 to CV8 (beware, this will reset the complete CV memory!)
@@ -0,0 +1,27 @@
Troubleshooting
================
To narrow down the issue when your decoder is not working as expected, you can do the following (in no particular order):
Enable logging and or debug via SWD
------------------------------------
Log messages can be enabled and output via either UART or USB please see :ref:`logging` for details.
For more advanced users it might also be beneficial to :ref:`debug with SWD <debugging_via_swd>`
Checking the power supply:
--------------------------------------
* **+3V3 to GND** should be 3.3V ± 1%
* **VDC/+V to GND** should be somewhere in the range of at least 6V to 23V depending on your track voltage.
If you don't measure the correct voltages, try to `measure your track voltage <https://dccwiki.com/Measuring_Track_Voltage>`_
Check your motor:
-----------------
Desolder your motor and try the motor with an appropriate power supply and DC voltage, to check if the motor is working or not.
CV Reset:
------------
Try to reset the decoder by writing a value of ``8`` to ``CV8`` (beware, this will reset the complete CV memory!)
+26 -18
View File
@@ -65,14 +65,14 @@ Control Loop & Digital Controller
Control Loop - Block diagram Control Loop - Block diagram
The block diagram above shows the complete control loop. The actual digital controller block is explained below. The block diagram above shows the (simplified) control loop. The actual digital controller block is explained below.
The Speed Helper block effectively sets the setpoint of the controller according to the CV configured acceleration and deceleration rates and actual target speedstep. The *Speed Helper* block effectively sets the setpoint of the controller according to the CV configured acceleration and deceleration rates and actual target speedstep.
For feedback the back EMF voltage V_EMF is measured via voltage divider and ADC. V_EMF is proportional to the motor speed in RPM. For feedback the back EMF voltage *V_EMF* is measured via voltage divider and ADC. *V_EMF* is proportional to the motor speed.
TODO: rewrite this: While the central component is the PID controller, there is an additional block called `Feed-forward <https://en.wikipedia.org/wiki/Feed_forward_(control)>`_ that has an impact on the control output variable. The Feed-forward block adds an additional offset to the output depending on the setpoint; this is done to achieve better control. A more detailed explanation regarding Feed-forward can be found below. The speed helper block corresponds to the ``speed_helper()`` function, which delays changing the setpoint according to the configured deceleration/acceleration rates. While the central component is the PID controller, there is an additional block called `Feed-forward <https://en.wikipedia.org/wiki/Feed_forward_(control)>`_ that has an impact on the control output variable. The Feed-forward block adds an additional offset to the output depending on the setpoint; this is done to achieve better control. A more detailed explanation regarding Feed-forward can be found below. The speed helper block corresponds to the ``speed_helper()`` function, which delays changing the setpoint according to the configured deceleration/acceleration rates.
.. figure:: ../../../svg/sw/Block_Diagram_Digital_Controller.svg .. figure:: ../../../svg/sw/Block_Diagram_Digital_Controller.svg
:alt: Block Diagram - Digital Controller :alt: Block Diagram - Digital Controller
@@ -80,12 +80,27 @@ TODO: rewrite this: While the central component is the PID controller, there is
Digital Controller - Block diagram Digital Controller - Block diagram
The controller is divided into two parts, depending on whether the motor is stationary or in motion. The startup controller handles overcoming friction of the motor, and finding base PWM level for overcoming friction. The base PWM level is saved and added to the output of the PID controller which handles motor control when the motor is in motion. The controller is divided into two parts, depending on whether the motor is stationary or in motion.
At all times either the startup controller or the PID controller is active.
The startup controller handles overcoming friction of the motor, and finding a base PWM level for overcoming friction.
The base PWM level is equivalent to a certain PWM duty cycle.
The base level gets saved and added to the output of the PID controller which handles motor control when the motor is in motion.
This means the actual output of the PID controller is the sum of the PID output and the base PWM level. This is referred to as the :ref:`feed forward <feed_forward>` block.
The benefit of doing this is that the PID controller does not have to work in the non linear friction region of the motor, improving control performance.
Startup Controller Startup Controller
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Used on startup, meaning when the motor is not moving. The startup controller sets a PWM duty cycle level of :math:`\frac{2}{3} \cdot \text{base_pwm}` and then ramps up the duty cycle/PWM level until the motor starts moving. This is done in order to overcome the friction of the drive train and motor. :math:`\text{base_pwm}` is the average value of the 16 previous startup PWM levels. When no previous startup PWM levels are saved the startup controller begins ramping up from 0. The actual value at which the motor started moving is used as a reference for the :ref:`feed forward <feed_forward>` block.
Used on startup, meaning when the motor is not moving. First the startup controller retrieves the last `BASE_PWM_ARR_LEN` base PWM levels.
The base pwm levels are not retained on a power cycle. That means when there is no previous base PWM level saved, the startup controller will start ramping up from 0.
When there is less than `BASE_PWM_ARR_LEN` base PWM levels saved, the startup controller will ramp up from the average of the saved base PWM levels.
After the startup controller retrieved the average of the last base pwm levels :math:`\bar{b}` it sets a PWM duty cycle level of :math:`\frac{2}{3} \cdot \bar{b}` and then ramps up the duty cycle/PWM level until the motor starts moving.
When no previous startup PWM levels are saved the startup controller begins ramping up from 0.
The actual value at which the motor started moving is multiplied by `K_FF` and used as a reference for the :ref:`feed forward <feed_forward>` block.
PID Controller PID Controller
@@ -131,7 +146,7 @@ This results in the following difference equations which are then implemented in
Gain Scheduling Gain Scheduling
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^^^^^^^^^^^^^^^^^^^^
.. figure:: ../../../svg/sw/adaptive_kp.svg .. figure:: ../../../svg/sw/adaptive_kp.svg
:alt: Gain Scheduling figure :alt: Gain Scheduling figure
@@ -145,19 +160,12 @@ Another aspect to consider is the implementation of `gain scheduling <https://en
.. _feed_forward: .. _feed_forward:
Feed-forward Feed-forward
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^^^^^^^^^^^^^^^^^^
As previously mentioned, to achieve better control, `Feed-forward <https://en.wikipedia.org/wiki/Feed_forward_(control)>`_ is used.
In essence this means that the output of the PID controller is not only the sum of the proportional, integral, and derivative parts, but also the base PWM level.
The base PWM level is set by the startup controller and is the PWM level at which the motor starts moving.
.. figure:: ../../../svg/sw/feed_forward.svg
:alt: Feed forward figure
:align: center
Feed-forward
TODO: Update this part:
To achieve better control, `Feed-forward <https://en.wikipedia.org/wiki/Feed_forward_(control)>`_ is used. On startup, the decoder will check for a configuration regarding Feed-forward control. When no configuration is found, the decoder automatically runs a calibration to establish a base PWM level (y\ :sub:`1`) for both directions. The base PWM level (y\ :sub:`1`) will vary depending on load, motor, and voltage on the tracks and can be configured with CV_176 - CV_179. If the setpoint is greater than the threshold, y\ :sub:`2` is corrected automatically when i\ :sub:`n` reaches 0.5i\ :sub:`min` or 0.5i\ :sub:`max`. CV_47 can be used to set how sensitive this correction is.
Back-EMF voltage measurement Back-EMF voltage measurement
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Do not edit this file with editors other than draw.io -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" style="background: transparent; background-color: transparent; color-scheme: light;" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="1930px" height="2823px" viewBox="-0.5 -0.5 1930 2823" content="&lt;mxfile host=&quot;app.diagrams.net&quot; agent=&quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0&quot; version=&quot;26.0.3&quot; scale=&quot;1&quot; border=&quot;0&quot;&gt;&#xA; &lt;diagram id=&quot;fYnpBcbPwy3h1yrhEr7x&quot; name=&quot;Page-1&quot;&gt;&#xA; &lt;mxGraphModel dx=&quot;6320&quot; dy=&quot;5010&quot; grid=&quot;1&quot; gridSize=&quot;10&quot; guides=&quot;1&quot; tooltips=&quot;1&quot; connect=&quot;1&quot; arrows=&quot;1&quot; fold=&quot;1&quot; page=&quot;1&quot; pageScale=&quot;1&quot; pageWidth=&quot;850&quot; pageHeight=&quot;1100&quot; background=&quot;none&quot; math=&quot;0&quot; shadow=&quot;0&quot;&gt;&#xA; &lt;root&gt;&#xA; &lt;mxCell id=&quot;0&quot; /&gt;&#xA; &lt;mxCell id=&quot;1&quot; parent=&quot;0&quot; /&gt;&#xA; &lt;mxCell id=&quot;K4uLP4tBgHA3zsCXKBI8-35&quot; value=&quot;&quot; style=&quot;line;strokeWidth=15;html=1;rounded=0;fontFamily=Helvetica;fontSize=100;fontColor=default;fillColor=none;gradientColor=none;direction=west;strokeColor=#0000FF;&quot; parent=&quot;1&quot; vertex=&quot;1&quot;&gt;&#xA; &lt;mxGeometry x=&quot;1180&quot; y=&quot;1337.75&quot; width=&quot;100&quot; height=&quot;15&quot; as=&quot;geometry&quot; /&gt;&#xA; &lt;/mxCell&gt;&#xA; &lt;mxCell id=&quot;No6-LZMIRZosWDj3bi_c-3&quot; value=&quot;&quot; style=&quot;line;strokeWidth=15;html=1;rounded=0;fontFamily=Helvetica;fontSize=100;fontColor=default;fillColor=none;gradientColor=none;direction=west;&quot; vertex=&quot;1&quot; parent=&quot;1&quot;&gt;&#xA; &lt;mxGeometry x=&quot;1565&quot; y=&quot;1335&quot; width=&quot;435&quot; height=&quot;15&quot; as=&quot;geometry&quot; /&gt;&#xA; &lt;/mxCell&gt;&#xA; &lt;mxCell id=&quot;No6-LZMIRZosWDj3bi_c-1&quot; value=&quot;&quot; style=&quot;shape=image;verticalLabelPosition=bottom;labelBackgroundColor=default;verticalAlign=top;aspect=fixed;imageAspect=0;image=data:image/png,iVBORw0KGgoAAAANSUhEUgAABiAAAANoCAYAAABJLCIrAAAABHNCSVQICAgIfAhkiAAAIABJREFUeJzs3Xt8HHW9P/7XJGmTFNIbm6Q0KZBSFOktbaGAFNFzTil45CIgogIe/Qm0pRRF5RwVFTyg54Ci0Ja2+P3JEQRBSwU9Uijn9z0gt0JL26QXQEovNGmSZuktzbVJ5vfH7uzO7Hxm5jOzM7szm9fzwZLduXw+n5mdbrKf93zeH+Wtt5pUEBERERERERERERER+ago3w0gIiIiIiIiIiIiIqLCwwAEERERERERERERERH5jgEIIiIiIiIiIiIiIiLyXQnAKSCIiIiIiIiIiIiIiMhfHAFBRERERERERERERES+YwCCiIiIiIiIiIiIiIh8xwAEERERERERERERERH5jgEIIiIiIiIiIiIiIiLyHQMQRERERERERERERETkOwYgiIiIiIiIiIiIiIjIdyWqmu8mEBERERERERERERFRoeEICCIiIiIiIiIiIiIi8h0DEERERERERERERERE5DsGIIiIiIiIiIiIiIiIyHcMQBARERERERERERERke9KAM5CTURERERERERERERE/uIICCIiIiIiIiIiIiIi8h0DEERERERERERERERE5DsGIIiIiIiIiIiIiIiIyHcMQBARERERERERERERke8YgCAiIiIiIiIiIiIiIt8xAEFERERERERERERERL4rUdV8N4GIiIiIiIiIiIiIiAoNR0AQEREREREREREREZHvGIAgIiIiIiIiIiIiIiLfMQBBRERERERERERERES+YwCCiIiIiIiIiIiIiIh8VwJwFmoiIiIiIiIiIiIiIvIXR0AQEREREREREREREZHvGIAgIiIiIiIiIiIiIiLfMQBBRERERERERERERES+YwCCiIiIiIiIiIiIiIh8xwAEERERERERERERERH5jgEIIiIiIiIiIiIiIiLyHQMQRERERERERERERETkuxJVzXcTiIiIiIiIiIiIiIio0HAEBBERERERERERERER+Y4BCCIiIiIiIiIiIiIi8h0DEERERERERERERERE5LsSgJNAEBERERERERERERGRvzgCgoiIiIiIiIiIiIiIfMcABBEREUXajh2NwuW9vUdx8OCe1OujR5vR1dliW5aq9kIdPGBYVqQclmpHWekR3fNOlJV2Su13/AjxdiPKu4WvM39qSor7U8syyxxR3m3aPpN+f+2nfpm+HKeynI5FtE60jeyyzPXa8Vtt67b9ovcodY5K+i3fQ6t99NuL3mc37ZPZVquvpKRfeH7cng9R/ceP6HQ87/p93Lw3+nOsP3fa8QRp2LCjvpZ39Gizr+UREREREYWd8sYbu5mDiYiIiCLrqaf+E6XDS1FeXobjjjsOpaWlKC0djuHDh2PYsBKUlAxDSUkxiouNj6KiIhQVFaG4qAhKURGKipTEMqUISpGS+qkoCooUJfVcURQoUADtuQIoSDxH4r/EOq2ByfWpl8l9hqIhetiUZyoAVU08U1Xjcm1BYhsVUAEVKlQ1ua2q6l6rUAdVDKrp14ODg6mfg4MqVHUw+XwwtWxgYMDw6O8fwMBAP/r6juHYsWPo7e1DX18vOjqOore3F729vbjyqu/k+jQREREREQWCIyCIiIgo+pRkZ2IiLmBc4TDflfVa+/1M1ZCJkvEgyotsb7eS3N98jYuvev1nlArVFJDk3WFEREREVEgYgCAiIqLIs+/gVgx3PQeH3YYAAw5UgGQvZsntVDU18AIKlNRoC0VJ/Muprp7opZVERERERKHEAAQREREVDn16lUT+FEBwh7HPVSUN3S53Bh0o1HJ1YRo+FGxCorqRWmoyEjFU07IRERERUeEryXcDiIiIiLKVyt+u68TT7ib23PvIHkFbPDtREYV3qkBGDxkyvqmwTfCmrUrOJWMYpVUgp4OIiIiICABKcpOSgIiIiCg4CrSAg16Wf+SoiEbfbQ7xdORbob4DXo8rD19knKeVcbmxmtpC1X0x43c0IiIiIioUHAFBREREhcPPTrtC7et1iachaDzD3smeu3z05huDD8aJp3WvVW1LRhyIiIiIqDAxAEFERESRJ85eogjW+qeQu40L+dhyj2ezoEh/nBg31I9o0F8R2sitIl2Eom3/Tm9tIyIiIiIKoRImGSUiIqJCku7GE/+N49fUDqIMTVHuao5y2/OPZ48yyeVqUlXVkHopsaerPE9ERERERKHGERBEREQUcVadv4pwfWZudSXzmWRfciF0ORfCMeQWz1gh8dTN72Enu6CnkpyEWnvuNHk1EREREVHUFOW7AURERETZUKDrFjZ19Dl35qmCZ6KX1vtFj+GckQVF8KDIy8Pb6DShtKpmfp7wWiMiIiKiwsEREERERBRpKtR0B5+po8+549hrV1/Uugij1t7c4ZkZUrKNHHrcP3MUhCEooRhHYlVV13mrhIiIiIgohBiAICIiouhTUv8T8Npj6LEtwRQTubrDi2dlKFMU6xEJUtmVvKRgclOkArS1cRJqIiIiIiocTMFEREREEad176mCXOsSk8BmlpMaTSGbusmqPfnDhEEaplEieVJxBamNBNdZ5twz2seNmhjBpSSfQ9UmoSYiIiIiKgwcAUFEREQRp6ZDEB5SMOnLMeRCsZ051k1Xdu46E9ltyTNA3nmalFrIXIpVuYlJqKM9pwwRERERkR2OgCAiIqLIUwEg2ZGXsdQFuyTtogrDYWjf28/RDeSG4Bpxe9lIbS9fqJr8MFF0S6qqOALine truncated

After

Width:  |  Height:  |  Size: 1.3 MiB

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Do not edit this file with editors other than draw.io -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="701px" height="845px" viewBox="-0.5 -0.5 701 845" content="&lt;mxfile host=&quot;app.diagrams.net&quot; agent=&quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0&quot; version=&quot;25.0.3&quot; scale=&quot;1&quot; border=&quot;0&quot;&gt;&#xA; &lt;diagram name=&quot;Page-1&quot; id=&quot;EzXMAEqKDDRs-_LGy8zr&quot;&gt;&#xA; &lt;mxGraphModel dx=&quot;1687&quot; dy=&quot;920&quot; grid=&quot;1&quot; gridSize=&quot;10&quot; guides=&quot;1&quot; tooltips=&quot;1&quot; connect=&quot;1&quot; arrows=&quot;1&quot; fold=&quot;1&quot; page=&quot;1&quot; pageScale=&quot;1&quot; pageWidth=&quot;827&quot; pageHeight=&quot;1169&quot; math=&quot;0&quot; shadow=&quot;0&quot;&gt;&#xA; &lt;root&gt;&#xA; &lt;mxCell id=&quot;0&quot; /&gt;&#xA; &lt;mxCell id=&quot;1&quot; parent=&quot;0&quot; /&gt;&#xA; &lt;mxCell id=&quot;4ED7IVWrFvjwATd2QOsb-36&quot; value=&quot;&quot; style=&quot;endArrow=classic;html=1;rounded=0;strokeColor=#647687;shape=flexArrow;strokeWidth=2;fillColor=default;gradientColor=none;width=32;endSize=11.67;exitX=0.5;exitY=0;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;&quot; edge=&quot;1&quot; parent=&quot;1&quot; target=&quot;4ED7IVWrFvjwATd2QOsb-89&quot; source=&quot;4ED7IVWrFvjwATd2QOsb-77&quot;&gt;&#xA; &lt;mxGeometry width=&quot;50&quot; height=&quot;50&quot; relative=&quot;1&quot; as=&quot;geometry&quot;&gt;&#xA; &lt;mxPoint x=&quot;20&quot; y=&quot;70&quot; as=&quot;sourcePoint&quot; /&gt;&#xA; &lt;mxPoint x=&quot;480&quot; y=&quot;160&quot; as=&quot;targetPoint&quot; /&gt;&#xA; &lt;Array as=&quot;points&quot;&gt;&#xA; &lt;mxPoint x=&quot;385&quot; y=&quot;135&quot; /&gt;&#xA; &lt;/Array&gt;&#xA; &lt;/mxGeometry&gt;&#xA; &lt;/mxCell&gt;&#xA; &lt;mxCell id=&quot;4ED7IVWrFvjwATd2QOsb-37&quot; value=&quot;STARTUP_MODE&quot; style=&quot;edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];fontSize=20;fontColor=default;rotation=270;&quot; vertex=&quot;1&quot; connectable=&quot;0&quot; parent=&quot;4ED7IVWrFvjwATd2QOsb-36&quot;&gt;&#xA; &lt;mxGeometry x=&quot;-0.3535&quot; y=&quot;-3&quot; relative=&quot;1&quot; as=&quot;geometry&quot;&gt;&#xA; &lt;mxPoint x=&quot;-3&quot; y=&quot;7&quot; as=&quot;offset&quot; /&gt;&#xA; &lt;/mxGeometry&gt;&#xA; &lt;/mxCell&gt;&#xA; &lt;mxCell id=&quot;4ED7IVWrFvjwATd2QOsb-64&quot; value=&quot;&quot; style=&quot;endArrow=classic;html=1;rounded=0;strokeColor=#647687;shape=flexArrow;strokeWidth=2;fillColor=default;gradientColor=none;width=32;endSize=11.67;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;&quot; edge=&quot;1&quot; parent=&quot;1&quot; source=&quot;4ED7IVWrFvjwATd2QOsb-89&quot; target=&quot;4ED7IVWrFvjwATd2QOsb-102&quot;&gt;&#xA; &lt;mxGeometry width=&quot;50&quot; height=&quot;50&quot; relative=&quot;1&quot; as=&quot;geometry&quot;&gt;&#xA; &lt;mxPoint x=&quot;1200&quot; y=&quot;490&quot; as=&quot;sourcePoint&quot; /&gt;&#xA; &lt;mxPoint x=&quot;1315&quot; y=&quot;490&quot; as=&quot;targetPoint&quot; /&gt;&#xA; &lt;Array as=&quot;points&quot; /&gt;&#xA; &lt;/mxGeometry&gt;&#xA; &lt;/mxCell&gt;&#xA; &lt;mxCell id=&quot;4ED7IVWrFvjwATd2QOsb-65&quot; value=&quot;K_FF*startup.level&quot; style=&quot;edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];fontSize=20;fontColor=default;rotation=270;&quot; vertex=&quot;1&quot; connectable=&quot;0&quot; parent=&quot;4ED7IVWrFvjwATd2QOsb-64&quot;&gt;&#xA; &lt;mxGeometry x=&quot;-0.4316&quot; y=&quot;7&quot; relative=&quot;1&quot; as=&quot;geometry&quot;&gt;&#xA; &lt;mxPoint x=&quot;-7&quot; y=&quot;27&quot; as=&quot;offset&quot; /&gt;&#xA; &lt;/mxGeometry&gt;&#xA; &lt;/mxCell&gt;&#xA; &lt;mxCell id=&quot;4ED7IVWrFvjwATd2QOsb-71&quot; value=&quot;&quot; style=&quot;endArrow=classic;html=1;rounded=0;strokeColor=#647687;shape=flexArrow;strokeWidth=2;fillColor=default;gradientColor=none;width=32;endSize=11.67;entryX=0.5;entryY=0;entryDx=0;entryDy=0;&quot; edge=&quot;1&quot; parent=&quot;1&quot; target=&quot;4ED7IVWrFvjwATd2QOsb-89&quot;&gt;&#xA; &lt;mxGeometry width=&quot;50&quot; height=&quot;50&quot; relative=&quot;1&quot; as=&quot;geometry&quot;&gt;&#xA; &lt;mxPoint x=&quot;340&quot; y=&quot;20&quot; as=&quot;sourcePoint&quot; /&gt;&#xA; &lt;mxPoint x=&quot;320&quot; y=&quot;505&quot; as=&quot;targetPoint&quot; /&gt;&#xA; &lt;Array as=&quot;points&quot;&gt;&#xA; &lt;mxPoint x=&quot;615&quot; y=&quot;20&quot; /&gt;&#xA; &lt;/Array&gt;&#xA; &lt;/mxGeometry&gt;&#xA; &lt;/mxCell&gt;&#xA; &lt;mxCell id=&quot;4ED7IVWrFvjwATd2QOsb-72&quot; value=&quot;MEASUREMENT &Line truncated

After

Width:  |  Height:  |  Size: 171 KiB

+6 -6
View File
@@ -31,18 +31,18 @@ def print_speed_steps():
* | 255 | 1111 1111 | Forward | Speed step 126 | * | 255 | 1111 1111 | Forward | Speed step 126 |
""" """
# Reverse speed steps # Reverse speed steps
print(f"SPEED_STEP_REVERSE_STOP = 0x{0:02X}, // {0:08b}bin {0:03d}dec") print(f"SPEED_STEP_REVERSE_STOP = 0x{0:02X}, /**< {0:08b}bin {0:03d}dec */")
print(f"SPEED_STEP_REVERSE_EMERGENCY_STOP = 0x{1:02X}, // {1:08b}bin {1:03d}dec") print(f"SPEED_STEP_REVERSE_EMERGENCY_STOP = 0x{1:02X}, /**< {1:08b}bin {1:03d}dec */")
for i in range(1, 127): for i in range(1, 127):
print(f"SPEED_STEP_REVERSE_{i:03d} = 0x{i+1:02X}, // {i+1:08b}bin {i+1:03d}dec") print(f"SPEED_STEP_REVERSE_{i:03d} = 0x{i+1:02X}, /**< {i+1:08b}bin {i+1:03d}dec */")
print("\n\n") print("\n\n")
# Forward speed steps # Forward speed steps
print(f"SPEED_STEP_FORWARD_STOP = 0x{128:02X}, // {128:08b}bin {128:03d}dec") print(f"SPEED_STEP_FORWARD_STOP = 0x{128:02X}, /**< {128:08b}bin {128:03d}dec */")
print(f"SPEED_STEP_FORWARD_EMERGENCY_STOP = 0x{129:02X}, // {129:08b}bin {129:03d}dec") print(f"SPEED_STEP_FORWARD_EMERGENCY_STOP = 0x{129:02X}, /**< {129:08b}bin {129:03d}dec */")
for i in range(1, 127): for i in range(1, 127):
print(f"SPEED_STEP_FORWARD_{i:03d} = 0x{i+129:02X}, // {i+129:08b}bin {i+129:03d}dec") print(f"SPEED_STEP_FORWARD_{i:03d} = 0x{i+129:02X}, /**< {i+129:08b}bin {i+129:03d}dec */")
# Call the function # Call the function
print_speed_steps() print_speed_steps()