vedderb / bldc

The VESC motor control firmware
2.16k stars 1.35k forks source link

Servo output from CAN_BUS command #480

Closed vinci-xiao closed 2 years ago

vinci-xiao commented 2 years ago

Hi, I tried to using can-bus command to control a servo. I triled to modified the following programs, but it still doesn't work. Can anyone give me a clue?

comm_can.c

include "general.h"

include "servo_simple.h"

// Custom Code

void comm_can_set_brake_servo_pos(uint8_t controller_id, float pos) { int32_t send_index = 0; uint8_t buffer[4]; buffer_append_int32(buffer, (int32_t)(pos * 1000000.0), &send_index); comm_can_transmit_eid_replace(controller_id | ((uint32_t)CAN_PACKET_SET_BRAKE_SERVO_POS << 8), buffer, send_index, true, 0); }

comm_can.h void comm_can_set_brake_servo_pos(uint8_t controller_id, float pos); // Custom Code

conf_general.h

if !defined(HW_SOURCE) && !defined(HW_SOURCE_ALT)

define HW60_IS_MK5

define HW_SOURCE "hw_60.c"

define HW_HEADER "hw_60.h"

endif

ifndef HW_SOURCE

error "No hardware source file set"

endif

datatypes.h CAN_PACKET_STATUS_6, **CAN_PACKET_SET_BRAKE_SERVO_POS,** CAN_PACKET_MAKE_ENUM_32_BITS = 0xFFFFFFFF, } CAN_PACKET_ID;