NIDAQ waveform

beshoy.agayby's Avatar

beshoy.agayby

19 Sep, 2018 08:31 PM

Hello Chris,
I am not clear on the use of NIDAQ analog output waveform; do you have an example for a sinusoidal generation?

Cheers,
Beshoy

  1. 1 Posted by beshoy.agayby on 19 Sep, 2018 08:44 PM

    beshoy.agayby's Avatar

    would something like this work? iochannel tag="A_out" type="nidaq_analog_output_voltage_waveform" voltage="v_out" range_max="5" range_min="0" channel_number="0" waveform="sinusoid" period="500ms" offset="0"/

    Cheers,
    Beshoy

  2. 2 Posted by beshoy.agayby on 20 Sep, 2018 11:10 AM

    beshoy.agayby's Avatar

    Hi Chris,

    I tried it and it works but i have a couple of issues:
    -can i turn the wave from on and off without turning the NIDAQ on and off? -the default value of the output is always midway between min and max voltages when the output isn't on; is this normal? -can i change the frequency on the fly or do i have to load and unload the experiment? For now, changing the period variable during the experiment doesn't have an effect.

    Cheers,
    Beshoy

  3. Support Staff 3 Posted by Christopher Sta... on 20 Sep, 2018 02:14 PM

    Christopher Stawarz's Avatar

    Hi Beshoy,

    can i turn the wave from on and off without turning the NIDAQ on and off?

    No, that isn't supported at present.

    the default value of the output is always midway between min and max voltages when the output isn't on; is this normal?

    You mean before the NIDAQ device has been started (or after it's been stopped)? I don't think there's any way to control (via software) the state of the outputs when the device isn't running. Whatever happens is probably hardware dependent.

    can i change the frequency on the fly or do i have to load and unload the experiment?

    You have to reload the experiment. I don't think it's possible (in terms of hardware and/or driver support) to alter the waveform while the device is running. We could change MWorks' interface so that you can alter parameters while the device is stopped, but that isn't supported currently.

    Cheers,
    Chris

  4. 4 Posted by beshoy.agayby on 21 Sep, 2018 11:11 AM

    beshoy.agayby's Avatar

    Hi Chris,
    Thanks for the reply. If it's possible to enable turning the channel on and off and/or change the frequency when the device is off, that would be great and eliminate the need for using external function generators. I don't need the frequency to be changed while it's running, just between protocols for example.
    What I did so far is having different device configurations with one having analog waveform and the other having the regular constant output. Then, I turn on the device with the waveform configuration when I need it.
    Cheers,
    Beshoy

  5. Support Staff 5 Posted by Christopher Sta... on 21 Sep, 2018 05:28 PM

    Christopher Stawarz's Avatar

    Hi Beshoy,

    If it's possible to enable turning the channel on and off and/or change the frequency when the device is off, that would be great and eliminate the need for using external function generators.

    OK, I'll add those to my to-do list.

    What I did so far is having different device configurations with one having analog waveform and the other having the regular constant output. Then, I turn on the device with the waveform configuration when I need it.

    So your experiment has two different NIDAQ devices in it, both of which use the same piece of hardware? If so, I'm very surprised that works.

    Chris

  6. 6 Posted by beshoy.agayby on 24 Sep, 2018 11:12 AM

    beshoy.agayby's Avatar

    Hello Chris,

    I was suspicious at first as well, but it worked. One of the problems with this solution is that timing is a pain to adjust as turning the device on and off takes time. Also, when turning the device off, there is a bit of time where the signal is continuous and not oscillating.

    However, one of the things i appreciate about using the NIDAQ with Mworks is that the phase of the produced sinusoidal is very consistent; so every time the device is turned on, the produced signal is at the same phase.

    Any ETA on those features? I am just trying to see if I can wait for your updates instead of purchasing a new function generator.

    Cheers,
    Beshoy

  7. Support Staff 7 Posted by Christopher Sta... on 25 Sep, 2018 06:20 PM

    Christopher Stawarz's Avatar

    Hi Beshoy,

    Any ETA on those features? I am just trying to see if I can wait for your updates instead of purchasing a new function generator.

    It shouldn't be a big job, but I'm a bit swamped at the moment. Realistically, I can probably get the changes in to the nightly build within 1-2 months. If you don't want to use the nightly build, you'll have to wait for the next official MWorks release (tentatively coming in spring of 2019).

    Chris

  8. 8 Posted by beshoy.agayby on 26 Sep, 2018 10:43 AM

    beshoy.agayby's Avatar

    Hi Chris,

    That's alright, that sounds reasonable. I can then test it out with the nightly build.

    Cheers,
    Beshoy

  9. Christopher Stawarz closed this discussion on 01 Oct, 2018 02:35 PM.

  10. Support Staff 9 Posted by Christopher Sta... on 21 Dec, 2018 07:12 PM

    Christopher Stawarz's Avatar

    Hi Beshoy,

    As of the current MWorks nightly build:

    • NIDAQ analog output can be stopped and restarted (independently of other input/output tasks) via the new analog_output_enabled parameter.

      Note that the NI drivers available for macOS don't allow individual analog output channels to be stopped and started independently. Therefore, analog_output_enabled will start or stop all analog outputs.

    • The waveform parameters of a NIDAQ analog output waveform channel can be modified while the experiment is running. Changes take effect after analog output is stopped and restarted (either by stopping and starting the entire device, or by stopping and starting just analog output using analog_output_enabled).

      To make this work sensibly, I added two new parameters (amplitude and mean) to waveform channels. If you omit these, they will be derived from range_min/range_max as before. However, range_min/range_max cannot be changed after the experiment is loaded, so if you want to change amplitude and/or mean at run time, you'll need to use the new parameters.

    I've attached a small example experiment that demonstrates how to change a waveform on the fly.

    Unfortunately, I still haven't found a reliable way to zero out waveform channels when the device is stopped. The NI API doesn't appear to provide any support for this. I tried a "brute force" approach, wherein I stopped analog output, set all output samples to zero, restarted output, and restopped. This works, but it was causing issues in some of my tests, so I'm not sure it's really a good idea. Of course, you can do the same thing in your experiments (by stopping, setting amplitude and mean to zero, restarting, and restopping), which might be a viable solution in some cases.

    Cheers,
    Chris

  11. 10 Posted by beshoy.agayby on 09 Jan, 2019 10:29 PM

    beshoy.agayby's Avatar

    Hi Chris,

    Sorry didn’t reply earlier. I managed to give the script a quick test around the Christmas break here and it works; thanks a lot. I tried to play around with how to reset it; I think one way is to set the mean/amplitude to zero does it (after disabling the channel and enabling with the new values). However, I haven’t tested it extensively yet. Having all the analogue outputs turn on at the same time isn’t an issue right now as we would only use one.

    Cheers,
    Beshoy

  12. Christopher Stawarz closed this discussion on 15 Jan, 2019 02:47 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

07 Feb, 2019 02:24 PM
02 Feb, 2019 01:58 PM
01 Feb, 2019 06:25 PM
26 Jan, 2019 12:15 AM
18 Jan, 2019 05:44 PM