02-25-2014 01:18 PM
So we were asked to reproduce the function generator and oscilloscope as a virtual instrument for our final exam. But I'd like to focus on the function generator. The audio generator GW Instek GAG-809/810 has only a single button for the waveform wherein the user would just press it repeatedly to show the desired waveform (i.e., sine wave, square wave). Yeap, the audio generator only have the two waveform but our professor wanted us to add the generator's feature, that is, for the users to be able to display the wave into sawtooth and triangle wave.
So how do we construct it, that different wave forms would display everytime we press the button?
02-25-2014 01:25 PM
Hi geneclaude,
you could start using an Enum control when it comes just for the functionality.
Otherwise you may use a boolean button, check for rising edges (or use value change events) to count up an additional enum holding the waveform mode…
02-25-2014 02:32 PM
You need to use the Boolean as a toggle that will step to a different waveform each time it's pressed.
Something like this:
Of course, this is an example that needs a lot of work.
02-25-2014 03:01 PM
Nice Kelly
Don't forget to type def that enum!
02-25-2014 03:08 PM - edited 02-25-2014 03:08 PM
Don't forget to type def that enum!
Yeah, I meant it when I said it needs work. The enum needs to be a type def and this really should feed a producer/consumer or something like that. I just threw that togeather to give the OP a starting point.
02-25-2014 03:11 PM
i was thinking.....
02-25-2014 03:17 PM
That works, too, except there are four waveform types not three (Sine, Square, Triangle, Sawtooh) so the constant should be a 3 instead of a 2. The concept is very good.
02-25-2014 03:21 PM - edited 02-25-2014 03:23 PM
@kbbersch wrote:
That works, too, except there are four waveform types not three (Sine, Square, Triangle, Sawtooh) so the constant should be a 3 instead of a 2. The concept is very good.
you got the jist of it....
actually, 4 waveforms (0,1,2,3)...constant should be 4
02-25-2014 03:48 PM
@apok wrote:
@kbbersch wrote:
That works, too, except there are four waveform types not three (Sine, Square, Triangle, Sawtooh) so the constant should be a 3 instead of a 2. The concept is very good.
you got the jist of it....
actually, 4 waveforms (0,1,2,3)...constant should be 4
Guys... Ahem ... Constant? P-Node Num.Elements
Go to it !
02-25-2014 03:56 PM
apok wrote:
actually, 4 waveforms (0,1,2,3)...constant should be 4
Constant should be the highest number we expect to see, which is 3 or number of elements -1, since the first element is value 0.