I am using TReX DMC01 to control DC motor(131:1 Metal Gearmotor 37Dx57L). I am using the motor to actuate brakes for one of my project. I want to implement a PID control of the motor so that i can increase/decrease motor speed and forward/reverse the motor autonomously.
I have the flexibility to use serial only or serial with analogue inputs. I have just got the serial with analogue working. I have placed the mode jumper and just ramping up and down the Voltage manually and read the current when applied a load on the motor. One issue is that i am not able to reverse the direction of the motor without enabling the serial override. Do i have to enable and disable the serial override every time when i operate. If I have to use it autonomously (i.e PID control)i guess by this way it wont be possible. I wont be using any analogue controller. I am planning to just get the PID working so that i can set the motor work by itself.
I am using LabVIEW. But if anyone can give me a any sort of code for implementing PID i could convert it to the LabVIEW equivalent.
Any help would be really grateful.
It is not clear to me exactly what you are trying to do and what problem you are encountering. Could you be more specific about how you are trying to use the TReX? Do you have the mode jumper set to be in analog or serial mode? If the TReX is in analog mode, you should have to activate serial override before the motor will respond to serial commands. Are you able to control your motor using just analog or serial control alone? Could you post a wiring diagram showing how you have everything connected and a picture of your setup?
Separately, this vi posted by another community member might be helpful.
Thanks for your reply.
I figured out the problem for motor not reversing. The controller neutral was set to 0. I have changed it to 512 now i am being able to change the direction.
Regarding PID, I tried to change the current so that the analogue voltage increases or decreases accordingly. I haven’t been able to completely solve the logic that i need.It is still a work in progress.
Basically i am using the motor 37D 131:1 to act as an actuator to press the disc. I could know when the wheel is locking up and probably from the motor encoder(not connected in the picture but it is working) how much the pad has travelled from it rest position til pressing the disk. But the main control needs to be something similar to ABS system so that the motor presses and releases the disk to slow the vehicle down.
I am reading the current through serial. As mentioned in the command document of TReX I am multiplying any decimal value by 150mA to convert it to actual motor Current. But the motor information shows that the free run current is 300mA. But the serial read is not showing this current. Is that suppose to be like that? This might be a completely stupid question. But i just want to make myself everything clear.
Any guidance will be grateful.
I am glad you figured out the problem you were having with driving the motor in reverse. It sounds like you are trying to do PID control with the current output that you are getting from the controller. Please note that the current sensor on the TReX cannot measure low currents like 300mA very accurately, so you will probably want to use a separate current sensor. Also, you mentioned that you are expecting to read a current value close to the motor’s rated free-run current. That is the current the motor will draw with nothing attached to the shaft. When the motor is installed in your setup, it will likely draw more current because the setup itself is loading the motor.
Ok that solves the problem of my serial not reading the free run current.
So does that mean the sensor wouldn’t read any small current in loading. For example if the Get Motor current command gave me value of 1 then i multiply it by 150 mA to get the motor current. Because when i did testing by push the magnet underneath the motor i got small values coming up.
I understand that the stall torque and current information given in the webiste for motor is fairly accurate. I got a relationship between torque and current by plotting it.
Torque = Kt*Current Drawn by Motor… i took 300mA at 0 torque and 5A at Stall torque @12V
Kt i got is = 0.3755 Nm/Amps (similar calc for speed current relation)
I have limited the current to decimal value of 22 ( i hope this limts the current to 3.3 amps, assuming the current factor is 150mA) for safety purposes.
My question is would the maximum torque or stall torque now be = 0.3755*3.3 =1.239Nm or something else .
Like I said in my previous post, the current sense readings of the TReX at low currents are very inaccurate. Even when no current is flowing through the device it might still read a couple counts on the current sense outputs, so I would treat them as having an uncertainty of something like ±500 mA, which makes them very untrustworthy at low currents.
Your calculations seem fine, except that you seem to be ignoring that the line relating torque and current has an offset and will not go through the origin. If you limit the current to 3.3A the maximum torque you will be able to achieve will be around 1.239Nm, which is effectively equivalent to the stall torque at 8V.