Steering BLDC Motor with RT-Ubuntu PC

Hi

My goal is to steer one motor over CAN with my ubuntu pc as a starting step.

I have the following hardware setup:

  • 1 motor connected to boosterpack
  • boosterpack connected to uDriver (launchpad)
  • launchpad connected over CAN-cable to PCI CAN card (without any terminal resistor, selfmade CAN-cable)
  • PCI CAN card attached to pc

software setup:

The output of the python-script is the following:

  • SYS: D | MTR1: DA | MTR2: DA MTR1: Iq: 0.000, Pos: 0.000, Speed: 0.000 MTR2: Iq: 0.000, Pos: 0.000, Speed: 0.000

Following the CAN description pdf, I figured that it means that both motors and the uDriver are disabled :frowning:

Can someone give me advice to move forward?

Best
Yannick

1 Like

Hi @yannick,

there are a few things. Are you using a uDriver or a TI launchpad? These are not the same thing. The uDriver is the 5x5 cm custom design board where the launchpad is the longer board sold by TI.

In addition, the mw_dual_motor_torque_ctrl you use is only for communication via SPI to the master board. This means, if you want to use CAN, you need to flash this mw_dual_motor_torque_ctrl repo.

The python script you found was from the very early days of programming the launchpad. It should still work though. These days we use the blmc_driver - see here for an example for a single motor control.

Best,
Julian

1 Like

Thanks Julian!

I am using the TI launchpad. I managed to flash the uC and was able to run the c++ code you are giving :smiley: If I am running on the ubuntu pc meanwhile the python script, I can see that one motor and the launchpard are enabled :slight_smile: Now I just need to figger out why my motor doesnā€™t rotate when I apply a non-zero torque current.

Best
Yannick

Thatā€™s great news! When you rotate the motor by hand, do you see the position readings updating? If not something might be wrong with the encoder setup (and then also applying a current might not work).

1 Like

I see. I havenā€™t yet installed an encoder (my goal as a starting point is just to apply a little torque and see the motor spinning). I guess I need to change up either the c++ program or the python program. Right now I am using the given python CAN program and try to manually send torque references in a while-loop after I enabled everything. Reading the mentioned CAN documentation and your c++ code, one can use 4 bytes for setting the torque_reference of one motor. Is 0x[0f,ff,ff,ff] the highest torque current (2A) and 0x[ff,ff,ff,ff] the most negative torque current (-2A)?

The encoder is essential for using the motor setup. Note that you are using a brushless motor with three phase wires. There is no simple ā€œput some current and have the motor rotateā€ in our setup. The motor phase gets aligned during the initialization phase (when the motor gets enabled). Without this I donā€™t think you can use the current firmware setup to get the motor to turn.

1 Like

I understand. In that case, I am going to finish first my actuator module and then try againā€¦ Thanks for helping me :slight_smile:

Iā€™m struggling with running the actuator module as a spring.

Hardware setup:

  • Actuatormodule connected to launchpad (motor and encoder)
  • launchpad connected to powersupply, rt computer and CAN connection to PCI card

Software setup:

what is working:

  • If I change IQ to a non-zero value in main_2mtr.h and activate the motor, the motor spins
  • When I unplug the motor from the actuatormodule (but let the encoder plugged) and plug on just a motor without the actuatormodule, I can do the following. I can turn the actuatormodule motor and the connected motor turns as far as I turned the ā€œnot connected motorā€ (you can see the video here).
  • Basically I am able to send certain commands (like motor activate) to the launchpad and I can receive values (e.g. encoder position) in the c++ program.

what is not working:

  • PD control of motor (c++ program) doesnā€™t get applied to the motor. The coils are magnitized though.
  • Virtual Spring Mode of launchpad firmware

Question:

  • Did someone manage to run the virtual spring mode of the launchpad firmware? If yes, how did you change the firmware? Because just enabling the spring mode doesnā€™t work for me.

Hi Yannick,

we run the virtual spring mode for debugging purpose and I think we donā€™t change the firmware. How did you enable the spring mode - did you change the firmware or did you send the enable virtual spring command?

Best,
Julian

Hi Julian

I enable the spring mode in the firmware by setting gFlag_enableVirtualSpring[2] = {true, true};

Greetings
Yannick

Hi Yannik,

looking at the code, this should enable your virtual spring. Not sure why itā€™s not working for you. You mentioned the motors calibrate nicely at the beginning? Did you try to set the virtual spring behavior manually and run the C++ code? This way the motors get enabled and the virtual spring is working.

Best,
Julian

Thanks Julian, the spring mode is working! (was my fault that I couldnā€™t let it run)

Now I need to figger out why I cannot send a ref_current from the c++ program to the launchpad.

Hi

Does someone know? Is it possible to flash the SPI dual_motor_ctrl firmware on the launchpad instead of the udriver? I want to send over SPI commands to the launchpad instead of CAN.

Best
Yannick

Hi Yannick,

I think you will be able to flash but not to use the SPI firmware. That is as the lunchpad doesnā€™t provide pins to interface with the SPI lanes.

The launchpad uses the two SPI communication channels to boot up the motor drivers. On our custom made micro driver boards, one of the SPI lanes was changed to use for communication.

Best,
Julian

Hi Julian!

Thanks for your quick response. I see, so the udrivers have two spi connections free because they have already the inverter built in? In that case I need to find the SPI pins from the launchpad to the second inverterboard. Next, unplug that inverter board and connect the pins with a masterboard right?

Best
Yannick

Hello,

It should be possible to mod the TI board to free one of the SPI and use it for communication. But you need to modify the connections between one of the boostxl and the Lanchpad.

On the microdriver, instead of using one SPI for each DRV, we use the same one with a different chip select line. You will need to do the connection according to this schematic : https://github.com/open-dynamic-robot-initiative/open_robot_actuator_hardware/blob/master/electronics/micro_driver_electronics/eagle_design_files/microDriver_v2.zip (to be open with eagle)

It is important to keep the connection as short as possible between the boostXL and launchpad.

Best,
Thomas.

2 Likes

Hello, I am jumping on this thread to keep the answers centralized :slight_smile:

I have the same setup as OP :

  • Launchpad
  • dual_motor_ctrl over can and the python code to test

When sending the can frame to enable mtr1, the mtr moves slightly (1/100 of a turn?), is it what it is supposed to do ?
After that I can read the encoder output but enabling virtual spring mode does not work.

Hi tlemarec,

When sending the can frame to enable mtr1, the mtr moves slightly (1/100 of a turn?), is it what it is supposed to do ?

Yes, thatā€™s the expected behavior. The motor gets aligned / calibrated for around 5 seconds once it gets enabled.

After that I can read the encoder output but enabling virtual spring mode does not work.

Have you tried to enable the spring mode in the firmware manually? Does sending torque commands work?

Best,
Julian

Hello @jviereck,

I am trying to send torque commands but without success.
Can you confirm that the following frame format is correct ?

005#00.00.00.0F.00.00.00.00

The current sent from the board to the pc via can bus seems to be noise.

Is it possible my wiring is wrong ? How can I check the wiring of the 3 phases ?

Iā€™ll note that I tried increasing the current sent but the current returned by the board is still noise (rapid oscillation centered around 0, with a max amplitude of ~0.005).
But increasing this current does have a visual effect : the motor ā€˜jumpsā€™ then stays locked and start to heat if the current is high enough.