Skip to content

Commit 2534765

Browse files
committed
Update pinout for Hall sensors. Add monitoring of the angle_index.
1 parent cd60693 commit 2534765

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎OWNVERTER/FOC_hall_sensor/main.cpp‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ void loop_critical_task();
5353
void application_task();
5454

5555
/* --------------USER VARIABLES DECLARATIONS------------------- */
56-
#define HALL1 PA7
57-
#define HALL2 PC6
56+
#define HALL1 PC6
57+
#define HALL2 PC7
5858
#define HALL3 PD2
5959

6060
static const float32_t AC_CURRENT_LIMIT = 3.0;
@@ -315,7 +315,7 @@ inline void get_position_and_speed()
315315
HALL2_value = spin.gpio.readPin(HALL2);
316316
HALL3_value = spin.gpio.readPin(HALL3);
317317
/* We compute angle index using HALL values. */
318-
angle_index = HALL3_value * 4 + HALL2_value * 2 + HALL1_value * 1;
318+
angle_index = HALL1_value * 1 + HALL2_value * 2 + HALL3_value * 4;
319319

320320
hall_angle =
321321
ot_modulo_2pi(PI / 3.0 * sector[angle_index] +
@@ -553,7 +553,9 @@ void application_task()
553553
printk("%7.2f:", Iq_max);
554554
printk("%7.2f:", manual_Iq_ref);
555555
printk("%7.2f:", I1_offset);
556-
printk("%7d\n", control_state);
556+
printk("%7d:", control_state);
557+
printk("%7d\n", angle_index);
558+
557559
} else {
558560
/* If memory_print is true then we plot scope datas in an infinite loop
559561
* This can be used with ownplot if you have not python script installed

0 commit comments

Comments
 (0)