Forum
Hello, do you have an example code for the torque control of Brushed DC motor (with and/or without incremental encoder)?.
Hi @atrach,
The example code that you can convert for your DC motor controlling the Torque can be the below one:
In this example you need to do a couple of things:
- Put the motor type on DC brushed
SOLO_Obj1->SetMotorType(SOLOMotorControllers::MotorType::dc); - put the feedback mode on sensorless
SOLO_Obj1->SetFeedbackControlMode(SOLOMotorControllers::FeedbackControlMode::sensorless); - put the control mode on Torque mode:
SOLO_Obj1->SetControlMode(SOLOMotorControllers::ControlMode::torqueMode); - Now you can give the desired torque ( current ) set point using the following command:
SetTorqueReferenceIq(float yourdesireCurrentInAMPs);
Some notes:
- if you put SOLO in Torque Mode while DC brushed motors are utilized, SOLO will control the current of your DC motor with internally built-in PI controllers, you just need to set the desired value (set-point) and the "IM" parameter in the Motion terminal monitoring section will show you the amount of current in your motor in terms of Amps.
- The Torque control on DC brushed motors with SOLO is done in a sensorless manner, so there will be no need to have any type of sensors like Encoders.
Let me know if you need further clarifications.
Milad
If you found the answers helpful and you could solve your problems, please kindly verify here to help others in the future.
@milad I understand what you sent me. However, that tutorial that you sent me is for UART communication. I want to try something a little more simple. I tried to do torque control with Arduino and simple analog control (Below code and schematic) but nothing happens. I don't know where is my error (code, wiring, or maybe I have to even plug the controller to the main software for the first time) Please can you help me.
int dic_pin = 12;
int torque_pin = 9;
int desiredDutyCycle_Iq;
void motor_setup()
{
pinMode(dic_pin, OUTPUT);
pinMode(torque_pin, OUTPUT);
}
void torque_control()
{
digitalWrite(dic_pin, LOW);
desiredDutyCycle_Iq = 88; // I change this value manually for now
analogWrite(torque_pin, desiredDutyCycle_Iq);
delay(10);
}
Hi @atrach,
Just a couple of points:
- it seems you are using SOLO in Analogue mode, for that you need to set up the Piano switch first, meaning for instance to do the Torque controlling of a DC brushed motor, you need to put the Pin 1,2 and 5 Down first. ( please check the user manual for the further explanations)
- I recommend you before using Arduino, first set up wiring with Potentiometers like the image below ( for the DC motor you just need to connect B and C as you showed me on your drawings), so you can test the Torque by changing the potentiometer value to S/T pin while the piano switch is setup like above, then once you made sure the torque is controlled, you can start with the Arduino:
- Regarding your code written for Arduino, are you sure on the output of the Arduino you have the PWM pulses?
I will remain available for further discussions.
Regards
Milad
If you found the answers helpful and you could solve your problems, please kindly verify here to help others in the future.
Hello guys I have a new inquiry here with the controller so you may help me. I put the motor controller in torque mode (ANALOG MODE) as you said in previous email, so I have been using it for a while however there is a couple issues that are coming up.
1) The first issue is that as you can see in the figure 1. below, when I am commanding near maximum duty cycle ~ 255, I should be getting close to 32 amps output. However, I put a current sensor in series between the output of the motor controller and the DC motor and it measures less than 32 amps (see figure below). This means that I am getting half of the torque that I need at that particular moment. Notice the circles that I drew on the plots of current sensed and pwm, I should be getting more current.
2) looking at figure 2 below. from the same chart but I have drew other circles. This time my issue is that I am commanding an smooth current decrease but what the motor controller is doing is sending a flat zero current and then it compensates by sending another peak of current later. you can see from the graph how this affect my deacceleration and therefore the torque that I need.
3) Finally. I am trying to get a better response of my angular acceleration, velocity, and current because I have to do curve fitting and to find parameters of the system experimentally such as inertia etc. The problem is that as you see in the figure 3 below. The controller sometimes send negative currents even do I am just commanding current in one direction. This is adding noise in the response that I am looking for; therefore it is harder to get better parameters estimation. I can guess that this negative current is because of the close loop configuration of the controller. Meanwhile, I had the idea of putting diodes with resistors in parallel at the output of the controller to see if I get just current in one direction. But it did not work. The controller just didn't work so I had to remove them and go back to previous configuration. I would like to know how you deal with that. NOTE: for this particular test I was commanding just positive currents
Thanks for all you help.
Hi @atrach,
Thanks for your post and thorough analysis.
1) The first issue is that as you can see in the figure 1. below, when I am commanding near maximum duty cycle ~ 255, I should be getting close to 32 amps output. However, I put a current sensor in series between the output of the motor controller and the DC motor and it measures less than 32 amps (see figure below). This means that I am getting half of the torque that I need at that particular moment. Notice the circles that I drew on the plots of current sensed and pwm, I should be getting more current.
Are you operating SOLO in Closed-loop torque Mode?
It seems you are referring to 255 from the Arduino side, but what type of Arduino are you using?
In case 255 is the maximum duty cycle of the Arduino, assuming that Arduino can output a 5V pulse, then you should be able to reach the desired torque limited to the current limit value up to 32A at 5V input to S/T, however, if you use an Arduino that outputs 3.3V PWM pulses, at 255 you'll be able to only reach up to 66% of max torque ( S/T input's maximum is at 5V)
2) looking at figure 2 below. from the same chart but I have drew other circles. This time my issue is that I am commanding an smooth current decrease but what the motor controller is doing is sending a flat zero current and then it compensates by sending another peak of current later. you can see from the graph how this affect my deacceleration and therefore the torque that I need.
This might be due to the switching patterns of SOLO, we are releasing a new firmware in the next few days, with an improved switching pattern that can solve your issue for this, we will update you through an email.
3) Finally. I am trying to get a better response of my angular acceleration, velocity, and current because I have to do curve fitting and to find parameters of the system experimentally such as inertia etc. The problem is that as you see in the figure 3 below. The controller sometimes send negative currents even do I am just commanding current in one direction. This is adding noise in the response that I am looking for; therefore it is harder to get better parameters estimation. I can guess that this negative current is because of the close loop configuration of the controller. Meanwhile, I had the idea of putting diodes with resistors in parallel at the output of the controller to see if I get just current in one direction. But it did not work. The controller just didn't work so I had to remove them and go back to previous configuration. I would like to know how you deal with that. NOTE: for this particular test I was commanding just positive currents
This also can be enhanced with the new firmware with improved switching patterns for DC brushed motors, we blive by the end of next week the FW should go out, then after that you'll need to check this again let me know if it helped or the issue persisted.
Milad
If you found the answers helpful and you could solve your problems, please kindly verify here to help others in the future.
Hello Milad,
Thanks for your help, we are waiting here for the new release of the FW. Meanwhile:
1) We are using an Arduino Mega pin9 to control the PWM and it does output 0-5 volts.
2) We have never connect the controller to the motion terminal. We went directly to analog mode and setup everything as we discuss earlier. I understand that there is an internal PID that controls the current, I can see a couple of knops in the controller that may be for tunning this gains. We need to setup this experiment really fast. Do you think you can walk us through the motion terminal on a online meeting.
Please, if this is the case you can write to my company email directly (Atrach@newtmobility.com)
Thanks
Hello Millad,
We did connected to the motion terminal and did the parameter estimation of the motor. But the performance was the same.