LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

count up/down

Hi,
 
Attached is a code which I have written.
 
I would like to create a sweeping frequeny. 
 
The flow is as,
1) Accept input
2) Count up till it reach the upper limit
3) Count down till it reach the llower imit
4) Count up to the middle of the two limits.
 
I have create 3 while loops to excute the above algorithm. I wrote it based on my knowledge of C Lanuage. May I know is there anyway which I can optimize my code? 
 
Thanks
Jieyi
0 Kudos
Message 1 of 5
(3,362 Views)
I would suggest looking at using the "Ramp Pattern" function to generate your sweep values. That would eliminate the need for loops.

There also does not seem to be a "starting point". You're using a local variable of "End Phase" as an apparent starting point, and I don't know what that's about.
0 Kudos
Message 2 of 5
(3,346 Views)
"End Phase" phase is a variable from the output of my signal gen.
 
My Purpose is to write a function which can generate a sweeping sine wave.  Any clues on how can I start.

Message Edited by Jieyi on 09-19-2007 01:42 AM

Jieyi
0 Kudos
Message 3 of 5
(3,311 Views)
Hi Jieyi,

some comments on your programming as it seems you're coming from text based programming Smiley Wink
- You are mixing local variables and "value" property nodes. This is no good programming style and even hurts performance! Stick to locals if possible and avoid property nodes (at least "value" ones).
- You are reading and writing to the same "variable" in one iteration of the loop (like "End phase" in upper loop and "start phase" in middle loop). In this case you should use a shift register instead of accessing locals/property nodes two times!
- You are reading the stop condition (upper/lower limit/center phase) in each iteration. When these values don't change you can read them outside the loop and just use a wire to the comparison function. Here you also don't need a local variable as the wire does the dataflow!

You should really look at examples coming with LabView. And you should get familiar with dataflow concept of LabView!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 5
(3,304 Views)
Have you taken a look at the signal generation functions that come with LabVIEW. There's quite a lot of them, and I suspect one of them will do the trick.
0 Kudos
Message 5 of 5
(3,265 Views)