04-04-2023 08:57 AM
Hello,
I am looking for examples on how to read a button in labview. Can anyone share some details. Or if anyone have worked on something similar then it would be helpful. Thank you.
Solved! Go to Solution.
04-04-2023 09:07 AM - edited 04-04-2023 09:09 AM
Are you talking about a virtual button on the front panel or a physical button connected e.g. to a digital input?
It both cases, it is all in the dataflow where you just need to poll it at reasonable time intervals. Make sure the terminal (or DI read function) can actually be read by the code and is not e.g. hidden inside another case or outside the toplevel loop. (For virtual there are also e.g. value change events, but if the data does not "flow", it won't help you either)
One you give more details and maybe even attach your VI, we can give more specific advice.
04-04-2023 09:12 AM
Its a real button. I havent created any VI. So i need to design a system with a physical button, where when the user presses the button the labview reads that the button has been pressed and then perform certain other task. I am not sure on how to do it. Thats why I am looking for some examples. Thank you.
04-04-2023 09:16 AM
Plain LabVIEW does not care where the data comes from (front panel control, external input, etc.).
Designed right, a button state is just an electrical signal that you can measure. What DAQ hardware are you planning to use?
04-04-2023 09:21 AM
It would have been better communicated if you used the term "push button switch".
You need some DAQ hardware to detect the switch state and you use appropriate drivers to read it from the DAQ hardware. The simplest option would be a simple arduino with LINX toolkit.
Based on requirements you may need a fancy DAQ, like if you need to trigger an event when the switch is engaged or would a regular poll would suffice.
04-04-2023 09:30 AM
@Santhosh. Thank you. This is exactly what I was looking. Thats why I asked, my question was actually do I need some DAQ hardware or is there some fancy push button when you press the button it sends a digital signal that is read by labview. If I need DAQ hardware what would you recommend. This is part of a big production plant. Thank you.
04-04-2023 10:00 AM
@govindsankar wrote:
@Santhosh. Thank you. This is exactly what I was looking. Thats why I asked, my question was actually do I need some DAQ hardware or is there some fancy push button when you press the button it sends a digital signal that is read by labview. If I need DAQ hardware what would you recommend. This is part of a big production plant. Thank you.
You're starting at the wrong end.
What's the requirements for the button reaction? Is it just some slow, safe function (like send e-mail when pushed), or mission critical, fast and dangerous?
If it's e.g. some emergency button the function should be all electrical (i.e. not SW dependant) but you can read the status through SW.
A typical use case is "Perform measurement when button is pressed", which is a slow and safe interaction. In this which case the button sets a DI which can be polled on almost any DAQ-device (it must have a DI ofcourse). If it can happen quickly you can have some anti-bounce SW or even HW. If the timing of this activation is important, PCI-daq cards can generate events which is more accurate than polling.
If you really need timing you'll need some FPGA, which quickly gets expensive.
So, what's the use case and requirements?
04-04-2023 10:56 AM
@govindsankar wrote:
... is there some fancy push button when you press the button it sends a digital signal that is read by labview.
Yup, it's called your computer's keyboard. You could also read a game controller if you want joysticks, etc... You could bluetooth a wireless signal from a button app on your cellphone to LabVIEW. A digital DAQ card can read hundreds of physical switches really fast. You can detect digital signals on your PC's COM port (if you have one) with LabVIEW.
You need to tell us more information about what you actually need to do for us to provide valid suggestions. 😉
04-05-2023 08:58 AM
What I actually need is to control a hydraulic press. So when I press a button, my labview program will read the button has been pressed. Then the program will inform the control system of the hydraulic press that the function has to be performed, and then the press will put holes in a battery cell. This is the process that has to be done.
04-05-2023 09:17 AM
@govindsankar wrote:
What I actually need is to control a hydraulic press. So when I press a button, my labview program will read the button has been pressed. Then the program will inform the control system of the hydraulic press that the function has to be performed, and then the press will put holes in a battery cell. This is the process that has to be done.
Looks like a job for a PLC and HMI, but you could do similar stuff with cRIO as well.