LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling Motor RPM with PID control

Solved!
Go to solution

Hi everyone,

 

I am trying to operate a BLDC motor (1960KV) at a desired RPM. The actual motor RPM is measured using an optical quadrature encoder (720 CPR). The encoder comes with four wires: 5VDC, DGND, Channel A and Channel B. I am using NI USB-6218, 2022 Q3 labVIEW with Win 11 Home. 

 

1. When set to run at a particular RPM (say 4000), the motor initially gets to the setpoint, but the measured RPM fluctuates between 3700-4400 (shown in image-1). Is there a way to reduce these fluctuations?

2. While operating at the same set point of 4000 RPM, the motor randomly jumps between the range of 4000-14000 (image-2 and 3). This is probably in response to the noise in the input signal. Is there a way to smoothen the response of the motor so that it gets to the setpoint value without abrupt movements, and then stays there (no follow up jitters)?

3. Do I need to apply some sort of filter to the measured data from the encoder before it is provided as process variable to the PID controller?

 

Please let me know if you need any additional info.

 

Thanks.

lza

0 Kudos
Message 1 of 13
(2,577 Views)

Hi Iza,

 


@laz_2331 wrote:

I am trying to operate a BLDC motor (1960KV) at a desired RPM. The actual motor RPM is measured using an optical quadrature encoder (720 CPR). The encoder comes with four wires: 5VDC, DGND, Channel A and Channel B. I am using NI USB-6218, 2022 Q3 labVIEW with Win 11 Home. 


Would you mind to downconvert your VI to LV2021 or LV2019? (File->Save for previous)

 

How do you read the encoder data?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 13
(2,563 Views)

Hello GerdW,

 

Thank you for your response. 

 

I have attached the VI. I hope it works.

 

I am counting the rising edges for the encoder.

 

Thanks,

lza

 

 

0 Kudos
Message 3 of 13
(2,538 Views)

Hi Iza,

 


@laz_2331 wrote:

1. When set to run at a particular RPM (say 4000), the motor initially gets to the setpoint, but the measured RPM fluctuates between 3700-4400 (shown in image-1). Is there a way to reduce these fluctuations?

2. While operating at the same set point of 4000 RPM, the motor randomly jumps between the range of 4000-14000 (image-2 and 3). This is probably in response to the noise in the input signal. Is there a way to smoothen the response of the motor so that it gets to the setpoint value without abrupt movements, and then stays there (no follow up jitters)?

3. Do I need to apply some sort of filter to the measured data from the encoder before it is provided as process variable to the PID controller?


  • The shift registers aren't initialized and can introduce problems when starting the VI a 2nd time…
  • What's the point of building an array from exactly one sample and then calculating the Mean from that value? (You may try PtByPt-Mean instead…)
  • Do you really run the loop at 20ms iteration time? I guess there will be some jitter as you also call DAQmx two times in the loop with your USB-connected device…

Applying a filter (most often low-pass) on the pv will introduce an additional lag that you need to handle with the PID, too. From my experience: this quickly gets tricky! (I sometimes used a median filter with 5 samples when sampling at 100 Hz…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 13
(2,525 Views)

GerdW,

 

I have added shift registers and PtByPt-Mean to the VI. 

 

About the 20ms iteration time: I am not entirely sure what is a good value here. I have seen significant changes in the encoder output when I scan the range of 'milliseconds to wait' from 10ms upto 1000ms. The encoder output sees lesser jitters as the wait time increases, also the amplitude of fluctuations reduce (image attached). At this point, I would just go with a higher wait time. But, is that technically the right thing to do? I would appreciate it if you could point me towards understanding that part better.

 

Thanks,

lza

 

0 Kudos
Message 5 of 13
(2,491 Views)
Solution
Accepted by topic author laz_2331