36 #ifndef FAULHABER_P_GAIN
37 #define FAULHABER_P_GAIN 0.07
41 #ifndef FAULHABER_MAX_VELOCITY
42 #define FAULHABER_MAX_VELOCITY 12000
65 u8CRC = u8CRC ^ u8Byte;
66 for (i = 0; i < 8; i++) {
85 for (
uint8_t i = 0; i < data_length; i++) {
101 #define GOT_FULL_PACKET 7
116 p->data_length = c - 4;
133 p->data[
p->data_idx++] = c;
135 if (
p->data_idx >=
p->data_length) {
140 if (
p->calc_crc8 == c) {
202 static uint8_t data[] = { 0x40, 0x60, 0x00, 0x0E, 0x00};
214 static uint8_t data[] = { 0x60, 0x60, 0x00, 0x06 };
226 static uint8_t data[] = { 0x98, 0x60, 0x00, 0x11 };
238 static uint8_t data[] = { 0x40, 0x60, 0x00, 0x0F, 0x00};
250 static uint8_t data[] = { 0x40, 0x60, 0x00, 0x1F, 0x00};
276 static uint8_t data[] = { 0x60, 0x60, 0x00, 0x03 };
288 static uint8_t data[] = { 0x40, 0x60, 0x00, 0x0F, 0x00};
312 uint8_t data[] = { 0x64, 0x60, 0x00};
338 uint8_t data[] = { 0x20, 0x23, 0x00};
345 uint8_t data[] = { 0x21, 0x23, 0x00};
352 uint8_t data[] = { 0x01, 0x10, 0x00};
370 static uint8_t data[] = { 0x40, 0x60, 0x00, 0x0E, 0x00};
376 static uint8_t data[] = { 0x60, 0x60, 0x00, 0x03 };
383 static uint8_t data[] = { 0x40, 0x60, 0x00, 0x0F, 0x00};
403 if (
p->cmd_code == 0x01 &&
p->data[0] == 0x64 &&
p->data[1] == 0x60 &&
p->data[2] == 0x00) {
408 0) - get_servo_min_FAULHABER(0)) * M_PI_2;
410 feedback.
idx = get_servo_idx_FAULHABER(0);
416 else if(
p->cmd_code == 0x02) {
420 else if(
p->cmd_code == 0x05) {
421 uint16_t status_code =
p->data[0] | (
p->data[1] << 8);
436 if(!(status_code&0x0001) || !(status_code&0x0002) || !(status_code&0x0004)) {
438 int rc = snprintf(error_msg, 200,
"[FH]%d %04X",
p->cmd_code, status_code);
445 int rc = snprintf(error_msg, 200,
"[FH]%d ",
p->cmd_code);
446 for(
int i = 0; i <
p->data_length; i++) {
447 rc += snprintf(error_msg + rc, 200 - rc,
"%02X",
p->data[i]);
Main include for ABI (AirBorneInterface).
#define ACT_FEEDBACK_FAULHABER_ID
static void faulhaber_send_command(struct uart_periph *dev, uint8_t cmd_code, uint8_t *data, uint8_t data_length)
static struct uart_periph * faulhaber_dev
static uint8_t faulhaber_crc8(uint8_t u8Byte, uint8_t u8CRC)
void actuators_faulhaber_event(void)
struct faulhaber_t faulhaber
#define FAULHABER_MAX_VELOCITY
static void faulhaber_parser(struct faulhaber_parser_t *p, uint8_t c)
static struct faulhaber_parser_t faulhaber_p
static void faulhaber_parse_msg(struct faulhaber_parser_t *p)
void actuators_faulhaber_periodic(void)
void actuators_faulhaber_init(void)
void actuators_faulhaber_SetMode(uint8_t mode)
float p_gain
The proportional gain of the velocity controller.
int32_t max_velocity
The maximum velocity of the controller.
int32_t real_position
The real position from the feedback of the controller.
#define ACTUATORS_FAULHABER_COMMAND_SCALE
bool target_reached
When the target position is reached.
enum faulhaber_modes_t mode
Current mode of the controller.
bool homing_completed
Once the homing is completed.
int32_t setpoint_position
The setpoint position controlled from the actuator.
int32_t target_velocity
The target velocity send to the controller.
uint8_t state
The state of the mode.
bool position_ready
Ready for receiving (new) positions.
Common code for AP and FBW telemetry.
void uart_put_byte(struct uart_periph *periph, long fd, uint8_t data)
int uart_char_available(struct uart_periph *p)
Check UART for available chars in receive buffer.
uint8_t uart_getch(struct uart_periph *p)
bool position
Position is set.
struct act_feedback_t::act_feedback_set_t set
Bitset registering what is set as feedback.
uint8_t idx
General index of the actuators (generated in airframe.h)
float position
In radians.
static uint8_t mode
mode holds the current sonar mode mode = 0 used at high altitude, uses 16 wave patterns mode = 1 used...
static const struct usb_device_descriptor dev
Architecture independent timing functions.
static float get_sys_time_float(void)
Get the time in seconds since startup.
void WEAK uart_send_message(struct uart_periph *p, long fd)
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
int int32_t
Typedef defining 32 bit int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.