LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Case Structure / Timer

Solved!
Go to solution

Hi

 

I have attached a sample vi for controlling a serial device that takes inputs of 40 to turn on the device and 41 to turn off the device.

 

What I want to happen is when I press start I want a 40 to be sent to turn on the device and activate the time loop clock.

 

Then once the time has completed, I want the completion of the timer to send a 41 to turn off the device and stop both loops.

 

I think I need to add a case structure to the timing loop but not sure how to go about it.

 

Any suggestions would be great.

 

Thanks

0 Kudos
Message 1 of 23
(3,101 Views)

Hi,

 

I saw your VI to understand the operation. but still not understood it properly.

made few changes in your vi. jus check.

 

Its better to use some Architecture like state machine etc for this

 

Regards,

Bijay

0 Kudos
Message 2 of 23
(3,068 Views)

goldfronts1 wrote:

I have attached a sample vi for controlling a serial device that takes inputs of 40 to turn on the device and 41 to turn off the device. 

What I want to happen is when I press start I want a 40 to be sent to turn on the device and activate the time loop clock. 

Then once the time has completed, I want the completion of the timer to send a 41 to turn off the device and stop both loops.


You are also reading bytes from the serial port. How does that fit into the description above? Should that occur at regular intervals? Do you always need to send 40 before reading?

 

I see no reason for two loops, one is enough. Send the 40, loop using the "elapsed time" express VI , then send the 41. Eliminate all these fragile communications with local variables and value properties. None of these are needed. I have the feeling that you have 80% too much code.

 

Also try to use a terminal pattern with fewer terminals, this is maddening. What's up with all these hidden controls and indicators?

0 Kudos
Message 3 of 23
(3,060 Views)

Hi 

 

The device is a shutter that when the 40 is sent it opens it. It stays open for the specifiied time that the user inputs until that time has elasped. When that time has elasped I want a 41 sent to close the shutter.

 

Thanks

0 Kudos
Message 4 of 23
(3,046 Views)

Also I am a beginner with labview and I was just using the sample serial port vi supplied by labview to get started with the code.

 

I'm assuming that yes the 40 needs to be sent for as long as the time is not zero??

 

Any thoughts?

 

Thanks

0 Kudos
Message 5 of 23
(3,044 Views)

Hi 

 

Can you save this file as LV 9? as I can't open LV 10.

 

Thanks

0 Kudos
Message 6 of 23
(3,032 Views)

goldfronts1 wrote:

I'm assuming that yes the 40 needs to be sent for as long as the time is not zero??



Why are you assuming this? If this is true then you also neet to specify the rate of sending. I don't think this is true.

 

You still haven't told you whay you also read from the serial port and what you are doing with the result.

0 Kudos
Message 7 of 23
(3,026 Views)

So how this program should work is the following.

 

I am using a shutter that is controlled via a serial port.

 

I want the user to input a specified duration of time for the shutter to be open.

This requires that the computer send a signal of 40 to communicate with the device. The controller should then read the signal of 40 from the serial port which indicates is should open and the timer should start to elaspse at the same time the shutter opens.

 

Then once the timer has elapsed or the user hits exit, then system should send a 41 to the controller to close the shutter.

 

Sorry for the confusing explanation.

 

Thanks

0 Kudos
Message 8 of 23
(3,018 Views)

Hi Bijay

 

Thanks for the edited vi.

 

The one issue with this vi is that when I hit the start button the shutter opens (the system sends a 40 immediately), but the timer does not come on until I hit the start button again.

 

Also, once the elapsed time has finished, the system does not send a 41 to close the shutter.

 

Any thoughts, as this was my original problem, besides the code being messy Smiley Sad

 

Thanks

0 Kudos
Message 9 of 23
(3,015 Views)
Does anyone have any suggestions for my issue? Thanks
0 Kudos
Message 10 of 23
(2,981 Views)