08-26-2008 09:55 AM
08-26-2008 06:10 PM
For synchronization purposes, you'd probably be better off with one loop. However, to maintain synchronization with two loops, you'll want one to wait on the other until a flag is set/reset. This will introduce handshaking in your loop which would at least ensure that you don't miss your data points.
What is your actual end-goal with this? That may lead to some better ideas.
08-26-2008 08:10 PM
08-27-2008 10:48 AM
suni,
Is your custom function different every time the loop runs, or will it be the same function, or the same set of functions based upon some parameters? If you are needing to continuously acquire but also process and then output, I agree that the two loops might be the better way to go. You might look at a producer-consumer style architecture.
08-27-2008 01:45 PM
08-28-2008 05:45 PM
suni,
If the functions only depend on the inputs before the simulation begins, you can create this function outside of your main while loop. Then pass the functions to the while loop and use them when you'd like.
Also, as far as "Real-Time" - your system will not run in true 'Real-Time' unless you are on a RTOS. If you are using the Windows OS, you will not be 'Real-Time'.
As far as the system reacting slowly to your inputs, this is entirely dependent upon when those inputs are being read. There is going to be delays through your program, and if you need a particular input to be as fast as possible, then that reading should be in its own separate while loop so that its speed does not depend on other factors.