LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple delays for different sampling rates. (edit)

Hi,

First of all, congratulations on your community and especially to the moderators, for the excellent job done.

I’ve always used LIFA for simple projects, with one or two sensors, but since I don’t have much knowledge about Labview I’m having a problem.

I’m developing a project for which I need data from several sensors: DHT11, HC-SR04, among others… Regarding these two, I can make them work individually without problems.

The issue is that the sampling rate of DHT11 should be at least 1s, while for HC-SR04 (and other sensors) I wanted the sampling rate to be 100 ms.

How can I solve this situation?

I already tried whileloops with different delays, but it doesn’t work…

EDIT:

I searched the posts for possible solutions for my problem.

I thought I couldn’t divide the reference wire in parallel whileloops, but I saw it done in some examples, so I tried that with 2 sensors (DHT e LDR), and in fact it solved the problem.

Captura de ecrã 2013-10-3, às 12.24.34.png

Until I tried it with another sensor, HC-SR04, and something very strange happened.

Captura de ecrã 2013-10-3, às 12.34.22.png

The data don’t seem to make any sense.

Captura de ecrã 2013-10-3, às 12.33.36.png

I continued looking for other solutions, until I saw this post: https://decibel.ni.com/content/thread/15577?tstart=300, where it says that we shouldn’t divide the reference wire in several parallel whileloops, since it creates a race condition and therefore data can get out of sync and cause one or both of the loops to return errors.

It is possible that this “out of sync” is what’s making the scores go off whitout any sense.

It seems like one possible solution for this is to use a state machine to operate the two tasks at potentially different rates.

I would like to know if any of you has already used a state machine to solve this kind of problem.

Thanks,

AMagro

0 Kudos
Message 1 of 1
(2,980 Views)