PA12 is the MCU pin according to UM2516 (ST`s user manual).
(now I changed the browser and then I can even upload pictures …)
PA12 is the MCU pin according to UM2516 (ST`s user manual).
and here is the measurement of the working phase:
and the not working one with TIM1_CH2 (yellow channel 1) always on:
I checked the PDF manual, so pin mapping seems correct
Could you print the values of all the pins? I’m shooting in the dark here, but his is some timing issue with the way the MCU is being programmed.
BLDCDriver6PWM(A_PHASE_UH, A_PHASE_UL, A_PHASE_VH, A_PHASE_VL, A_PHASE_WH, A_PHASE_WL);
Print all values for A_PHASE_xx etc, as integers, so we see what the 6PWM sees. At some point they all translate to raw integers, let’s see if they match the integers from the documentation.
This is what I see when I trace A_PHASE_xx :
it comes from:
but honestly I dont understand how those integers are used.
Hmmmm… very strange!
If find it best to use the STM32 pin names like PA9 , PB6 etc… rather than pin-numbers when working with the STM32 core. Using the Arduino pin numbers adds an extra layer of confusion. But if you have pre-defined constants like you do, that’s probably the clearest way.
PA9/PA12 should be working, as you have verified in the docs…
PA9 is also used in I2C2 and USART1 - are you perhaps initialising either of these peripherals?
Could you share PeripheralPins_B_G431B_ESC1.c? Check in HALL_TIM_MODULE_ENABLED if any of the pin configurations are commented out.
At that point it would be best to run a bare bones, simple open loop, no extra setup, not even Serial setup and calls. And plug in the direct reference to the pins, such as
BLDCDriver6PWM(PA8, ???, PA9, PA12, PA10, PB15)
Not sure/remember what’s the ??? pin however.
Also, I believe I posted a barebones code here at some point in the past, try running that?
This is perhaps some pin mapping issue.
Hello from a new user
I only used Arduino Ide, not Platformio. but PIO_FRAMEWORK_ARDUINO_ENABLE_CDC enables usb, and Pa12 is a usb dataline.
Could this be the problem? What happens if you remove it?
I have not activated anything else than what is in the open loop velocity example. I have even taken out all serial communication - no effect.
That exactly was the problem.
Solved and now I can go further …
Absolutely fascinating. So many ways to go wrong due to different environments. I guess Arduino IDE does all this behind the scenes for you.
Hello, Sorry to be another person having trouble with simpleFOC/B-G431B-ESC1. This is my first time using simpleFOC so I believe I am having a lot of beginner issues. I’ve used the forums and the videos about setting up platformio and B-G413B Part1 and Part 2 as resource but I still have these a couple of issues. Any help is much appreciated with solving any of the below problems.
I have none of the initialization messages printing to terminal (then again I might not be accessing it correctly).
I circled and x-out the difference between my platformio.in compared to @Lutz1967 when I comment out the part I x-out and uncomment the part I circled (see picture) I get a whole bunch of errors (so I can’t replicate @Lutz1967 's successful code).
Looking at a example for open velocity in the docs (Velocity control example using Drotek’s L6234 driver) uses onTarget once and doTarget for the the other Target value, while the example for open loop velocity in simpleFOC library is uses doTarget for both if I try to match the code of the docs I get a whole bunch of errors.
I get this error/caution without changing my code (see picture).
Also I have attached my main code.
Thanks In Advance,
The B-G431 can be a little harder to get going, so I hope you have patience…
IIRC the USB port of the board is on the daughter-board, and connected to the ST-Link. The G431 itself does not have USB, so you should remove the USB_HIGHSPEED_FULLMODE.
The SERIAL_UART_INSTANCE=2 is correct, and this should redirect Serial.println() to the USB-Serial connection of the ST-Link. So when you hit monitor in platformIO you should see stuff.
It can be helpful to insert a
while (!Serial) ; or just a delay of 5s or so to give you a chance to hit the monitor button in PlatformIO and make sure you see the first messages, because they can come pretty fast. Esp. in open loop mode there is no delay due to initialization.
To see the motor debug output add the line
to your setup before calling motor.init()
- your lib_deps should look something like this:
lib_deps = askuric/Simple FOC@^2.2.1
No need to add SPI and Wire, they’re part of the core.
Did you add the library to your project using PlatformIO’s library manger?
- Looks like the Drotek example is wrong? I can’t see a function doTarget() so I think it should say
command.add('T', onTarget, "target velocity");in that example.
It’s just the name of the function, but it has to match up with what you defined above.
I think you need to put everything to Serial2 instead of Serial. At least that works for me. I use the serial monitor from the ArduinoIDE. PlatformIO does print but I didn’t managed to make serial input. With the Arduino serial monitor it works.
With the option
SERIAL_UART_INSTANCE=2 the normal “Serial” instance should point to UART2, and you should not need to use “Serial2”
Thanks both of you for your answers. @runger, yes I added the latest simpleFOC library to the project. Also I added the delay and made the changes you suggested and can now see the terminal messages, however sadly the motor is still not spinning. I am getting warnings at build, upload, and terminal steps. I’ve tried a lot of troubleshooting but still no success yet. If you (or anyone else) would be so kinds as to continue helping me troubleshoot that would be much appreciated.
First to put some constraints on this problem I believe I have ruled out the following:
Its not a bad board issue, I have multiple boards and swapped them out to retry troubleshooting.
Its not a wiring issue, these boards seem to cause the motor to twitch just by being given power and being connected without any code and since it wouldn’t twitch unless it was connected I don’t think its a wiring issue.
Its not a driver issue, I downloaded the ST drivers and STM32CubeProgrammer software and the board is showing up as the board and is connecting in STM32CubeProgrammer.
Which is why I believe it to a be a code issue.
Here are my warning in the build, upload, and terminal that potentially can be used to pin point the issue:
I get this warning (see image below), I think it maybe relates to the doTarget onTarget thing because in the main code its partly underlined (also I see other people using doTarget in their code) not sure if that’s relevant kind of shooting in the dark here.
I get this warning in the upload terminal.
When I type in a value (number for desired velocity) and press enter I get this error in the monitor terminal “Warn: \r detected!”
Help Much appreciated.
Thanks in Advance,
Again attached is my main and platformio.ini:
Update: Its Spinning!!!
SimpleFOC is so cool!
Turns out in later troubleshooting steps I forgot to turn on the power
However big problem still can’t enter values into the terminal, getting that “Warn: \r detected!” also still have those other error codes under Build and Upload Terminal sections in above post (if that’s relevant) so I guess updated question is does anyone know how to fix my entering values into the terminal issue?
Help Much Appreciated,
You can ignore that one. The compiler is being very fussy and complaining about the fact that we’re passing a const char * (pre-defined string) to a function that takes char* type. It can be ignored.
Hmmm… never seen it before. I think you can ignore it if it says “SUCCESS” on the bottom.
Change the newline type for the serial terminal to just newline. At the moment it is sending newline and return. Its a windows vs. unix thing, line endings. In platformIO I think you can use the option:
monitor_flags = --eol LF
But I think you can ignore it, SimpleFOC warns you but it still handles your input.
May I ask, are you entering the ‘T’? Your input should be something like T1enter or T4.3enter
Where the enter is you hitting the return key.
It was the the not pressing T first thing, I can communicate in the terminal now . The “build flag --eol LF” didn’t get rid of the error message but I don’t care because I just needed to access the terminal and now I can. Thanks so much for all your help @runger I am so happy it is working now.