06-25-2017 02:33 PM
Thanks altenbach.
This is a different type of averaging. It's not a boxcar or moving average to smooth one dataset as your example shows. It's more like averaging multiple curves in Matlab. The same test is repeated 10 times, producing almost the same curve of 40 points each time. Curve 1 and curve 2 are averaged together, (not along themselves) then curves 1, 2 & 3, then 1,2,3 & 4, and so on. Each time a dataset comes in (every 1/2 second), the same curve improves until the 10th is the best. the problem I had was plotting each curve as the loop was running, but it works nicely now.
06-25-2017 02:53 PM - edited 06-25-2017 02:54 PM
@ASH2020 wrote:
Curve 1 and curve 2 are averaged together, (not along themselves) ...
I have no idea what that even means! (What is the difference between "together" and "themselves"??)
My code shows how the signal improves with each iteration, showing the average of the previous N signals at each iteration. How is that different to what you are trying to do? Did you try my code?
If you want to average the last N samples of an experiment that goes on forever, you would need to store N signals in a 2D array, of course.
06-25-2017 04:06 PM
@altenbach wrote:
@Blokk wrote:
Hmm, i think the two waits are not parallel, so they will add up. But i will benchmark it, when i get to my PC 🙂Except for dataflow constraints, all waits run in parallel. There is a 100ms wait inside the sequence frame, a 500ms wait in the toplevel diagram of the big FOR loop. (And a 2ms wait inside the 40x FOR loop (80ms total) which makes absolutely no sense). If the others can finish in under 500ms, the total loop time will be 500ms. (See also this discussion)
Thanks for the clarification! I will keep this in mind!
06-25-2017 04:41 PM - edited 06-25-2017 04:49 PM
Hi, it looks like your code is a standard "boxcar" where you would pick an average coefficient, say 3, then you average points 1,2,3 then average points 2,3,4, then average points 3,4,5 and so on "along" the curve, which gives a smoothing of the dataset. Like this:
Mine averages all the point 1s on curves, then all the point 2s, etc. Like this:
Hope this makes sense.
06-25-2017 05:11 PM
Hey Blokk,
Just to explain the waits, the 100ms is between the Visa write and Visa read. I found this by experimentation, any shorter than about 70ms and it crashes. The 2ms was purely for development, so I could see the loop count with an indicator. Otherwise it runs so fast you can't see it happening. It've taken it out now. The 500ms sets the time for acquisition of data packets. It is bang on 5 seconds for 10 loops.
06-25-2017 05:50 PM - edited 06-25-2017 06:06 PM
@ASH2020 wrote:
Hi, it looks like your code is a standard "boxcar" where you would pick an average coefficient, say 3, then you average points 1,2,3 then average points 2,3,4, then average points 3,4,5 and so on "along" the curve, which gives a smoothing of the dataset. Like this:
You need to quote relevant parts of the post you are replying to, else nobody knows what "your code" refers to. My code certainly does not do what you describe here. My code shows the following at each iteration on the second plot:
06-25-2017 11:24 PM
@ASH2020 wrote:
Hey Blokk,
Just to explain the waits, the 100ms is between the Visa write and Visa read. I found this by experimentation, any shorter than about 70ms and it crashes. The 2ms was purely for development, so I could see the loop count with an indicator. Otherwise it runs so fast you can't see it happening. It've taken it out now. The 500ms sets the time for acquisition of data packets. It is bang on 5 seconds for 10 loops.
Hmm, in principle, if the serial protocol of your device uses a proper termination character, you do not need a Wait between the VISA Write and Read. The VISA Read will just wait automatically until a data string arrives with a termination character at the end. As I see in your first post VI, you left the termination character unwired, thus keeping the default xA value. Does your manual of the device state what termination character should be used? Either, I do not see the "Build Data Packet.vi" content, how you form the serial request.
Actually just recently I worked on a driver for a serial device, and using a proper termination character, I did not need any Wait between the VISA Write and Read. However, the device "did not like" polling: I needed to add a 100 msec wait after each Write/Read sessions...So in the end I needed a Wait anyway 🙂
06-26-2017 04:03 AM
My apologies altenbach. In that case I misunderstood. Thank you for the example.
06-26-2017 04:13 AM
Blokk, we haven't got a termination character in the data request at the moment. The hardware is our own and has different parts, each with an ARM processor, running a Forth kernel. The data packet sent from the GUI has an address, an event, various time elements, packet length, a bit of other stuff and a checksum. The main ARM then routes the packet accordingly to the other ARMS via I2C and something then takes place, which then provides the return packet. So, there may well be a delay in the equipment itself. We're so flat out getting everything going at the moment that there hasn't been the opportunity to look into timing in great detail. I have my doubts that it is to do with the serial bus, but one day, when there's time, I will investigate. (Yeah, and pigs might fly!)
Thanks for all your help with it.
06-26-2017 04:31 AM
@ASH2020 wrote:
Blokk, we haven't got a termination character in the data request at the moment. The hardware is our own and has different parts, each with an ARM processor, running a Forth kernel. The data packet sent from the GUI has an address, an event, various time elements, packet length, a bit of other stuff and a checksum. The main ARM then routes the packet accordingly to the other ARMS via I2C and something then takes place, which then provides the return packet. So, there may well be a delay in the equipment itself. We're so flat out getting everything going at the moment that there hasn't been the opportunity to look into timing in great detail. I have my doubts that it is to do with the serial bus, but one day, when there's time, I will investigate. (Yeah, and pigs might fly!)
Thanks for all your help with it.
I see! 🙂 Anyway, if the RS232 comm works stable with that 100 msec wait, just do not touch it! 😄