From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PID motor control

VTrying to implement system similar to https://decibel.ni.com/content/docs/DOC-16983 with a9 volt DC motor max speed 350 rpm 

The problem that I am facing in here is that

1.>when i set a desired speed more than 200 rpm the controller output oscillates and suddenly becomes zero and the counter shows a random value(i.e feedback is not proper).For lower speed it works fine.

2>Also the rise time for the system is very high..Whta could be the causes for these glitches?

 PIDmotorcontrol_problem.JPG

0 Kudos
Message 1 of 18
(3,346 Views)

You should configure the measurement ONCE, outside the loop, before the loop starts, and clear the task only after the loop exits.

 

How did you choose your PID Gains? That will affect the rise time.

 

Can you post a screenshot, or a data file, showing what happens when you set the speed over 200rpm? It might be helpful to put the PID output on the same graph with the measured and target speeds (although you may need to put it on a separate Y axis to get the scaling right).

 

Above 200rpm, do you know that the pulses will be long enough to avoid being caught by the filter? Have you tried putting an oscilloscope on the pulse output while running the motor at a constant high speed?

 

Have you checked for any error from the DAQmx Read?

Message 2 of 18
(3,337 Views)

Hi nathand,

I have configured the gains using trial and error method  and they seem to work well in simulation when i am trying to simulate the motor with its transfer function.The rise time seems large when trying to implement the system with hardware( cDAQ 9184 DIO 9401 Analog O/P card 9263)

As you say the pulses might be wrongly filtered out.I have tried reducing the minimum pulse width parameter for the filter but that does not change results.But using it is necessary otherwise the counter reads garbage values.

I am not working with system today but when i follow up tomorrow i shall surely check for errors in DAQmx read..Can you tell me what sort of eror you are suspecting might occur?

I am uploading my VI for you to check if i have made a mistake in programming.

Thanks 🙂

 

0 Kudos
Message 3 of 18
(3,307 Views)

As I already mentioned, there is a problem with your code. You should both configure and clear the DAQmx Task outside the loop; leave the Read inside the loop.

 

Do you know that your simulation matches the behavior of the real system? How did you determine the transfer function? If the simulation doesn't match the real system, then of course the gains that you determine won't work well either in the real system. It is almost always better to use a tuning method such as Ziegler-Nichols than to tune through trial and error. Again, please attach an image showing the performance of the system, including the PID output.

 

I don't know what DAQmx error you might see, and there might not be one. It's just the first thing I ask people to check when their acquisition doesn't return the expected results, since frequently there's an error that explains the problem.

 

An oscilloscope will allow you to measure the actual pulse width, which you can use to determine if the filter values are appropriate.

0 Kudos
Message 4 of 18
(3,288 Views)

posting a word file with images about system behaviour..

I hooked up the hall output to an oscilloscope the min. pulse width was around 50 ms.on setting that as min. pulse width,problem couldnt be solved.I suspect it makes the system more vulnerable to noise.As a beginner,I am just curious as to what could be the cause of so much noise!

 

You are possibly right about the gains,but the system has earlier worked with well with another chassis.Right now i just want to get the system working at all speeds ,rise time is the next priority.

0 Kudos
Message 5 of 18
(3,254 Views)

Sorry, I have no idea here. I would recommend watching the input on the scope while the system is running and see if you can see a noisy electrical signal right when the RPM value goes high. I would also take out the PID, set a constant voltage to the motor, and see if the speed is stable (remove any variable load on the motor first). That should help determine if the problem is instability in the motor speed or in the measurement.

 

I'm puzzled that your graph shows so few data points - on what time scale is this happening? You may want to put some sort of timing function inside your loop, it doesn't appear that there's one there now.

 

Have you tried making the change to the VI that I suggested, moving the DAQ setup and clear outside the loop?

 

Again, it would be easier to interpret your graphs if you put the PID output on the same graph as the setpoint and measured speed, then move the output to a separate Y axis. That way the measurement and output will line up.

0 Kudos
Message 6 of 18
(3,233 Views)

I have made the changes to the VI as you suggested.

I have checked with the motor speed it is stable..there is definitely a problem in measurement.

Sorry I did not get what you said about the timing VI.What would the timing VI do?
Thanks for all your help.

0 Kudos
Message 7 of 18
(3,215 Views)

There should be some sort of timing in the loop so that each loop iteration takes approximately the same amount of time, and so that the loop doesn't spin as fast as possible and consume resources unnecessarily. The DAQ functions will limit the loop rate somewhat, but it would be a good idea to have a loop timer at a fixed rate (which might also be accomplished through the DAQ functions, depending on how you configure them).

 

To try to figure out the measurement problem, there are several experiments you could try. First, run the system in an open-loop mode (no PID loop). Slowly increase the signal to the motor and watch the speed feedback. Does it suddenly become unstable at some speed? Check grounding and electrical noise. Can you connect a pulse generator in place of the motor feedback, and slowly increase the speed at which it generates pulses? Does it become unstable at the same speed? If an external pulse generator is stable, then there's likely a problem with grounding or shielding of the motor. If you get the same instability with a pulse generator as with a motor, then it's likely a problem with the way you've configured the measurement. If it's not stable at any speed, it could be a problem with the DAQ device itself.

0 Kudos
Message 8 of 18
(3,177 Views)

Do you mean making use of a timed loop instead of the while loop?I have tried it but it seems to deteriorate performance.

Agree that DAQ functions will limit the loop rate somewhat, how can this be accomplished through the DAQ functions?

Sorry for troubling with such a whole load of questions , using LabVIEW and DAQ first time.

I will try with the experiments you suggested.

0 Kudos
Message 9 of 18
(3,153 Views)

Hi Gaussy,

 

set a sampling rate for your CTR task. Something like 100-200Hz should be fine… Reading one sample will wait for the next available sample and so limit the loop rate!

 

LabVIEW comes with alot of example VIs. Open the example finder in the help menu, search for DAQmx examples!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 18
(3,147 Views)