Notifications
Clear all

Digital control


Forum 1
(@abdullah)
New Member
Joined: 4 weeks ago
Posts: 3
Topic starter  

Hi,

1. can I control DC motor Torque mode using digital control ,using Encoder ,and all calculation in side soloDriver?

2. can I change control law (i.e. change u"control law") in side soloDriver ?

Thank you.


SOLO Team liked
Quote
SOLO Team
(@milad)
Chief Member Moderator
Joined: 1 year ago
Posts: 185
 

Hi @abdullah,

Posted by: @abdullah

1. can I control DC motor Torque mode using digital control ,using Encoder ,and all calculation in side soloDriver?

Yes, sure, SOLO has all you need to control the Torque of a DC Motor ( I'm taking "DC" as DC brushed here, although SOLO can also control the torque of Brushless DC motors too), what you need to do for that is, putting SOLO UNO in closed-loop ( pushing Pin No# 5 Down), identifying the motor parameters, selecting the torque mode and giving Torque references in form of Amps ( of course the unit for torque is not Amps, it's N.m, however, there is a linear relationship between the Torque applied by motor and the active current in Torque generation.)

While you use SOLO for brushed DC motors, "IM" is the current acting in Torque generation, by having that value that you can read it from SOLO using Digital commanding, you can calculate the torque as:

Torque of the Motor [N.m] = Current acting in torque generation ( IM in your case, Iq in case of 3 phase motors)[A] * Torque constant of the Motor [N.m/A] 

You can find the Torque constant of your Motor in its datasheet or you can measure it yourself using tools like torque meter, etc...

To learn about digital Control examples, using our Libraries for Arduino or Raspberrypi, you can go to the "Example" sections, and there you'll see examples on how to communicate with SOLO for various control purposes.

Posted by: @abdullah

2. can I change control law (i.e. change u"control law") in side soloDriver ?

You can do this for Speed and Position loops and put them in your external processor or controller ( eg Arduino, Raspberry Pi, Teensy, ...), you need to notice that the Torque loop has a fixed "PI" controller and it can't be changed fundamentally, so if you watch this video from 7.40 to 10.00, it's true that there we are explaining the algorithm for 3-phase motor controlling but the structure of the loops is exactly the same for DC brushed motors, so you have the closest loop to the motor as Torque loop, then Speed loop and finally the position loop also for the DC brushed motors.

Now if you want to implement your own control law, for example, you want to do a model predictive controller ( MPC) while mixing Position and Speed loop together as your control law, you can put SOLO in Torque mode, and send the torque reference as the output of your control Law to control Speed or position, we have some users that are doing the same.

I will remain available.
Regards
Milad

 

If you found the answers helpful and you could solve your problems, please kindly verify here to help others in the future.


Abdullah liked
ReplyQuote
Forum 1
(@abdullah)
New Member
Joined: 4 weeks ago
Posts: 3
Topic starter  

Thank you 

I have a  question , how to control DC motor using ROS and Raspberry pi 4  

 


ReplyQuote
SOLO Team
(@milad)
Chief Member Moderator
Joined: 1 year ago
Posts: 185
 

Hi @abdullah,

To start controlling the DC motors, I would recommend you to start having your hands on SOLO by using simple Analogue Control both in Torque and speed mode in closed loop, if you read the following article and the video it has inside, you'd be able to do that:

https://www.solomotorcontrollers.com/control-speed-dc-motor-arduino-solo-closed-loop-sensorless/

This tutorial is for Sensorless closed-loop speed control, however, by just putting the Piano Switch Number 4 UP, you can put SOLO UNO in Torque mode and test also the torque mode with the same setup ( on SOLO UNO Direction pin is +5V tolerant, so you can directly connect it to your Arduino or Raspberry PI and no need for an extra resistor).

After you learnt this, you can start working with Digital control and using UART communication to replicate the same behaviour, unfortunately at the moment we don't have an example code with Python in the Raspberry pi environment for controlling DC brushed motors in Torque mode, but by looking at the following example:

https://github.com/Solo-FL/SOLO-motor-controllers-PYTHON-RASPBERRY-PI-library/blob/main/examples/RASPBERRY_PI_position_control_brushless_motor.py

you can do:

  1. if you select the Motor type as the value of "0" which stands for DC motors, by changing 
    # Select the DC-brushed motor type
    motor_type = 0
  2. change the control mode to control the torque in the "Setup" section that runs only 1 time in initialization of the code by :
    #Control The Torque
    __solo_driver.set_control_mode(1)
  3. sending the Torque references in the "Loop" section by:
    __solo_driver.set_torque_reference("your desired Motor current acting in Torque Generation in Float")
    for example, as can be seen below in the example code, https://github.com/Solo-FL/SOLO-motor-controllers-PYTHON-RASPBERRY-PI-library/blob/566d95d371d74a78e2a59235566fc411097c2847/src/solo_motor_controller.py","user_id":5203312} }" data-hydro-click-hmac="1ee6565c3bc31760bcf956da1e9914e9ce6a1297932cc874c1496a0d90dc401f">SOLO will inject 2.8Amps of current into your motor which will result in a certain torque on the shaft.:
    __solo_driver.set_torque_reference(2.8)

    https://github.com/Solo-FL/SOLO-motor-controllers-PYTHON-RASPBERRY-PI-library/blob/566d95d371d74a78e2a59235566fc411097c2847/src/solo_motor_controller.py","user_id":5203312} }" data-hydro-click-hmac="1ee6565c3bc31760bcf956da1e9914e9ce6a1297932cc874c1496a0d90dc401f"> 

The example given above is for position control, so if you want to tune only the torque controller, you can ignore the Speed and position controller tunings like Speed or Position controller Kp and Ki as in Torque mode they have no effect.

in near future, we will add DC brushed motors examples in our library code examples, but I believe you can easily change the existing codes and make them control your DC brushed motor.

 

Posted by: @abdullah

ROS

Regarding ROS, at this time, we haven't published yet a specific tool for that, however, our Arduino Library is written in C++ format, so you can use it directly in ROS and the only thing you need to change are the functions for Reading and Writing to USB or COM port in ROS, and you need to replace them with Arduino functions we have for that, to be more specific these 3 lines inside " bool SOLOMotorController::ExeCMD(unsigned char cmd[]) " function in SOLOMotorController.cpp file

Serial.write(_cmd,10);

while(Serial.availableForWrite() == 0); // wait till end of writing

Serial.readBytes(_readPacket, 10); //read received data

so first you need to send 10 bytes over VCP ( virtual COM port of targeted SOLO unit), wait for a short time, read the feedback from SOLO, you can have a look at the below link about how to do it, of course, somewhere in your code in ROS you need also to open the COM port of SOLO, initialize it with proper parameters and then the rest as mentioned above...

https://answers.ros.org/question/28377/simple-open-a-serial-port-and-send-a-value-to-microcontroller/

https://answers.ros.org/question/334343/how-to-read-data-from-a-serial-port-and-publish-it-on-a-topic-in-c/

I will remain available.

Regards
Milad

 

 

If you found the answers helpful and you could solve your problems, please kindly verify here to help others in the future.


ReplyQuote
Share: