From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Basic Programming Problem

Solved!
Go to solution

 Hi Guys, I need some help.

 

I want to increase and then decrease a number continuously.

 

for example: 0,1,2,3,4.....179,180, 179, 178,...3,2,1,0,1,2,3....179,180, etc..

 

Any ideas??

Regards!

Sam

0 Kudos
Message 1 of 8
(2,951 Views)
Solution
Accepted by topic author Oseguera

Please find attached TWO DIFFERENT solution in LV8.6.

 

Kudos are welcomed.:-)

Download All
Message 2 of 8
(2,946 Views)

Niice,

 

I think the complex is simpler. 

How can i send you a kudo?

 

0 Kudos
Message 3 of 8
(2,939 Views)

What is that little box with Boolean text within?

I approach my mouse with the helper activated and says anything.

 

Regards,

0 Kudos
Message 4 of 8
(2,936 Views)

It is called "local variable".Available by right clicking control or indicator.

 

It is used to read or write the value to control or indicatro any where in the VI, multiple times.

 

Its like pointer of C lang.

0 Kudos
Message 5 of 8
(2,932 Views)

Here's another way (LabVIEW 8.2).

 

(of course you don't really need a chart, so replace it with a plain numeric indicator)

 

Download All
0 Kudos
Message 6 of 8
(2,929 Views)

Your method will work but there is small issue to be notified.

 

Since you are creating an array of 0 to 180 & 180 to 0, you are unnecessarily allocating the memory for these additional 360 nos. Its very small memory but still not an optimized & efficient code. User wants only one output & not an array I believe, so why to have chart to allocate more memory???

 

Why to waste precious memory???

 

0 Kudos
Message 7 of 8
(2,911 Views)

 


@kekin wrote:

Why to waste precious memory???


 

Compared to anything else, the memory use here is insignificant. Even megabytes of data are no problem. The array is folded, meaning it is calculated at compile time and internally replaced with a diagram constant. Indexing a fixed size array is very efficient, meaning the code in the loop is significantly more efficient than hadling all these case structures and comparisons with every iteration.

 

The average computer has GBytes of RAM. The data structures here are a million times smaller. Insignificant!

 

If memory is really an issue, you can make it 4x smaller by changing the representation to U8 inside the FOR loop.

 

Just for fun, here's another solution that does not use arrays, case structures, or comparisons. 😄

 

 

Download All
Message 8 of 8
(2,906 Views)