Stobber Posted December 22, 2013 Report Share Posted December 22, 2013 (edited) Any good reasons to avoid it? I intend to set the Event Structure's timeout to 0. Edited December 22, 2013 by Stobber Quote Link to comment
gleichman Posted December 23, 2013 Report Share Posted December 23, 2013 Why? Do you want to execute it on a defined core? Otherwise you are just adding delay in execution. Quote Link to comment
Stobber Posted December 23, 2013 Author Report Share Posted December 23, 2013 What do you mean by adding delay in the execution? I want to tie a PID controller into an event-based messaging framework so it can be configured by and report to other components. Quote Link to comment
GoGators Posted December 23, 2013 Report Share Posted December 23, 2013 I assume this is on a real-time target because of where the question was asked. User events are supported on real-time targets, but I don't use them that often because of the other options of queues and FIFOs. What do you mean by adding delay in the execution? I want to tie a PID controller into an event-based messaging framework so it can be configured by and report to other components. So you want to have a deterministic loop doing PID, but you want also be able to send commands to it (like setpoint) I assume. I haven't used execution trace to look at it, but using an event structure is going to make it jittery (don't know by how much). Personally I have used RT FIFO of type U8 array with the array size fixed to the largest datatype. The Create RT FIFO has an input where you set the array size. This will decrease any chance of buffer allocations. Also I would use the Timed sequence structure. It puts the loop in a priority thread, but has less overhead than the timed while loop (10% < CPU). 1 Quote Link to comment
gleichman Posted December 23, 2013 Report Share Posted December 23, 2013 If you have a timed loop with an event structure set to 0 seconds then it will execute as follows. Event Waiting? Yes - Execute Event code [*]Wait for (elapsed time - timed loop time) If you use a while loop with the event stucture it executes the same as above without step 2, so you are adding overhead and increasing the time to react to event by using a timed loop. This would only make sense if you want your PID to not operate faster than a specific frequency. Quote Link to comment
Stobber Posted December 23, 2013 Author Report Share Posted December 23, 2013 GoGators wrote: So you want to have a deterministic loop doing PID, but you want also be able to send commands to it (like setpoint) I assume. I haven't used execution trace to look at it, but using an event structure is going to make it jittery (don't know by how much). Personally I have used RT FIFO of type U8 array with the array size fixed to the largest datatype. The Create RT FIFO has an input where you set the array size. This will decrease any chance of buffer allocations. Also I would use the Timed sequence structure. It puts the loop in a priority thread, but has less overhead than the timed while loop (10% < CPU). I normally use subroutine FGVs to pass data into and out of a PID control loop, but I want to tie in a "Stop" command from an event-based messaging framework I use. What I needed to hear from someone at NI is that using events introduces jitter, so thanks for that. I'll test the loop on hardware, and if the jitter affects the determinism, I'll write a translator that turns events into RT FIFO elements or uses them to control an FGV that enumerates expected messages. gleichman wrote:If you have a timed loop with an event structure set to 0 seconds then it will execute as follows. Event Waiting? Yes - Execute Event code [*]Wait for (elapsed time - timed loop time) If you use a while loop with the event stucture it executes the same as above without step 2, so you are adding overhead and increasing the time to react to event by using a timed loop. This would only make sense if you want your PID to not operate faster than a specific frequency. GoGators inferred my use case correctly. A PID controller doesn't need to be fast; it needs to be consistent. Maintaining determinism in the PID algorithm is more important than responsing to messages quickly. Quote Link to comment
Nayil Alam Posted January 20, 2014 Report Share Posted January 20, 2014 Thank you. Your post really helped me! Why? Do you want to execute it on a defined core? Otherwise you are just adding delay in execution. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.