07-28-2020 04:49 AM
I have a sine wave coming from a 'signal simulate' this will eventually go to an amplifier which will control a shaker. I need to the amplitude of the signal to be gradually or stepped increased when the rig is turned on and gradually decreases when the rig is stopped. How is this achieved ?
Thanks, James
07-28-2020 04:53 AM
Hi James,
@Jamesbdowty wrote:
I have a sine wave coming from a 'signal simulate' this will eventually go to an amplifier which will control a shaker. I need to the amplitude of the signal to be gradually or stepped increased when the rig is turned on and gradually decreases when the rig is stopped. How is this achieved ?
When your "rig is turned on" then you ramp up the amplitude of the sine wave.
And when the "rig is stopped" then you need to ramp down the amplitude.
What is the problem?
What have you tried?
Where did you fail?
07-28-2020 07:11 AM
Hi GerdW,
The amplitude will be established before, it a requirement that this is all automated,
Thanks, James
07-28-2020 07:19 AM
Hi James,
@Jamesbdowty wrote:
The amplitude will be established before, it a requirement that this is all automated,
I never meant you need to change the amplitude manually…
What have you tried?
Where are you stuck?
07-28-2020 08:15 AM
I dont really know where to start to be honest,
Any tips would be useful
07-28-2020 08:50 AM
07-28-2020 09:22 AM
A few breadcrumbs, I won't be able to walk you through all the details start to finish:
1. I assume you'll generate this signal with a Continuous Sampling AO task. Look at the shipping example for "non-regeneration" which keeps writing new data to a task in a loop. You'll be doing something similar.
2. To make life easier, I'd write the same # of samples every time *and* I'd make that size hold an integer # of sine wave cycles. Then you can probably just calculate the data once and keep writing another copy of it to the task over and over.
3. In addition to this re-usable chunk of data, I'd make 3 other special chunks of the same size. One will ramp you up to full amplitude, one will ramp you back down to 0, one will be a constant bunch of 0's because you won't be able to perfectly time your software stoppage with the exact end of the hardware ramp-down.
You'll write the ramp-up chunk first, keep re-writing the normal chunk in a loop, then write the ramp-down, and finally write the chunk of 0's enough times to be sure you gave the shaker a soft landing.
The snippet below shows how to take a normal sine wave chunk and make the other special chunks.
-Kevin P
07-28-2020 12:00 PM
@Kevin_Price wrote:
you won't be able to perfectly time your software stoppage with the exact end of the hardware ramp-down.
You'll write the ramp-up chunk first, keep re-writing the normal chunk in a loop, then write the ramp-down, and finally write the chunk of 0's enough times to be sure you gave the shaker a soft landing.
You can also just write your "ramp down" value once, then wait until you get a buffer underflow error, then stop your task. IIRC there are two possible errors that will be generated in this case but I don't have the specific error numbers in front of me.
07-28-2020 12:37 PM
@BertMcMahan wrote:
You can also just write your "ramp down" value once, then wait until you get a buffer underflow error, then stop your task.
That's a good idea and will be a simpler way to be sure you end at 0. You'll probably need to explicitly disallow regeneration (prior to starting the task) with a DAQmx Write property node as seen in the shipping example.
Many many years ago non-regenerating output tasks used to be pretty tricky to deal with, but DAQmx has gotten much better and handles things rather well these days. You can see in the example that all you've got to do is call DAQmx Write in a loop and the driver manages all the details about timing and buffer locations.
-Kevin P