07-25-2018 12:31 PM
Hi! LabVIEW Beginner here.
I was wondering if there was a way to create a square wave with a randomized duty cycle within a range, such that it completes an entire cycle before changing its duty cycle to another random percentage in the range. It must also move across the waveform chart or graph slow enough so that the user could follow the square wave with a joystick. My current attempt moves at around the speed I want but the wave changes very abruptly and always stays up for a while before it starts changing abruptly and then down for a while.
07-25-2018 01:39 PM
Your issue is that the square wave generator is generating the square wave piecemeal. You want to generate one cycle at a time. With a frequency of 0.075 Hz, and the default Sampling Info (1000 pts at 1000 Hz) you're not generating a full period. Change either your sampling info or your frequency to match (to generate a full period of data), and set the Reset? input to True so you get a fresh start each time.
07-26-2018 08:23 AM
@DotsonLCCF wrote:
Hi! LabVIEW Beginner here.
Hello, LabVIEW Beginner. You are making a common mistake of not first thinking about what you want to do, and instead jump into LabVIEW to start coding how you are going to do it. So let's ask what do you want to do? What do you mean by a "square wave with a randomized duty cycle"? I can think of several things this might mean:
As you initially phrased it, the first method sounds most like what you said, but might not be what you really want. But in any case, what do you end up with? A series of times, and a rule for what to do when the time runs out (namely "flip" the flip-flop).
Now, think LabVIEW. I see three basic things happening here -- something happens repetetively, time is involved, and there is the concept of a flip-flop, something that has two values and changes from one to the other.
Putting these things together (with some "rules" to handle the "variability" questions raised above) should lead you to a simple solution.
Bob Schor