キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

Automating Button Clicks

Hello all,

 

I have been working with an Omega platinum temperature controller.  Most of the VI was provided by omega, and I added in a second reading.  Their example VI utilizes an event structure, but I need to read the temperature about 1 time per second.

 

I've tried (unsuccessfully) to divide the time by a numeric constant and output true if there is no remainder and false if otherwise.  I have tried using a while loop but this also did not work. 

 

Is there a way to have LabVIEW click this button for me once per second? I have attached the VI below.

 

Thank you,

Jackson

0 件の賞賛
メッセージ1/35
5,956件の閲覧回数

If you mean the Read button, then yes.

Inside the Event Structure that handles the button press, all it's doing is sending a User Event.

Create a timeout case in the same Event Structure, then send the same user event. Set the timeout to 1000ms and you're done 🙂

 

Edit: in fact, just go to the Read case, then right click on the border and choose "Edit Events handled by this case" then on the left, click "Add Event". Select "Application" from the middle column then Timeout from the right column. Complete by wiring a 1000 to the hourglass at the top-left of the event structure.

Adding a timeout caseAdding a timeout case


GCentral
メッセージ2/35
5,941件の閲覧回数

cbutcher,

 

I tried to follow that same method but I recieved the error code:

 

VISA Write in MB Serial Transmit.vi:630007->MB Serial Master Query.vi:1850006->MB Serial Master Query Read Holding Registers (poly).vi->Platinum_MB_SerRead.vi->Platinum_MB_Example Serial Master.vi

 

Does the timeout set for the read button also impact the write button?


Thank you,

Jackson 

0 件の賞賛
メッセージ3/35
5,930件の閲覧回数

Hi,


@jackson040 wrote:

VISA Write in MB Serial Transmit.vi:630007->MB Serial Master Query.vi:1850006->MB Serial Master Query Read Holding Registers (poly).vi->Platinum_MB_SerRead.vi->Platinum_MB_Example Serial Master.vi


So that's not really an error code, it's the call chain for the error - i.e. it tells you where the error occurred. If you go through those VIs (from right to left, starting at your main VI then working into the subVI in the bottom loop's Read case and then into their subVIs) you could see where the error originates.

 

What was the error code? (i.e. not just the top bit of the message, but the number and perhaps the explanation text?)

 


@jackson040 wrote:

Does the timeout set for the read button also impact the write button?


No. The write button is separate. Do you need both to happen once per second?


GCentral
0 件の賞賛
メッセージ4/35
5,904件の閲覧回数

@cbutcher wrote:

If you mean the Read button, then yes.

Inside the Event Structure that handles the button press, all it's doing is sending a User Event.

Create a timeout case in the same Event Structure, then send the same user event. Set the timeout to 1000ms and you're done 🙂

 

Edit: in fact, just go to the Read case, then right click on the border and choose "Edit Events handled by this case" then on the left, click "Add Event". Select "Application" from the middle column then Timeout from the right column. Complete by wiring a 1000 to the hourglass at the top-left of the event structure.

Adding a timeout caseAdding a timeout case


This approach assumes that no other events occur during the 1 second. I think that in this case it will generally work - but if, for instance, the user were pressing Clear Error once every second then the timeout will never occur. For this reason I don't like using the timeout for timing. I would just send the Read command every 1 second in its own loop - it's just sent via a queue.

0 件の賞賛
メッセージ5/35
5,828件の閲覧回数

@johntrich1971 wrote:

This approach assumes that no other events occur during the 1 second. I think that in this case it will generally work - but if, for instance, the user were pressing Clear Error once every second then the timeout will never occur. For this reason I don't like using the timeout for timing. I would just send the Read command every 1 second in its own loop - it's just sent via a queue.


OP mentioned 'about once a sec', so it might be enough. I'd probably use the timeout, but set it to 100 and use Elapsed time instead. 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
メッセージ6/35
5,821件の閲覧回数

@johntrich1971 wrote:
 I would just send the Read command every 1 second in its own loop - it's just sent via a queue.

Whilst it's true that this is a better approach from the point of view of ensuring a read, I figured an extra loop would perhaps overcomplicate the situation.

 

OP, if you anticipate pressing lots of other buttons frequently, but don't want to press the read button, you will need to use the idea suggested by johntrich, and add a 3rd loop with timing that enqueues the Read command. 

 

I also wasn't a huge fan of the code duplication inherent in adding either another case or another loop...


GCentral
0 件の賞賛
メッセージ7/35
5,816件の閲覧回数

@cbutcher wrote:

@johntrich1971 wrote:
 I would just send the Read command every 1 second in its own loop - it's just sent via a queue.

Whilst it's true that this is a better approach from the point of view of ensuring a read, I figured an extra loop would perhaps overcomplicate the situation.

 

OP, if you anticipate pressing lots of other buttons frequently, but don't want to press the read button, you will need to use the idea suggested by johntrich, and add a 3rd loop with timing that enqueues the Read command. 

 

I also wasn't a huge fan of the code duplication inherent in adding either another case or another loop...


As I stated, it will probably work in this case although @Yameada's idea to use a shorter timeout with an elapsed time improves upon it (if the timeout is 1 sec then a button press just before the 1 sec is up will cause that iteration to be nearly 2 sec). I was just pointing out the pitfall with this approach that could cause trouble down the road (plus could cost points on the CLD-R exam https://forums.ni.com/t5/Certification/CLD-R-Question-6-paper-1/m-p/2590721) when more complex programs require more precise timing. I generally just use the timeout case for indicator updates or other things for which precise timing is not a requirement.

メッセージ8/35
5,809件の閲覧回数

First time I've seen a question for CLD-R, so that's interesting to know the sort of level/topic.

 

That aside, I guess it's dependent on the situation. Of course you're clearly right that timeout doesn't guarantee timing (or even occurrence, in principle), and Yamaeda gives a nice alternative to reduce the impact of other events whilst also avoiding too much added complexity (although probably that solution requires two separate cases rather than one case with two conditions).

 

I felt this was more or less for "indicator updates" but I may well have been wrong. Hopefully the OP can give some clarity 🙂 


GCentral
メッセージ9/35
5,797件の閲覧回数

The goal is to update the indicators without me physically clicking the "read" button. 

 

I've attempted to  implement a third event structure inside another while loop, but the program won't return a reading from the device.  I believe this has to do with how I added the new loop because I am not completely sure how to add this to the queue.  I tried to wire the conditional terminal of the new while loop to the conditional terminal of the other while loop, but I do not think this was the correct method. I've attached my VI below if you would please take a look.


Thank you for all your help!

0 件の賞賛
メッセージ10/35
5,770件の閲覧回数