Control a BLDC motor (3 Hall sensor) with a Joystick

Hello, thank you very much for the info.

I saw a similar post or someone was talking about it. He actually set it up via Simplefoc Studio. I would start with that the day I got the card.

In fact I thought that the PID would make the wheel behave differently depending on the mode chosen. That the PID settings were not exactly the same for the two modes. Since the two modes do not do the same. But I think it’s obviously no use.

I wanted to know if you knew what the BLDCDriver3PWM and BLDCDriver6PWM driver part is for. As the name suggests, is it to run the engine with PWMs? But does this only apply to sensorless motors ? Just curious about that.

Thanks !

The drivers can be configured to work with 3 or 6 PMW signals here are a couple of links that explain how they work

I can somewhat answer the part about 3 pwm and 6 pwm, there are different driver ic’s or dedicated drivers for bldc motors.
Some accept a pwm signal for U V W (positive side) from the MCU, but then the mosfet driver or motor driver ic just generates the negative side signal for the actual switching mosfets on its own (negative side is basically the inverse of the positive side signal).
For 6 Pwm the MCU generates a dedicated pwm signal for positive U V W and for Negative U V W, this gives you more controll over what the driver ic does

Edit: to slow

Hi @JorgeMaker ! Sorry for the absence and for not responding earlier. :sweat_smile:

I ordered the Board Infineon bldc shield ifx007t :

I am trying to run my motor without the hall sensor at the moment. I am using the Open_loop_velocity_example library. I modified it slightly to match the PIN assignment.

Here are the one of the PowerShield.
image

Here are the one of the PowerShield.

So I modified the code from BLDCDriver3PWM(9, 5, 6, 8); to BLDCDriver3PWM(11, 9, 10, 6);. And now we have this in general :

// Open loop motor control example
#include <SimpleFOC.h>


// BLDC motor & driver instance
// BLDCMotor motor = BLDCMotor(pole pair number);
BLDCMotor motor = BLDCMotor(11);
// BLDCDriver3PWM driver = BLDCDriver3PWM(pwmA, pwmB, pwmC, Enable(optional));
BLDCDriver3PWM driver = BLDCDriver3PWM(11, 9, 10, 6);

// Stepper motor & driver instance
//StepperMotor motor = StepperMotor(50);
//StepperDriver4PWM driver = StepperDriver4PWM(9, 5, 10, 6,  8);


//target variable
float target_velocity = 15;

// instantiate the commander
Commander command = Commander(Serial);
void doTarget(char* cmd) { command.scalar(&target_velocity, cmd); }

void setup() {

  // driver config
  // power supply voltage [V]
  driver.voltage_power_supply = 24;
  driver.init();
  // link the motor and the driver
  motor.linkDriver(&driver);

  // limiting motor movements
  motor.voltage_limit = 12;   // [V]
  motor.velocity_limit = 50; // [rad/s] cca 50rpm
 
  // open loop control config
  motor.controller = MotionControlType::velocity_openloop;

  // init motor hardware
  motor.init();

  // add target command T
  command.add('T', doTarget, "target velocity");

  Serial.begin(115200);
  Serial.println("Motor ready!");
  Serial.println("Set target velocity [rad/s]");
  _delay(1000);
}

void loop() {

  // open loop velocity movement
  // using motor.voltage_limit and motor.velocity_limit
  motor.move(target_velocity);

  // user communication
  command.run();
}

For the moment I am testing without the hall sensors because it is necessary to order special resistors on this board. I’ve ordered the PowerShield board on JLCPCB and the Mosfets BTN8962 on Aliexpress. I am waiting for this card to test the hall sensor .

Regards :slight_smile:

1 Like

Did it work? :slight_smile: Everything seems fine

No, just a bit of noise.

What is Enable(optional) for ?

Enable pin of your driver

Ok, but I don’t understand which one should I put ? I’ve tried without anything but It doesn’t work too.

Maybe this is not the correct number : BLDCMotor motor = BLDCMotor(11); because I don’t know the specs of my motor.

But I have no movement, not even shaking.

I thought it would be easier without sensors but it’s visiblment more complex … I look forward to receive my PowerShield cards to test with the hall sensors.

You have to set the appropriate pole number in order to make it work

Yes I did it but didn’t work either. I’ve tried all the combinaisons. I’m waiting for the PowerShield board. I tried with another motor (only 2 poles) and it worked. I think I have to use the hall sensors of mine …

I will keep you informed in the coming days.

Seems like I’m a masochistic pyromaniac cause my BTN just arived from Aliexpress (I don’t know if it work for the moment ).

Regards :slight_smile:

Interesting, I am very curious how it works, since all official Infineon driver distributors are completely out of stock until end of 2022. I was told under very good authority that the aliexpress chips are partial rejects where they take the bad batches and instead of crushing them for recycle they run them through the packaging machines after hours and sell them on aliexpress. The chips definitely work but most of the time the sputtering or doping or silicon temperature regime was partially wrong, which means the timing and current profiles are off. So they will work but you may experience overheating and lower current profiles, and occasionally the chip will pop.

What you are saying seems logical to me. I will tell you how the fleas behave. The packaging looks fine.

This is something I was dreading, I ordered more for this reason. It’s about doing tests. I don’t need anything very specific. Only something that does the job.

Here are my chips.

I hope you are wrong and that I will not set my project on fire :sweat_smile: :rofl:

:crossed_fingers: :crossed_fingers: :crossed_fingers:

You got me so curious I also ordered from two vendors. I want to use them for testing. They sell them for like a dollar a chip, that’s really suspicious, because the cheapest I could find from official distributors was around $5 retail.

You got a link where you ordered?

AliExpress is something else, i just found a 800a 1200v IGBT module, 5pcs for 5$🤣

Yes I think we order to the same distributor :slight_smile:

Here is mine : Livraison gratuite BTN8982 BTN8962 BTN8982TA BTN8962TA 5PCS - AliExpress 502

I am not responsible for the damage caused by this chip. I have not yet tested.

Even the Aliexpress reseller will no longer have BTNs I should have bought more from the start :sweat_smile: :rofl:

You could even order a baby from aliexpress…

https://www.aliexpress.com/item/1005001961762825.html

I picked two random ones, just search for btn8962ta

https://www.aliexpress.com/item/4000843043016.html

Hi everyone,

I’m asking you a little message to show you my board and ask for your opinions.



I will solder the BTNs tomorrow. I wanted to know if a soldering iron would be enough to solder the “back” of the BTN?

I am going to solder pins for the arduino which are female on the other side to be able to use the pins of the arduino.

And I would solder cables directly to the terminals for power, motor and hall sensors.

#include <SimpleFOC.h>

// Hall sensor instance
// HallSensor(int hallA, int hallB , int cpr, int index)
//  - hallA, hallB, hallC    - HallSensor A, B and C pins
//  - pp                     - pole pairs
HallSensor sensor = HallSensor(2, 3, 4, 11);

// Interrupt routine initialization
// channel A and B callbacks
void doA(){sensor.handleA();}
void doB(){sensor.handleB();}
void doC(){sensor.handleC();}

void setup() {
  // monitoring port
  Serial.begin(115200);

// Joystick Ini
  pinMode(VRx, INPUT); 
  pinMode(VRy, INPUT); 
  pinMode(SW, INPUT_PULLUP); 

  // check if you need internal pullups
  sensor.pullup = Pullup::USE_EXTERN;
  
  // initialize sensor hardware
  sensor.init();
  // hardware interrupt enable
  sensor.enableInterrupts(doA, doB, doC);

motor.controller = MotionControlType::velocity;

}

void loop() {

  xPosition = analogRead(VRx);  // (A0)
  yPosition = analogRead(VRy);  // (A1)
  SW_state = digitalRead(SW); 

speed = map(xPosition, 650, 1023, 0 , 100);
motor.target = speed;

}

I intend to use this code to start what do you think ?

Does everything sound good to you?

Regards ! :slight_smile:

Much better if posible to use pinheads rather than cables or use a cable with a pin and then solder the pin.

If you put a little bit of tin on the pad and then heat it with the soldering iron it should work

Hey @Jekylleur,

The infineons board is very very similar to the powershield, or better said powershield is very similar to the infineons board;
It will definietely work with the simplefoc :smiley:

Just make sure to provide the enable pins to the BLDCDriver3PWM constructor (btw you’mm have to do this for both of the boards)

BLDCDriver3PWM driver = BLDCDriver3PWM(11, 9, 10, 6, 5, 3);

BLDCDriver3PWM receives optionally 3 enable pins for each of the phases.