LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with reading data with visa

Solved!
Go to solution
Solution
Accepted by topic author tominsek

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.

Tim
GHSP
Message 21 of 28
(327 Views)

Hi aeastet, 

Thank you very much for all this

0 Kudos
Message 22 of 28
(318 Views)

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 23 of 28
(316 Views)
Solution
Accepted by topic author tominsek

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.

Tim
GHSP
Message 24 of 28
(314 Views)

@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.

 

  • 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?)

 

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:

  • Why do you (mis)use the frontpanel indicators to transfer data between states? Define elements in your MainLoopCluster for the readings of your device!

Again here i was trying to keep thing close to what he had so that maybe he could understand what was going on here.

 

  • You don't seem to handle the error anywhere in your VI!?

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.

 

  • 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)…

 

If you look close this is a queued state machine.

 

  • 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…

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.

Tim
GHSP
0 Kudos
Message 25 of 28
(303 Views)

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.

2.png

1.png

  

0 Kudos
Message 26 of 28
(224 Views)
Solution
Accepted by topic author tominsek

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!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 27 of 28
(212 Views)

Solved...

Thank you

0 Kudos
Message 28 of 28
(197 Views)