File tree 2 files changed +20
-3
lines changed
2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 24
24
#define FW_VERSION_MAJOR 5
25
25
#define FW_VERSION_MINOR 03
26
26
// Set to 0 for building a release and iterate during beta test builds
27
- #define FW_TEST_VERSION_NUMBER 64
27
+ #define FW_TEST_VERSION_NUMBER 65
28
28
29
29
#include "datatypes.h"
30
30
Original file line number Diff line number Diff line change @@ -672,13 +672,22 @@ void mc_interface_set_pid_pos(float pos) {
672
672
return ;
673
673
}
674
674
675
+ volatile mc_configuration * conf = & motor_now ()-> m_conf ;
676
+
675
677
motor_now ()-> m_position_set = pos ;
676
678
677
679
pos += motor_now ()-> m_conf .p_pid_offset ;
678
680
pos *= DIR_MULT ;
681
+
682
+ if (encoder_is_configured ()) {
683
+ if (conf -> foc_encoder_inverted ) {
684
+ pos *= -1.0 ;
685
+ }
686
+ }
687
+
679
688
utils_norm_angle (& pos );
680
689
681
- switch (motor_now () -> m_conf . motor_type ) {
690
+ switch (conf -> motor_type ) {
682
691
case MOTOR_TYPE_BLDC :
683
692
case MOTOR_TYPE_DC :
684
693
mcpwm_set_pid_pos (pos );
@@ -1364,7 +1373,9 @@ float mc_interface_get_pid_pos_set(void) {
1364
1373
float mc_interface_get_pid_pos_now (void ) {
1365
1374
float ret = 0.0 ;
1366
1375
1367
- switch (motor_now ()-> m_conf .motor_type ) {
1376
+ volatile mc_configuration * conf = & motor_now ()-> m_conf ;
1377
+
1378
+ switch (conf -> motor_type ) {
1368
1379
case MOTOR_TYPE_BLDC :
1369
1380
case MOTOR_TYPE_DC :
1370
1381
ret = encoder_read_deg ();
@@ -1378,6 +1389,12 @@ float mc_interface_get_pid_pos_now(void) {
1378
1389
break ;
1379
1390
}
1380
1391
1392
+ if (encoder_is_configured ()) {
1393
+ if (conf -> foc_encoder_inverted ) {
1394
+ ret *= -1.0 ;
1395
+ }
1396
+ }
1397
+
1381
1398
ret *= DIR_MULT ;
1382
1399
ret -= motor_now ()-> m_conf .p_pid_offset ;
1383
1400
utils_norm_angle (& ret );
You can’t perform that action at this time.
0 commit comments