Hello,
in my project i would like to use the B-G431B-ESC1 with SimpleFOC. I am planning on using an arduino mega with a can shield to get data from a can bus. I would then like to calculate a target angle of a bldc on the arduino and send this angle to the B-G431B-ESC1. The B-G431B-ESC1 would then perform the controlling of the bldc motor.
Can i send this data via UART or I2C ?
Both.
The commander has a serial and a i2c interface.
A bit confused, if you’ve got CAN working, why don’t you send data over that. From memory the uart doesn’t work in 1 direction (tx?) Unless you snap off the stlink daughter board as there is some pin sharing going
So i can just connect the RX/TX pins on the arduino and the B-G431B-ESC1 and send data via the commander ?
I have CAN not working yet. Furthermore I get my CAN Data from a Car, so I am fine with trying to listen to the can of the car but i don’t feel confident sending data on the can.
I want to keep the daughter board, so then i2c would be my only option ?
Give the rx/tx a go but don’t be surprised if it works in one direction. Pb3 and pb4 (usart tx and rx) are broken out as a connector AND connected to the stlink and that caused me problems.
The Serialusb works, so computer to esc1 will be fine, but can’t easily connect mega to esc1 usb port.
Another thing you could try is SoftwareSerial using rx(pb4) and tx(pa15). The latter is the ‘pwm’ pin.
(I really can’t remember if it was tx or rx i had trouble with so you might need to use pb3/pa15 if i got it wrong)
alright, thanks for the help.
I used UART in both directions ok, however CAN sounds pretty cool. I think you need an extra tranciever chip though while UART is very handy, I can connect directly with my pc or to any other microcontroller easily. There is modest error control etc. but not as good as CAN.
Did you have to remove the daughterboard for UART ?
No, there are solder pads there. I don’t think the daughter board uses UART, it uses the SWD port.
See the data sheet for the board, it shows the pinouts, the TX/RX pins are broken out to pads down at the bottom between the power terminals.
USART 2 goes to the daughter board and in parallel to the connector for PWM etc. I never tried, but would expect that you cannot easily use both at the same time. USART 2 is the port which receives data from USB (through the daughter board). USART 1 is not broken out, but can be made available with some soldering (on the cost of not being able to use sensors anymore probaby…).
For CAN bus, the B-G431B-ESC1 is fully equipped with a transceiver and a software switchable termination resistor. No additional hardware is required on this end.
To be clear regarding SimpleFOC‘s support:
You can use I2C via I2CCommander from our drivers library.
You can use Serial via the Commander in our main library.
You can use CAN via @Grizzly ‘s SimpleCAN library.
Each solution is a bit different with its own advantages and disadvantages.