07-10-2020 12:47 AM - edited 07-10-2020 12:48 AM
It is just simple math!
Let's say you have a lookup table for a 1 Hz +/- 1V sinewave. Let's say you built that using 100 samples.
You have a time that goes from 0-10 seconds. If you want to output a 1Hz 1V sinewave, you take your x value and look it up. (your x value is your time)
If you want to output a 2Hz 1V sinewave. You take you x value, multiply it by 2. Look that up. (When your x value gets larger than 100, then you use quotient/remainder and use the remainder, because you've wrapped around into the next cycle of the sinewave.)
If you want to output a 3Hz 10V sinewave. Multiply x by 3. Whatever result you get from the table, multiply by 10.
If you need a signal with a phase angle of 90 degrees, then 90/360 * 100. That value you add to your x before multiplying by the frequency and looking it up.
One lookup table for "standard" sinewave. The rest is simple math to apply that to the frequency, amplitude, and phase angle you desired, however many various signals you desire.
07-29-2020 05:11 PM - edited 07-29-2020 05:11 PM
I am not following how to create simultaneous signals that all do different things. I can easily have 10 different sine wave generator vi functions on my back panel, just takes up a lot of room. If I use just 1 then I can have 10 different amplitudes of that signal but they all will have the same frequency and phase unless I make another generator and feed it a different phase/frequency. Is this making sense of where I am not understanding? Gerd claimed I can do this all with one, I'm not seeing how I can use fpga math functions to change phase and frequency from the output of the generator VI. Like I said I can easily do this on a separate generator. I'll link a picture so it makes more sense of what I'm doing.
This is just a small portion of the code. There are 6 other generators.
07-29-2020 07:29 PM
I'm not familiar with that Express VI. Since it seems to be only outputting a single value, it sure doesn't look like it has a look-up table.
It would have helped if somewhere along this thread you attached an actual VI of your code.
As I said earlier, just use a single sine wave generator that creates a "standard" sinewave Amplitude of 1, frequency of 1 Hz. Make your look-up table (you did say you had a look up table in your subject line). Once you are ready to look up a value based on where you are in the phase, and also the actually frequency, you can multiply the result by the amplitude.
@MGardner5 wrote:
I'll link a picture so it makes more sense of what I'm doing.
Attach a VI!
07-30-2020 03:38 PM
The rest of the code is not relevant and I crammed a ton into one vi so it wouldn't really be helpful anyways. https://zone.ni.com/reference/en-XX/help/371599P-01/lvfpga/sine_generator/ This is the one I am using. The generator vi takes care of the look up table, all I do is select which one to use. I did not create the generator vi, its an fpga resource I am making use of.
07-30-2020 04:31 PM
But you have to admit that SOME code is relevant.
So thank you for pointing out where you started so we can find that express VI.
I think you have stumbled across a common problem with Express VI's. They give you a nice quick start, but as soon as you want to do more with them, they get in the way.
In this case you are multiplying the number of these Express VI's you want to use. They have combined the functionality of a lookup table with the point by point nature, and there is no way to untangle the two.
I right clicked on one and picked Open Front Panel, which converts the Express VI to the underlying code. I see the lookup table embedded as an array constant. And uninitialized shift registers which allow the VI to output the sine wave point by point when it remembers its last state.
I think you are going to have to ditch the Express VI. Dig into it to see how it works. Then you can try to replicate that code so that all instances can be based off a single array constant for your lookup table.
TLDR;
Get rid of the Express VI's. Create your own look up table for a standard sine wave. Perform ordinary math calculations to look up the correct index of the lookup table for each instance you want to generate a sinewave.
07-30-2020 04:41 PM - edited 07-30-2020 05:09 PM
Ah that is making more sense now. I am such a beginner I never thought to try to load the code up. I did not even know I could open its VI. So what you're saying is I can copy and paste its code into my VI and then wire it to share the lookup table? Might get messy; I for sure am no master especially since what I am using it for is like a side project. Might take a lot of my time to learn and figure out how the details work, thoughts?
07-30-2020 07:08 PM
Weird part about that express VI was that once I converted it, it didn't seem to let me do any editing with it. So I don't know if you can do a SaveAs to make a new copy.
But you can certainly inspect it to see how it works. Create your own code that behaves similarly. It is worth doing for the learning experience.