LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a running light using different states

Hello everybody, I'm new to LABVIEW and I'm wondering if I'd be able to get some help for a little exercise using this software: 

So, what I want to do is to create a SubVI where a 'running light' either runs from left to right or from right to left using different states. I would use 4 states:

- initialize

- running right

- running left

- stop

lablamp.jpg

And 3 buttons:

- Start

- Switch

- Stop

I'm wondering if anyone would be able to give me a help or some tips/ideas about how to get started with this because I'm a complete labview-newbie and I have no clue where to start... 😕
Thanks in advance! 

0 Kudos
Message 1 of 5
(2,286 Views)

Right down in words on a piece of paper the logic you would use.  It could be a flowchart or pseudo code.

 

Look up shift registers.  Your code will be a combination of shift registers in a loop and a case structure.

 

 

0 Kudos
Message 2 of 5
(2,272 Views)

LabVIEW has a data type you don't see in too many "conventional" programming languages -- Time.  Think about incorporating Time in your program.

 

I'm assuming that you are using an Array of Booleans for your lights.  Have you looked at the Boolean Functions in LabVIEW?  Have you looked at the Array functions?

 

LabVIEW is also unusual (for a language) in that data often don't "live" in variables -- they live in "wires".  The exceptions are Controls (where data "comes in" to a VI, sometimes by a User entering a number or pushing a button) and Indicators (where data "goes out" from a VI, sometimes to be viewed by a User as a display).  Wires, in turn, have interesting relationships with LabVIEW Structures (Loops, Case, Event, etc.).  You should be familiar with this (the introductory Tutorials on first page of this Forum, or your first LabVIEW class, should explain some of this).

 

Give it a try.  If you get stuck, first ask your fellow students (learning together is much more fun than learning "in solitary").  If you are still stuck, return here, and attach your LabVIEW code (you can post a picture of the code, but be sure to attach the actual VIs).

 

Bob Schor

 

Bob Schor

 

Message 3 of 5
(2,255 Views)

To write code that moves between different states, consider a State Machine.

 

As RavensFan said, use a Shift Register to store the current state of your display, and then use things like property nodes for the array indicator to determine the number of visible elements so you can appropriately size your array.

 

You can use Replace Array Subset to update a single value in the case that you're adding/removing a single true element (removing is the same as adding a false) (by adding I mean changing - the array length should be fixed). When you reach a full/empty array, you'll need to reset to the other in order to continue.

 

The Quotient and Remainder function may be useful to you for this application, but consider keeping a separate "position" value in a Shift Register rather than using the iteration terminal (i) to aid debugging and simplify possible changes/transitions in direction etc.


GCentral
0 Kudos
Message 4 of 5
(2,253 Views)

One skill is forum (or google) search. You might have found this thread with examples of various qualities, so make sure to read the comments. 😄

Message 5 of 5
(2,213 Views)