LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timing after event without locking out the user

Solved!
Go to solution

I believe you've done it!

0 Kudos
Message 11 of 20
(872 Views)

You learn quickly.  Much better vi than the first one.  In your original you had calulations for Ramp Threshold and Constant Threshold.  They don't appear in your new vi.  If you want these, you can put the code inside the Timeout event, and the calculations will take place every 50mS.  Just wire the inputs from the event case edge.

 

One more thing, you have several events that send a time to the shift register, Start Custom Ramp, Start Inc, and the Qramps 1-3.  Will these not interfere with each other?  Will one event run until its end before another will run?  Or is the timer just relative to the last event that set the starting value?

 

Another point I just saw.  On the right edge of the event structure, the blue terminal for Time, you can see a white dot in the middle of the blue box.  This means to use the default value if unwired.  In the Set Values event, there is nothing wired to this terminal.  What will happen is that the default value for a numeric, which is 0, will be sent to the shift register.  This may or may not be desirable.  Normally it is best to right click on the terminal and uncheck "Use Default if Unwired".  Then the blue box will turn white, meaning that some cases do not have wires to this terminal, and the VI run arrow is broken.  Find all cases that do not have a wire to this terminal, and add a wire from the left side blue terminal to the right side.  Once all cases are wired, the run arrow will return to white, no errors.  This ensures that a known value is sent to the shift register instead of a default value in some cases.  Like I said before, this may be desirable or not.  It depends upon your application.

 

Same for the error wire.  The Timeout case does not have an error wire.  What happens is that the default for error, which is no error, is sent to the shift register every time the Timeout event occurs.  If one case causes an error, then 50mS later the Timeout case happens, and the no error condition is sent to the shift register, you have just lost a real error.  Change the terminal to not use the default, and add a wire in the Timeout case from the error terminal on the left to the right.  This way, any error gets propogated through with each loop iteration.  Also, your first function before the loop has its error out wire going to a terminal.  It should go to the shift register for the error wire.  Move the error wire to the shift register.  It is also considered good practice to use shift register for the purple wires for the Sorensen session.  This is mostly useful when using a For Loop, in case the loop iterates zero times.  Without a shift register, the purple output will be default, and will cause an error when trying to close the session.  With the shift register, whatever is passed in on the left will go out on the right, thereby avoiding an error when closing the session.

 

This is a lot of stuff for a beginner to learn.  But you are doing well so far.  Are there any other problems with your code?

 

- tbob

Inventor of the WORM Global
Message 12 of 20
(861 Views)

All of the ramp buttons are meant to be used not simulatenously with each other. The ramp gradually raises the current up to the final current. The quick ramps (qramp) were added because a user said they would be more convenient. So, I do want each of them to pass on their start time which should not interfere, but if they do interfere, then the last executed ramp will take over and the timer will be accurate anyway I believe.

 

I have left the white dot for the time variable that tunnels out of the event structure, because all of the instances that it was unwired were instances where we were not interested in how long the process was taking, we just care how the ramps are progressing. Losing an error message after 50ms, however, was not desirable! I have wired all cases so that the error propagates and does not get lost due to the timeout case!

 

I believe I have incorporated the shift register for the VISA reference correctly.

 

One thing I added to my code (freshly attached) was a query in the timeout case where I ask for the protection condition. It is supposed to return an 8-bit number, and I am only concerned with the 6th bit, telling us if an external trigger (like no water flow, or a temperature sensor) has shut off the power supply. Unfortunately the string indicator gives me a decimal number, like 32. I know, 32 is easy to see that only the 6th bit is 1, but I really want the program to see if the 6th bit is true or false, and display appropriate text if it is true. I want to test for the 6th bit preferably by changing it to a binary number or array or something (which I will look into) and not by doing a lot of comparisons with the decimal number (Like is it at least 32? Is it less than 64? Is it at least 96? etc.) If you know how to examine just one bit when a decimal number is returned, that would be great!

 

Thanks for all the help, I feel like I've gotten such a better grasp on these event structures!

0 Kudos
Message 13 of 20
(855 Views)

Just use a boolean AND gate on your decimal number (as long as it is an integer datatype).  Most of the boolean functions are polymorphic and handle integers fine.  Try it!

 

Lynn

0 Kudos
Message 14 of 20
(846 Views)

Like this:

 

20043iDC07AC642CFB3E9B

- tbob

Inventor of the WORM Global
0 Kudos
Message 15 of 20
(842 Views)

So do I just AND my decimal number with 00100000? That doesn't seem right because I don't only want the case when it is exactly 32... So, can you explain exactly what I AND it with?

0 Kudos
Message 16 of 20
(838 Views)

@gjacob wrote:

So do I just AND my decimal number with 00100000? That doesn't seem right because I don't only want the case when it is exactly 32... So, can you explain exactly what I AND it with?


 

Look at my code.  It works fine.  You select which bit you want to check (bits start with 0).  Numerical 32 is bit number 5.  So enter a 5 into Bit and run it.  If the indicator lights up, the bit is set.  The string can be 33 or 34 or anything that has the 5th bit set and it will report that bit being set.

 

If you AND your string (converted to decimal) with 00100000, if the 5th bit is set, the result will be non zero.  If the bit is not set, the result will be zero.  Other bits don't matter at all.  Try it.

- tbob

Inventor of the WORM Global
0 Kudos
Message 17 of 20
(831 Views)

Yes I believe you've done it again, thank you! It reports correctly when the device has been externally shut off.

 

I was about to make a case structure that wires a true constant when the bit set? output is 1 and wires a false constant when the bit set? output is0, but then I realized there is an easier way 🙂 Man, I just looked at that Rube Goldberg thread yesterday too!

 

Thanks again for both of your helps!

(But especially tbob's)

0 Kudos
Message 18 of 20
(826 Views)

@gjacob wrote:

 

I was about to make a case structure that wires a true constant when the bit set? output is 1 and wires a false constant when the bit set? output is0, but then I realized there is an easier way 🙂 Man, I just looked at that Rube Goldberg thread yesterday too!

 

Thanks again for both of your helps!

(But especially tbob's)


You mean like this:  It has been done before.

 

20045i9E9AC850DC7621B6

- tbob

Inventor of the WORM Global
0 Kudos
Message 19 of 20
(820 Views)

Haha, yes exactly.

0 Kudos
Message 20 of 20
(815 Views)