I am at my wits end - I am attempting to control a really nice Hudson motor which is part of a telescope mount - it has 8 poles and an integrated quadrature encoder - The part number indicates that it has 4000 cpr encoder, however it also parenthetically states (post-quadrature) - and in fact it fails the PP Check if I use 4000, it passes with 2000 cpr but the reported angle only changes PI radians for a full rotation vs 2PI radians. Oh I am using angle mode and when I turn the system on it starts spinning like a motor. I looked at the quadrature signals on an oscilloscope and they are nice and clean with less than 100 nsec rise and fall times.
Now the setup is running on a Teensy 4.0 with an Infineon board that I have used in the past with no issues at all (different motor and encoder) - the cabling and pinouts are identical - this WAS with an older version of Simple FOC - one thing I notice now is some messages during compile related to something with the Teensy as follows, I tried looking at the code - its a bit cryptic and the warnings arenât very specific as to what pins might be âwrongâ???
c:\Users\dolph\OneDrive\Documents\Arduino\libraries\Simple_FOC\src\drivers\hardware_specific\teensy\teensy4_mcu.cpp:12:54: note: â#pragma message: SimpleFOC: compiling for Teensy 4.xâ
12 | #pragma message(âSimpleFOC: compiling for Teensy 4.xâ)
| ^
c:\Users\dolph\OneDrive\Documents\Arduino\libraries\Simple_FOC\src\drivers\hardware_specific\teensy\teensy4_mcu.cpp: In function âint get_submodule(uint8_t, uint8_t)â:
c:\Users\dolph\OneDrive\Documents\Arduino\libraries\Simple_FOC\src\drivers\hardware_specific\teensy\teensy4_mcu.cpp:93:47: warning: â not in same submodule!â directive writing 23 bytes into a region of size between 21 and 23 [-Wformat-overflow=]
93 | sprintf (s, âTEENSY-DRV: ERR: Pins: %d, %d not in same submodule!â, pin, pin1);
| ^~~~~~~~~~~~~~~~~~~~~~~
c:\Users\dolph\OneDrive\Documents\Arduino\libraries\Simple_FOC\src\drivers\hardware_specific\teensy\teensy4_mcu.cpp:93:13: note: âsprintfâ output between 51 and 53 bytes into a destination of size 50
93 | sprintf (s, âTEENSY-DRV: ERR: Pins: %d, %d not in same submodule!â, pin, pin1);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
c:\Users\dolph\OneDrive\Documents\Arduino\libraries\Simple_FOC\src\drivers\hardware_specific\teensy\teensy4_mcu.cpp: In function âint get_inverted_channel(uint8_t, uint8_t)â:
c:\Users\dolph\OneDrive\Documents\Arduino\libraries\Simple_FOC\src\drivers\hardware_specific\teensy\teensy4_mcu.cpp:130:80: warning: â - only B supportedâ directive writing 19 bytes into a region of size between 14 and 15 [-Wformat-overflow=]
130 | sprintf (s, âTEENSY-DRV: ERR: Inverted pin: %d on channel %s - only B supportedâ, pin1, ch2==1 ? âAâ : âXâ);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
c:\Users\dolph\OneDrive\Documents\Arduino\libraries\Simple_FOC\src\drivers\hardware_specific\teensy\teensy4_mcu.cpp:130:13: note: âsprintfâ output between 65 and 66 bytes into a destination of size 60
130 | sprintf (s, âTEENSY-DRV: ERR: Inverted pin: %d on channel %s - only B supportedâ, pin1, ch2==1 ? âAâ : âXâ);
| ^
is this a problem ? It seems to move the motor fine during alignment checks which always seem to yield the same Zero Electric angle of 6.28 (<< 2PI ??)
MOT: Monitor enabled!
MOT: Init
MOT: Enable driver.
MOT: Align sensor.
MOT: sensor_direction==CW
MOT: PP check: OK!
MOT: Zero elec. angle: 6.26
MOT: No current sense.
MOT: Ready.
Here is the motor/encoder setup code (although still a little bit odd about the 2000 cpr vs 4000 cpr:
// BLDC motor instance BLDCMotor(polepairs, (R), (KV))
BLDCMotor motor = BLDCMotor(8, 2.87, 9.28);
// BLDC driver instance BLDCDriver3PWM(phA, phB, phC, (en))
BLDCDriver3PWM driver = BLDCDriver3PWM(4, 5, 6, 7, 8, 9);
// position / angle sensor instance Encoder(encA, encB , cpr, (index))
Encoder sensor = Encoder(15, 14, 2000);
void doA(){sensor.handleA();}
void doB(){sensor.handleB();}