10-25-2019 03:41 PM
I have a colleague who started using LabVIEW several years before I, but had no experience with Program Design and tended to make VIs not unlike yours, with lots of Controls and Indicators with obscure names, lots of Local Variables, lots of wires running everywhere, and little (or no) documentation! Fortunately, all this was before NI created Express VIs, so that was one curse we didn't have to face.
I would look at his code and say "What are you trying to do?" He would start explaining about this control, that wire, and I'd stop him and say "No, I don't what to know how you are doing it, I want to know what you are doing".
LabVIEW is an "Engineering Workbench" (the "E" "W" of LabVIEW). Think like an Engineer. You have a Traffic Light. That's a "thing". It has three Lamps (or two -- I didn't understand that second one ...), "Red", "Yellow", "Green" (I'm guessing you are in Europe -- I think in the US, Green is on top ...). I'd create a Cluster that has three LED Controls, colored Green, Yellow, and Red (and given those names as Cluster Elements). I would also make a TypeDef for that Cluster (a Very Good LabVIEW Practice -- always create a TypeDef for any Cluster you define, it makes using them much simpler).
Do you know about While Loops and Shift Registers, namely that the Shift Registers can act like "memory elements" and hold values from one loop to the next?
Do you know about State Machines, a Design Pattern where you have a number of variables (such as Traffic Lights) that can have various "States" (i.e. Yellow lit, Red and Green off), and "Rules" to go from one State to Another ("If Red Lit, wait 3 seconds then do Turn On Green").
[I'm clearly Leaving Out Details, but there are LabVIEW Examples, Templates, and other help "built-in" to LabVIEW 2019, that may prove useful to you].
I've attached a tiny example for you look at.
10-25-2019 03:51 PM
@Bob_Schor wrote:
"Red", "Yellow", "Green" (I'm guessing you are in Europe -- I think in the US, Green is on top ...). I'd create a Cluster that has three LED Controls, colored Green, Yellow, and Red (and given those names as Cluster Elements).
Do you know about State Machines, a Design Pattern where you have a number of variables (such as Traffic Lights) that can have various "States" (i.e. Yellow lit, Red and Green off), and "Rules" to go from one State to Another ("If Red Lit, wait 3 seconds then do Turn On Green").
Bob,
I suggest you take a closer look at those traffiic lights on your drive home tonight!
10-25-2019 03:55 PM
@RavensFan wrote:I suggest you take a closer look at those traffiic lights on your drive home tonight!
I was thinking the same thing. He says he never understood the second light so apparently he ignores it altogether.
10-25-2019 04:18 PM
@aputman wrote:
@RavensFan wrote:I suggest you take a closer look at those traffiic lights on your drive home tonight!
I was thinking the same thing. He says he never understood the second light so apparently he ignores it altogether.
Makes me think of Willy Loman, from the play below
HAPPY: I’ve driven with him. He sees all right. He just doesn’t keep his mind on it. I drove into the city with him last week. He stops at a green light and then it turns red and he goes.
mcduff
10-25-2019 08:38 PM
@aputman wrote:
@RavensFan wrote:I suggest you take a closer look at those traffiic lights on your drive home tonight!
I was thinking the same thing. He says he never understood the second light so apparently he ignores it altogether.
Just to clarify Bob's comment, the second light he was referring to was the one in the VI where there was only a red light and green light. It was missing yellow.
10-26-2019 10:37 AM
I'm confused (ha, ha, you are all saying ...). I just loaded the three routines (on my computer, which should be identical to the ones I uploaded, Famous Last Words). When I hit the Run button on the Demo, I got 10" of Red, followed by 20" of Green, followed by 5" of Yellow, followed by 10" of Red, followed by ... [and stopping a light or two after I pushed Stop).
Ohhh, are you saying that Red is on top? Just a sec, let me go downstairs (I'm in a hotel right now) and look ... OOPS!!
OK, time for a Teaching Moment (for the OP -- don't post the answers here, please). What is the "minimal change" to wipe the Egg of Bob's Face?
Bob "Oops" Schor