04-12-2017 06:38 AM
Here you go. (This is a snippet - just drag this picture onto a block diagram).
When changing frequencies, it's important to keep track of PHASE, not time.
Each step computes a delta THETA (phase) and adds that to the total.
That means that each step starts where the last one left off.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
04-12-2017 06:41 AM
The "2 & pi" in the comments should be "2 * pi".
Blog for (mostly LabVIEW) programmers: Tips And Tricks
04-12-2017 06:50 AM
Just think in phase steps (and live with the small error due to phase accumulation)
04-12-2017 06:54 AM - edited 04-12-2017 06:56 AM
too late 😄
Edit: and the same math! 🙂
04-12-2017 06:54 AM
Tried out the build array but it didn't work out. It just ploted the arrays seperately in the graph.
If you wire two (or more) 1-D arrays into the BUILD ARRAY function, by default, it will create a 2-D array.
The graph will happily accept a 2-D array and plot 2 or more plots for you.
if you pop up on the BUILD ARRAY function and choose CONCATENATE INPUTS, then the function will do just that, making a longer 1-D array out of multiple 1-D arrays.
That's what happens in my example.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
04-12-2017 07:02 AM - edited 04-12-2017 07:04 AM
live with the small error due to phase accumulation
The only error I see would be roundoff error each time you figure deltaTheta.
When you store that into a DBL, you lose some precision at the 16th decimal place.
Although, since my scheme adds indefinitely, the phase accumulator will eventually reach a value where adding 3 radians will not be noticed.
That won't be a problem at 50000 samples, but if left to go indefinitely, will be a problem.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
04-12-2017 07:46 AM
Included a phase wrap ... and unless samplerate and max frequency meets Niquist...
If the user needs a longer hold time and uses a continous buffered generation to avoid a memory blast ... well, still room for improvement.
Hint: the Sine wave.vi allows tracking the phase...
04-12-2017 08:41 AM
So happy, you've been really helpful guys!
Tried it out with the equipment and everything seems to work, just have to check it out with my supervisor after the holliday. Happy easter!
Best regards,
Oscar