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.

Motion Control and Motor Drives

cancel
Showing results for 
Search instead for 
Did you mean: 

i have a big delay in my real time pid control

hi ,

since i don't have a digital input module i tried to use the serial port RS232 on my Crio to read the data from an absolute encoder in order to perform PID control for  a dc motor, but the problem is that the data took too match time to be read; there is a big delay between the first read position and the next one,and when i change the slide controller the indicator took time to change, although it should be instantinouse, here is

a snapshot of my vi. 

please i need help.

 

Capture.PNG

 

 .

0 Kudos
Message 1 of 5
(4,454 Views)

Hi Moho,

 

Looking at your code I see a couple of things that might be causing the issue. How long is the delay that you are experiencing? You are trying to transfer 2000 bytes every loop which will cause some delay. You also have a lot of mathematical operations that can take time between loop iterations. Also what is the VI that you have manipulating your waveform? Have you looked into the PID VIs?

Scott B.
AE NI
0 Kudos
Message 2 of 5
(4,437 Views)

I would take a look at the serial query.  Does it always return 2000 bytes every time, with the correct data?  Is there a delimiter in the message that you can use instead?

0 Kudos
Message 3 of 5
(4,430 Views)

HI,

i have reduced the number of bytes to read to 4, but still the same problem now some times it start working normal than began to slow down and some time it is too slow even when i change the slide controller its indicator took time to change, although it should be instantinouse.

 

0 Kudos
Message 4 of 5
(4,422 Views)

Just put the serial query in a loop by itself and see how fast it can run.  Then use a number higher then that to set your loop timing. Also, 9600 is really slow for a serial encoder.

0 Kudos
Message 5 of 5
(4,417 Views)