As many others i am new to Arduino.
I am trying to control the torque of a motor in both directions (CW & CCW) through MegaMoto Plus motor board:
And the motor i want to control:
The control signal (signal into the Arduino) is a +-5V where - = CW and + = CCW rotation. As an input signal is given to the Arduino, the motor must produce a torque and continue to do so, even after the motor has stopped because the load is greater than the torque produced from the motor.
You can think of it as a motor connected to a spring. When an input signal of eg. +2V the motor has to turn CCW with a torque 2/5 of maximum, hereby extending the spring - at some point the force from the spring will be the same as the torque/force from the motor and then then the system has reached an equilibrium. if you apply a higher input the motor will start turning CCW again and if you lower the signal the motor will unroll the spring until a new equilibrium has been reached. If no signal is provided the motor must become "loose" and the spring will be the only force (neglecting friction) in the system.
Some will probably ask me why i dont just use a position servo so i will reveal right away that i need to control the torque, NOT the position.
My guess is that i can use a closed loop servo approach, but instead of the feedback signal being a encoder it will be a current measurement. I want to use the current sensors in the motor shield hereby generating an error signal for the feedback loop. The error signal will result in a change in the PWM cycle in order to reduce the error so the produced torque will actually reach the desired value. Is that right?
I am learning every day, so please bear with me.
I want to use the current sensors in the motor shield hereby generating an error signal for the feedback loop. The error signal will result in a change in the PWM cycle in order to reduce the error so the produced torque will actually reach the desired value. Is that right?
I think what you mean is that you want use a feed back signal which you then would compare to an expected value to produce an error value, which you would then use to correct your output value to get the correct torque. I know it may look like semantics, but by describing things as accurately as possible you do improve you chance of success. Often by getting a good description of the problem and the desired results the solution becomes much clearer, if not obvious.
You are of cause completely right - what you describe is what i meant, but failed to write ;-)
Is there no one that can help out here? When i search Google or this forum for Torque control it seems to be very sparse with information. Is that because nobody knows, nobody uses that technique or because it should be obvious how to do it?
well i think unless you could directly measure torque, you need to experiment with your motor first...
when i say experiment you need to carefully plot out the torque vs current graph. this need to be done at various speed so that you really could understand the effect of speed and torque toward the current.
if its linear or curve that you think you seen it in some math text book or you fine with some error then you could make a really nice formula.... of if its somewhat irragular then you need to make a look up table.... if you dont know what it is look it up (pun intended).... ok once you have the formula/look up table then you could use it to make the correction.
Thanks for the reply.
Well, for PMDC motors the torque is proportional to current - the motorboard i have has an analog current sensor that provides a voltage to the Arduino. You can monitor this with the Arduino to give torque feedback as torque is equal to T=Kt*I, where T is torque, Kt is the motor torque constant, and I is the current. I need a linearly increasing output torque with respect to my input signal - i am "just" having a hard time writing the code.
As i said i am completely new to both Arduino and quite new to programming in general. I am studying ME so hopefully i will be able to get my head around it with a little help.
haha so you do have the formula
heres my pointer for you
say you have a set point torque you want rite to make it stable, set a dead band would help too
say that you are able to read the current
ok now its as simple as
if (ReadCurrent < SetCurrent)then increase speed motor
if (ReadCurrent==SetCurrent)maintain speed
if ReadCurrent >SetCurrent ) then decrease the speed.
i hope that could give you some hint and pinter on how to do it
Okay.. i kind of figured that out. But dont i need to do some kind of PID, PI or just P to not overshoot my target value? Is there somewhere i can find an example of this? I should mention that this (when it is done) will be used to electrically steer the front wheels of a gokart (steer by wire system with haptic feedback).
Thank you for your time.
well technically in my hint theres some kind of feedback though not as elegant as PID or fuzzy but it work for most of the time
say now you have a set point of 2Nm but with the current you measure you can say that your motor put out 1.3Nm
ok since that is lower, it will increase slowly until at one point it maybe overshoot alit at 2.2Nm maybe
ok now since that is higher then the set point it will decrease slightly and again it will overshoot and return a value of 1.9 and the since that is slightly lower it will increase and finally it become 2Nm. so as you can see there is some kind of control feedback. just not as elegant as PID.but let say you increase the complexity of each if statement to control how much it will overshoot then well it would be a stable system enough