Skip to content

Commit

Permalink
Added lbm motor type config option
Browse files Browse the repository at this point in the history
  • Loading branch information
vedderb committed Jul 31, 2022
1 parent 9a15de6 commit b334247
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lispBM/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,11 @@ The following selection of app and motor parameters can be read and set from Lis
'l-min-duty ; Minimum duty cycle
'l-max-duty ; Maximum duty cycle
'l-watt-min ; Minimum power regen in W (a negative value)
'motor-type ; Motor Type
; 0: BLDC (6-step commutation)
; 1: DC (DC motor on phase A and C)
; 2: FOC (Field Oriented Control)
; 3: GPD (General Purpose Drive)
'l-watt-max ; Maximum power regen in W
'm-invert-direction ; Invert motor direction, 0 or 1
'm-out-aux-mode ; AUX-pin output mode. Options:
Expand Down
10 changes: 9 additions & 1 deletion lispBM/lispif_vesc_extensions.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ typedef struct {
lbm_uint l_max_duty;
lbm_uint l_watt_min;
lbm_uint l_watt_max;
lbm_uint motor_type;
lbm_uint foc_sensor_mode;
lbm_uint foc_current_kp;
lbm_uint foc_current_ki;
Expand Down Expand Up @@ -279,6 +280,8 @@ static bool compare_symbol(lbm_uint sym, lbm_uint *comp) {
get_add_symbol("l-watt-min", comp);
} else if (comp == &syms_vesc.l_watt_max) {
get_add_symbol("l-watt-max", comp);
} else if (comp == &syms_vesc.motor_type) {
get_add_symbol("motor-type", comp);
} else if (comp == &syms_vesc.foc_sensor_mode) {
get_add_symbol("foc-sensor-mode", comp);
} else if (comp == &syms_vesc.foc_current_kp) {
Expand Down Expand Up @@ -2661,7 +2664,10 @@ static lbm_value ext_conf_set(lbm_value *args, lbm_uint argn) {
appconf = mempools_alloc_appconf();
*appconf = *app_get_configuration();

if (compare_symbol(name, &syms_vesc.foc_sensor_mode)) {
if (compare_symbol(name, &syms_vesc.motor_type)) {
mcconf->motor_type = lbm_dec_as_i32(args[1]);
changed_mc = 2;
} else if (compare_symbol(name, &syms_vesc.foc_sensor_mode)) {
mcconf->foc_sensor_mode = lbm_dec_as_i32(args[1]);
changed_mc = 2;
} else if (compare_symbol(name, &syms_vesc.foc_current_kp)) {
Expand Down Expand Up @@ -2868,6 +2874,8 @@ static lbm_value ext_conf_get(lbm_value *args, lbm_uint argn) {
res = lbm_enc_float(mcconf->l_watt_min);
} else if (compare_symbol(name, &syms_vesc.l_watt_max)) {
res = lbm_enc_float(mcconf->l_watt_max);
} else if (compare_symbol(name, &syms_vesc.motor_type)) {
res = lbm_enc_i(mcconf->motor_type);
} else if (compare_symbol(name, &syms_vesc.foc_sensor_mode)) {
res = lbm_enc_i(mcconf->foc_sensor_mode);
} else if (compare_symbol(name, &syms_vesc.foc_current_kp)) {
Expand Down

0 comments on commit b334247

Please sign in to comment.