10-03-2017 10:48 PM
Hi,
I am trying to build a program where it reads the input data,and calculate the rate if change.
The program suppose to work this way,where it reads the first data and read the data again 1 seconds later,and compare the change of data within this 1 sec.
>Read Data
>eg.4°
>Read data again
>eg.7°
>Compare the data in this 1 sec span
|4° -7° | / 1sec=3° /sec
I am using labview robotics 2015,version 15.0.1.I am using arduino to input data and the task I am trying to
perform is measure the rate of angle change in a second.
10-04-2017 01:15 AM
Hi CQL,
I am trying to build a program where it reads the input data,and calculate the rate if change.
And what is your problem?
Where are you stuck?
All you need is a while loop with a shift register and a 1s wait function inside…
10-04-2017 01:20 AM
Sounds good so far. You have a well described algorithm (if not necessarily a very accurate one) and so now it just comes to programming it.
Have you managed to take a measurement yet? This will be the first/main step by the sounds of it - once you know how to make 1 measurement, it's just a matter of repeating and each time calculating differences. For that, it's likely easiest to use a Shift Register.
Example:
10-05-2017 02:18 AM
@GerdW wrote:
Hi CQL,
I am trying to build a program where it reads the input data,and calculate the rate if change.
And what is your problem?
Where are you stuck?
All you need is a while loop with a shift register and a 1s wait function inside…
Thanks for the reply.
Currently i am stuck with implementing the shift register function with my current program.
@I've tried implementing @cbutcher shift register program with my current program and the program just did not work as before.
Is it because of 2 while loop? or something else?
Or which other function will be the best for me to implement the rate of change from that particular data with my program?
10-05-2017 02:59 AM
Thank for the reply.
I've tried putting the program you showed with my program and my program just do not work as before.
Is it because of the 2 while loop function at the same program?Not sure whats the issue
10-05-2017 03:56 AM
My example was using the loop to generate subsequent samples - you should move the shift register onto the outer While loop and not add a second while loop at all. Then, it might work how you want it to.
I'm curious as to why you're using the Bytes at Port to trigger a read with no wait, especially given I'm thinking that 50 bytes combined with the True constant wired to the Configure Serial Port indicates it does use a termination character (and the lack of termination character specified suggests if I recall correctly a CR character (but it might be LF?)).
10-05-2017 05:51 AM
@cbutcher wrote:
I'm curious as to why you're using the Bytes at Port to trigger a read with no wait, especially given I'm thinking that 50 bytes combined with the True constant wired to the Configure Serial Port indicates it does use a termination character (and the lack of termination character specified suggests if I recall correctly a CR character (but it might be LF?)).
This is actually a good setup for instruments that sporadically send data. If any data has come in (Bytes At Port > 0), then a message has started. Therefore it is safe to read and let the read complete with the termination character. Just make sure there is a wait in the FALSE case (Bytes At Port = 0).
10-05-2017 10:44 AM
crossrulz wrote:This is actually a good setup for instruments that sporadically send data. If any data has come in (Bytes At Port > 0), then a message has started. Therefore it is safe to read and let the read complete with the termination character. Just make sure there is a wait in the FALSE case (Bytes At Port = 0).
Good to know!
10-06-2017 01:55 AM
Apparently this work.But then i am pretty sure that the value i read at "Change/time indicator is not the the change/1sec.
Right now i am trying to find out how long does it take to travel from one shift register to another.(The difference in time for the "new value" and "old value"). So i can ÷ the value accordingly.
Note: I am unable to put the timer to 1000ms as it will cause lag to my rotation of compass etc.
10-06-2017 02:33 AM - edited 10-06-2017 02:33 AM
As you are not polling the data but simply read it whenever available, you need to adapt to the pace of the input.
If you know that you get exactly N samples in a second, you may discard N-1 data out of N.
Alternatively, you may record a time stamp after each read (for example using the Tick Count (ms) function) in a second shift register. The value difference should be divided by the time stamp difference - that is the elapsed time - expressed in seconds.