Welcome! Log In Create A New Profile

Advanced

Controlling hardware with digital NI board IO

Posted by tperret 
Controlling hardware with digital NI board IO
April 29, 2021 08:40AM
Dear all & Jaewon,

I'm looking for a way to interact directly with digital IO of NI boards in order to control an hardware board using interrupts.

I'm using a setup with 8 DIO from the NI board wired to the hardware. One pin is used for interrupts and 7 for addressing.
For that I need to set the 7 addressing bits to the desired state **then** send the interrupt trigger.

From what I understand from the source code of the TTLOutput and TaskObject classes I need some understanding of the register method of the digitalio class and whether this needs to be controlled by mglactivegraphic.
Could you give me some infromations about these functions?

I'm not sure yet if I want to implement that as an adapter (that will easily be used in ML) or as a TaskObject (that will need some deep ML code tweaking).

Thanks for your time,

Regards,
Thomas
Re: Controlling hardware with digital NI board IO
April 30, 2021 02:23PM
You need to learn how to use the DAQ toolbox. See the following manual page.
https://monkeylogic.nimh.nih.gov/docs_NIMHDAQToolbox.html#DigitalIO

The digital I/O needs initialization only once when the task starts. You can use the alert_function to do so.
https://monkeylogic.nimh.nih.gov/board/read.php?2,6,6#msg-6

The attached example shows how you should write a script. Don't forget to turn on the "Alert" option when you run the script.

If you need to trigger the interrupt synchronously with visual stimulus presentation, remove the interrupt-related code from the example and set the interrupt bit as a TTL. Then send out the TTL together with visual stimuli.
Attachments:
open | download - test.txt (138 bytes)
open | download - test.m (172 bytes)
open | download - alert_function.m (784 bytes)
Re: Controlling hardware with digital NI board IO
May 03, 2021 04:54AM
Hi,

Thanks a lot for these explanations.

I implemented it using the DAQ toolbox interface and works as expected.

As I'm initializing DIO from outside the ML interface, is there any way to mark the DIO ports used as unavailable in the ML interface?

Thanks again,
Thomas
Re: Controlling hardware with digital NI board IO
May 03, 2021 01:06PM
No, there isn't.

The National Institute of Mental Health (NIMH) is part of the National Institutes of Health (NIH), a component of the U.S. Department of Health and Human Services.