* Added primary stepper motor driver code to repo * Added odometery encoder code to repo * Added the ability to update encoder wheel ratio via ros service Co-authored-by: Pimpest <82343504+Pimpest@users.noreply.github.com> Co-committed-by: Pimpest <82343504+Pimpest@users.noreply.github.com>
27 lines
703 B
C
27 lines
703 B
C
#pragma once
|
|
#include "hardware/pio.h"
|
|
|
|
typedef struct substep_state_t {
|
|
|
|
uint calibration_data[4]; // relative phase sizes
|
|
uint clocks_per_us; // save the clk_sys frequency in clocks per us
|
|
uint idle_stop_samples; // after these samples without transitions, assume the encoder is stopped
|
|
PIO pio;
|
|
uint sm;
|
|
|
|
uint prev_trans_pos, prev_trans_us;
|
|
uint prev_step_us;
|
|
uint prev_low, prev_high;
|
|
uint idle_stop_sample_count;
|
|
int speed_2_20;
|
|
int stopped;
|
|
|
|
int speed;
|
|
uint position;
|
|
|
|
uint raw_step;
|
|
} substep_state_t;
|
|
|
|
|
|
void substep_init_state(PIO pio, int sm, int pin_a, substep_state_t *state);
|
|
void substep_update(substep_state_t *state); |