09-16-2021 07:53 AM
Hi all,
I am at a scenario, where I would acquire xdata (position) and ydata (intensity) from two different instruments and plot it in a waveform graph as it acquires each data point. The program stops after saving xdata and ydata array. Recently I learned about cursors in XY graph. I would like to know if I can ask the user to input a cursor point (a,b) in the waveform graph so that I can process [newX=xdata-a] and [newY=ydata/b] and save newX and newY. I would want to press a button after satisfactorily choosing the cursor a,b for the data process to start. I would also like to know how could I make the program wait till the point (a,b) is chosen.
I am using LabVIEW 2021 community version.
Thanks and Regards,
Pradeep
09-16-2021 07:57 AM
Hi Pradeep,
@pclab wrote:
Recently I learned about cursors in XY graph. I would like to know if I can ask the user to input a cursor point (a,b) in the waveform graph so that I can process [newX=xdata-a] and [newY=ydata/b] and save newX and newY. I would want to press a button after satisfactorily choosing the cursor a,b for the data process to start. I would also like to know how could I make the program wait till the point (a,b) is chosen.
What have you tried and where are you stuck?
09-16-2021 11:30 AM - edited 09-19-2021 12:33 PM
Once we see your code (VI, not pictures!) and know a bit more about your use case, we can give much more specific advice.
09-19-2021 11:23 AM - edited 09-19-2021 11:23 AM
Thank you GerdW and Altenbach.
What property node should I choose to allow the user to drag and set the cursor at the user-desired position?
Also where the XY Graph is saved as a picture file, I could see the cursor in the saved picture. Is it possible to hide the cursor in the saved bmp file, yet visible to the user in the front panel? The saved file is around 1.25 MB. It would be nice to see the file size reduced as I do not need good clarity. Is it possible to save as jpeg? Sorry to ask many unrelated questions in a single post.
This is the program that I am working on for the past two months. This is almost close to complete. Let me know your suggestions. Anything that you would have done differently, if so why.
Thanks and Regards,
Pradeep
09-19-2021 11:36 AM - edited 09-19-2021 11:37 AM
Hi Pradeep,
@pclab wrote:
The saved file is around 1.25 MB. It would be nice to see the file size reduced as I do not need good clarity. Is it possible to save as jpeg?
Don't export to BMP when you don't like the large BMP files!
Export to PNG (or JPG) instead:
("Bild lesen": "get image data" or similar…)
@pclab wrote:
What property node should I choose to allow the user to drag and set the cursor at the user-desired position?
Also where the XY Graph is saved as a picture file, I could see the cursor in the saved picture. Is it possible to hide the cursor in the saved bmp file, yet visible to the user in the front panel?
09-19-2021 12:16 PM
Hello GerdW,
In graph properties >> cursors >> i have checked allow dragging and opted free dragging. The cursor can be moved before running the vi and after the vi has stopped. But I need to choose the cursor position after the acquisition of data and before the normalize event structure. At that time, the cursor cannot be moved. Also that the normalize button does not respond and the txt file is not generated. What could be wrong here?
Pradeep.
09-19-2021 12:41 PM
Hi Pradeep,
@pclab wrote:
In graph properties >> cursors >> i have checked allow dragging and opted free dragging. The cursor can be moved before running the vi and after the vi has stopped. But I need to choose the cursor position after the acquisition of data and before the normalize event structure. At that time, the cursor cannot be moved.
The problem is: there is no time between "after the acquisition" and "before the normalize"!
You need to provide some "time" to the users so they can actually move the cursors…
(This is purely dictated by THINK DATAFLOW!)
@pclab wrote:
Also that the normalize button does not respond and the txt file is not generated. What could be wrong here?
When do you know that the "normalize button does not respond"?
The normalize action is embedded in an event structure - and this event case is only executed "after the acquisition". Due to "THINK DATAFLOW!" there is no other way to execute that event case! (Additionally you block the UI handling with this event case…)
Based on your questions I suggest to rethink your whole program design: when the program should react to user actions ALL THE TIME then you need to place the event structure into its own loop. You should also think about using a statemachine to implement your sequence of actions (DAQ, cursor movements, normalizing, …)!
09-19-2021 12:48 PM
@pclab wrote:
In graph properties >> cursors >> i have checked allow dragging and opted free dragging. The cursor can be moved before running the vi and after the vi has stopped.
Your code is inside out and will never work right as written!
You need to untangle your code into a reasonable state machine. It will be significantly simpler, easier to debug, and will do what you want. Have a look at the templates that ship with LabVIEW.
09-20-2021 12:56 AM - edited 09-20-2021 01:03 AM
Thank you for your valuable suggestions. I am convinced to use event-driven state machines.
I have a few questions, actually a lot. But for the time being...
Say, I have few states, viz. Initialize, Idle, Play, Run, Cursor, Normalize, Save, and Stop. The events would be Play, Pause, Run, Normalize.
I want to sequentially run two events (Run, and Normalize), which would be bound by a for loop. How can I do this? Or is this the right way?
@Altenbach: Regarding the "greedy polling loop" how else would I wait for a particular code to be received from the instrument. Depending on the current position of the stage, the time to move to the home position would vary.
Thank you for your support.
Pradeep.
09-20-2021 01:22 AM
Hi pclab,
@pclab wrote:
I want to sequentially run two events (Run, and Normalize), which would be bound by a for loop. How can I do this? Or is this the right way?
Your statemachine can (internally) store more information than just the "next state" information, like a counter value to simulate that FOR loop!
Like:
IF state == "Save" AND counter <> max_iterations
THEN next_state := "Run"
ELSE next_state := "Stop"
ENDIF
@pclab wrote:
Regarding the "greedy polling loop" how else would I wait for a particular code to be received from the instrument. Depending on the current position of the stage, the time to move to the home position would vary.
Right now those loops may never stop: what do you do when the expected response will not occur? How do you react on communication problems or a stucked stage?