From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

how to implement the Transfer Function in Real Time VIs?

You are using the Simulation loop so it is up to you to implement negative feedback correctly - which you have.  I really don't understand the point of your questions if you are doing everything in simulation loop - maybe try to be more specific and clear in your questions, then you might get some answers that are helpful!

 

Here are a couple of comments on your VI

 

1) There are clearly some problems with your code in the simulation loop - just looking at the PD section - you have an integrator with a input fixed to the sample time! Even if you are attempting to use an integrator in some very convoluted way to build the derivative action, it is still totally wrong. Your PI section also has similar problems. Test each bit of your code separate first before even closing the loops - you should identify which bits are incorect and fix. Trying to debug in a closed loop is hardwork.

 

2) Your simulation is entirely discrete - why are you using a variable step solver ?

 

3) Given your original description is in continuous time transfer functions, simulated the system in continuous time first and checked that works before doing the conversion to discrete. Then for each block check that  the conversion from continuous to discrete is correct.

Consultant Control Engineer
www-isc-ltd.com
0 Kudos
Message 11 of 15
(1,975 Views)

Thanks Andy!

 

My thoughts were that since I was deploying the control system on a physical testbad, I needed to discretize the continuous forms of the controllers and plant.

Are you suggesting that the control and simulation loop is useful for simulation only?

Also, are you suggesting that I do not need to convert the transfer functions to discrete forms?

And about your question on the integrator wired to discrete time, after discretizing the PD controller in the uploaded pdf attachment, I found its transfer function to be the function in the attachment.

I could not find a reasonable way to implement the (z-1) delay except I use the CD TF functions.

 

Lastly, what method do you think is best to deploy this system on myRIO? Using the CD and Simulation loop or using shift registers and while loops?

 

I look forward to your reply.

 

Thank you!

0 Kudos
Message 12 of 15
(1,969 Views)

The Simulation loop can run on a real-time target (LV RT anyway - not FPGA though). You have to use a fixed step solver, and to make it run in real-time you have to select the timing of the loop to be synchronised to the hardware. We've just done exactly that on a project.

 

And, if you runing the controller in a simulation loop, then you can keep everything in continuous time representation.

 

Converting everything into discrete time and using the timed loop (not while loop!) and feedback nodes or shift registers should also be fine if you choose sample rate correctly. It will have less computational overhead than using the Simulation loop - which in some applications might be important. I am not sure about the myRIO and which way you should go.

 

You should be able to implement a deriative very easily, feed a signal into a delay block (z^-1) and then subtract the delayed signal from the original signal and divide by the sample time (I still think there is something wrong with your transfer function, but can see what you were trying to do).

 

Hope this is helpful.

 

 

Consultant Control Engineer
www-isc-ltd.com
0 Kudos
Message 13 of 15
(1,962 Views)

"You have to use a fixed step solver, and to make it run in real-time you have to select the timing of the loop to be synchronised to the hardware. We've just done exactly that on a project."

 

How exactly do you do this?

In the attached VI, I have taken everything back to continuous time and used the PID blocks included in the CD and Simulation Palette to fix my controllers.

If you mean checking the box that says, "Synchronize Loop to Timimng Source" by your statement, "select the timing of the loop to be synchronised to the hardware", then I think I get your drift.

But as for your comment in choosing a fixed step solver, could you elucidate on this exactly? I believe this is probably where I am currently having issues as the amplitude of my measured signals get really large as can be seen in the attached VI when you run it.

Also, I'm still not so sure if I am doing the feedback right. I need the "head pose" as a feedback to both of the PI and PD controllers. Can you please check the VI if I am doing this accurately?

 

Message 14 of 15
(1,957 Views)

Thank you!

 

I fixed my problem actually. So grateful!

0 Kudos
Message 15 of 15
(1,940 Views)