LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

[newbie] positive edge triggered action and subvi's

Hi,

I'm completly new to labview or graphical programming and i have some problems with a simple excercise that I made up for myself.
What i want is a trafficlight system :

When my vi detects a positive edge in the master in signal it should start with the following sequence :

turn red light off
turn orange light off
turn master out off
turn green light on
wait delay 1
turn green light off
turn orange light on
wait delay 2
turn orange light off
turn red light on
wait delay 3
turn master out signal on

Even if master in is turned off before this sequence is done, it should still continue until red light and master out are on.

I have a few questions :

1. Does - what i have done so far - make sence? I started reading the "getting started..." but got bored and figured this out by myself (except for the timer that i ripped from this board)
2. How can i implement this positive edge triggered thing i want?
3. How can i create a sub vi from my traffic light so that i can connect 2 of them together?

Thanks!

0 Kudos
Message 1 of 6
(4,381 Views)
A state machine architecture is well suited to your application Look at the attached for some ideas. The Rising edge detector is implemented with a shift register plus logical NOT and AND. See the Idle state.

Lynn
Message 2 of 6
(4,376 Views)
Thank you very much for your reply.
That shift register solved my trigger problem. I also like the idea of implementing this excercise as a state machine. It is much more flexible than my approach.

Anyway, i would like to use my modified approach to ask another question...
I implemented the edge detection and now it works but when i start my program the lights stay off until an edge is detected.
Is it possible to tell the false state in my program to turn the red light and the master out on?
I can't place the lights outside the case structure because it would break the whole program, but a copy of the block representing my red light and master out would solve my problem. Is this possible?

I hope you understand what i'm trying to ask here. Mind you, my labview experience can still be counted in hours on one hand...

In a conventional programming language i would write :

if <condition true>
    start sequence with green light, orange light, red light, master on
else if <condition false>
    red light on
    master out on
end if


0 Kudos
Message 3 of 6
(4,366 Views)
Hi,

I successfully created a subvi from the "event" solution.
To make this work, i had to remove the while loop. But to get feedback from the last event, i need the shift registers that only work with this while loop.
So I had to create 2 more connections : "state in" and "state out".
Is there another way of doing this? I would like to do the same thing with the time, but that would mean again 2 more connections...
Download All
0 Kudos
Message 4 of 6
(4,351 Views)
Yes, you will need more connections. To avoid making the connector pane too crowded, you can cluster some of the inputs or outputs. For example a cluster with all the delays and a cluster with the lights and master out might be reasonable approaches.

Lynn
Download All
Message 5 of 6
(4,339 Views)

Attached is one way to do it, using local variables.  To create a local variable, right click on a terminal in the block diagram and select create -> local variable.  You can now use this anywhere in the VI to set or read the value of the object.  To read, right click the local variable and select "change to read."

Also, since you just want the values of those 2 LEDs to be true when the vi runs, you could simply make their default case True.  To do this, set them to true, right click them and select data operations -> make current value default.  Now, when you load the VI, they will be on.

Hope this gives you some ideas, and good luck learning LabView.

Message 6 of 6
(4,333 Views)