07-16-2025 07:30 AM
OK Here is a version with comments. If you do not understand what I am doing that means that you need to learn the basics of programming with LabVIEW. I will try to help with questions but you really need to try to understand what is happening here so you can take care of it moving forward. There is a lot more you can do with this system. You could make it recover if the serial coms get out of sync. You could add data logging. For this you would need to look into a producer consumer system. This is a good starting point. You need to learn how it works before you came make it better.
07-16-2025 07:45 AM
Hi aeastet,
Thank you very much for all this
07-16-2025 07:48 AM - edited 07-16-2025 07:49 AM
Hi tominsek,
@tominsek wrote:
----Could you please take a look and help me so that the graph shows all 4 values, each on its own line?
You don't use a graph, you use a chart.
This is quite a huge difference in LabVIEW, so please use the correct wording!
Did you read the context help for the chart? It shows how to provide data for several plots!
(Hint: it expects a 2D array of samples for multiple plots…)
Why do you separate the Write and Read states? Why not combine it into just one state?
Advantages:
Other stuff:
@tominsek wrote:
----- And also could you give me a hinw where should i put procedure for saving in sql?
Create a new state.
Call the state when appropriate…
07-16-2025 07:50 AM
If what I gave you solved you problem you should mark the question as solved. It is also nice to give Kodus to people that help you solve your issues. Most people here are volunteers. The come here to help because they love LabVIEW and what to see people that use it succeed.
You are very welcome.
07-16-2025 08:01 AM
@GerdW wrote:
Hi tominsek,
@tominsek wrote:
----Could you please take a look and help me so that the graph shows all 4 values, each on its own line?
You don't use a graph, you use a chart.
This is quite a huge difference in LabVIEW, so please use the correct wording!
Did you read the context help for the chart? It shows how to provide data for several plots!
(Hint: it expects a 2D array of samples for multiple plots…)
Why do you separate the Write and Read states? Why not combine it into just one state?
Advantages:
- no need to remember the current command
- handle the VISA reference more easily
- by removing the BytesAtPort you can also get rid of the Stall function, the TermChar will do the waiting for you! (Did you watch this video yet?)
Other stuff:
- Why do you (mis)use the frontpanel indicators to transfer data between states? Define elements in your MainLoopCluster for the readings of your device!
- You don't seem to handle the error anywhere in your VI!?
- Instead of using the "FIFO array" to control the state order you could use a queue - this will improve the statemachine to a QMH (queued message handler)…
- What's the point of the tab container? (The second page is empty!) From UX point of view I would recommend to use as less decorations as possible…
@tominsek wrote:
----- And also could you give me a hinw where should i put procedure for saving in sql?
Create a new state.
Call the state when appropriate…
Hi GerdW
a few things here. I was helping him solve his issues. I would like to respond to your questions.
Why do you separate the Write and Read states? Why not combine it into just one state?
Advantages:
I am doing this so later on if you write to the serial port and get an error you can add the error handling to fix that issue.
I left it this way so that he could follow it more easily. I am guessing that what I gave him was going to take time for him to understand what it is doing.
Other stuff:
Again here i was trying to keep thing close to what he had so that maybe he could understand what was going on here.
I did not build the error handling into the code yet. That should be the next step that he should try to work with. It was an example for him to start with.
If you look close this is a queued state machine.
I usually hide the controls that no one should see on a tab. It is personal preference. This way I also know where to go look for my controls an indicators that are useful but not necessary for the operator.
07-18-2025 02:54 AM - edited 07-18-2025 02:55 AM
hi,
Now i have another problem as i mentioned above a few days ago.
I have condition that it stores data in sql if the power is greater than 0 right. that works absolutly fine. but because when i stop the progrqm and start it again all the values are shiftet by one (example: power is 1500 and voltage is 230, if i stop it and start again then volotage will be 1500 and curr will be 230 ), then it start saving me to sql because the values are shifted by one and you can see that the power is no longer 0 but is 230 even though it is still actually 0.
What should i do so that the values don't move by one, when i run and stop the program.
07-18-2025 03:00 AM
Hi tominsek,
@tominsek wrote:
What should i do so that the values don't move by one, when i run and stop the program.
Before you start the SQL writing you should get rid of bugs in the communication part!
As said before: when your device uses a TermChar then you should use that TermChar for handling the messages!
Did you watch the linked video yet? It REALLY has good explanations!
07-18-2025 03:32 AM
Solved...
Thank you