simplefoc / Arduino-FOC

Arduino FOC for BLDC and Stepper motors - Arduino Based Field Oriented Control Algorithm Library
https://docs.simplefoc.com
MIT License
2.06k stars 530 forks source link

[BUG] Compile error with Arduino MEGA 2560 #190

Closed ator1811 closed 2 years ago

ator1811 commented 2 years ago

Hi,

I get a compile error when I compile the Encoder example with an Arduino Mega 2560 board Arduino-FOC/examples/utils/sensor_test/encoder/encoder_example/ I'm on version Simple Foc version 2.2.2. It says:

/...../Arduino/libraries/Simple_FOC/src/drivers/hardware_specific/atmega2560_mcu.cpp: In function 'void* _configure6PWM(long int, float, int, int, int, int, int, int)':
/...../Arduino/libraries/Simple_FOC/src/drivers/hardware_specific/atmega2560_mcu.cpp:149:22: error: expected primary-expression before ',' token
     .pins = { pinA_h,, pinA_l, pinB_h, pinB_l, pinC_h, pinC_l },
                      ^
/..../Arduino/libraries/Simple_FOC/src/drivers/hardware_specific/atmega2560_mcu.cpp:151:6: error: request for member 'dead_zone' in 'pwm_frequency', which is of non-class type 'long int'
     .dead_zone = dead_zone
      ^~~~~~~~~
/..../Arduino/libraries/Simple_FOC/src/drivers/hardware_specific/atmega2560_mcu.cpp:152:3: error: could not convert '{{pinA_h, <expression error>, pinA_l, pinB_h, pinB_l, pinC_h, pinC_l}, <expression error>}' from '<brace-enclosed initializer list>' to 'GenericDriverParams'
   };
   ^

Compilation error: exit status 1

What is wrong? It looks like the error is caused by a typo in the code, but I'm not sure. Compiled with an Arduino Uno gives no problems.

Regards

runger1101001 commented 2 years ago

Yeah, its a typo. You can just remove the extra ,

We'll fix the example for the next release, and very sorry for the inconvenience!