02-09-2012 09:37 AM
Hello,
I have this VI that gathers data using Modbus and cDAQ I/O. I've noticed that some of the Graphs show small instances where the data goes to Zero for a second or lees, then it jumps to its original state. Other times it jumps to very high values (over the rated limit) and then comes back down to the original state. I've managed to control some of these features using comparisons and while loops. Also, I tried to use the Synchronization functions of LV, but I really don't understand how these work. I'm actually not sure if these even are problems due to lack of Synchronization...
I've attached the VI and its subVIs. If anyone can help me with this I would appreciate it very much.
Thanks in advance,
Jose
Solved! Go to Solution.
02-09-2012 11:59 AM
You'll probably want to look at the "Producer-Consumer" architecture. See "http://zone.ni.com/devzone/cda/tut/p/id/3023" for an overview of this architecture. Basically, you'll want to have two loops (a producer loop and a consumer loop) and a queue to transfer data from the producer to the consumer. The producer loop, which would run at your desired sample rate, would read one scan from each device and send it to the consumer loop via the queue. The consumer loop would receive the data collected by the producer loop, process, and display it.
This all assumes that your sample rate is slow enough that the time offset between reading the cDAQ device and reading the modbus device is insignificant. "Slow enough" is probably 500 ms or more between scans, depending on how fast your modbus hardware is. If you really need the cDAQ device and the modbus device to take their measurements at the exact same moment, then you will need to add some form of hardware synchronization between the two devices, which may or may not be possible with your hardware.
Mark Moss
Electrical Validation Engineer
GHSP
02-09-2012 02:56 PM
Mark,
Thanks, for the explanation. I feel like I finally understood what the other blogs said.
I'll try this out and see what happens.
Also, I wanted to show an image of the graph when it spontaneously reads 0 and then comes back up:
Jose
02-09-2012 03:22 PM
Some other programming things to think about if you are going to redo your program:
1) Keep the block diagram to one window
2) Try not to use stacked sequences (it make it hard to see what is going on in your program
3) Using a cluster to store you data in one shift register may make your code easier to read and manage. Use bundle and unbundle to change data in a cluster.
4) Using an event structure could make your code easier. ( they are one of the best things to come out in LabVIEW in a long long time) Learn how to use them. There are great examples that ship with LabVIEW.
That should get you started.
02-10-2012 10:14 AM
Tim,
Could adding the Event Structure help avoid the signals from getting lost. I'm running the program using the Producer Consumer method discussed before, but I just noticed that some of my current signals got lost. As seen in this picture of the graph.
Later it happened with another current string signals.
I use modbus libraries to communicate with the current signals. I don't know if that helps determine the cause of this.
Thanks
Jose
02-10-2012 10:39 AM
I do not think that adding the event structure will fix that problem. I suspect that is something else. I would have to dig deeper into your code to see what is happening there. You may be getting stuck somewhere in your code and it is keeping you from updating the array. Who knows. The event structure may help free up the code so it runs more efficiently so it might help too.
I would work on cleaning up the programming stye of your code and eventually I believe the reason will be evident.
02-10-2012 10:41 AM
You could be getting read errors from you MOBUS device as well. Do you look for com problems when reading? Do you do any kind of integrity checking on your data?
02-10-2012 02:44 PM
Tim,
I do monitor the status of the Current Meter (which communicates with Modbus), but all the alarms are based on the power supply, tentameter, and if the data is invalid.
I wanted to show this, because I found it very odd:
You can see that according to this Flow Diagram the current signals should not be displayed if they o over or bellow the range specified (time is due to that the signals come form solar panels; therefore the conditions apply only during the day. I tested this for a lower range and it worked as expected. However, when I ran the at the correct rate I noticed this:
The current values were plotted for over a 25 amplitude and, if looked closer, there are plots for values that were 0. Is there a way I can make sure that it only displays when it is day time and in the range specified?
Thanks
Jose
-
02-27-2012 11:26 AM
I would like to try using event structures, but I don't know how to make them so that the event depends of the user to call the event. I see in the examples that the user controls the execution of the event structure by pressing a switch or something alike. In my case, I want my program to run freely, I can't seem to figure out how to make it so that the event structure decides how goes and when.
If anyone can help me here I would greatly appreciate it.
Thanks,
Jose
02-27-2012 03:11 PM
Tim,
I read some blogs and noticed that some people have trouble with their Modbus Decvices getting noise. These noises creat corrupt signals and thus you get abnormalities in the signals. Apparently is a matter of filtering the signal. Now, the only thing I'm not clear is if I must filter the signal through the hardware or with Labview. I know there are some VI and functions for filtering, but I'm not sure if these will help. If you or anyone else has a clearer ideal, please let me know.
Thanks,
Jose