Jump to content
  • 0

How to know what to set MccDaq.DigitalPortType to for USB-201?


Jen
 Share

Question

I would like to control the digital inputs and outputs of a USB-201 in MATLAB using the Universal library for .NET.

I have seen the code provided in https://kb.mccdaq.com/KnowledgebaseArticle50779.aspx and am trying to add to it.

I would like to use DConfigPort and DOut commands for example but am mystified by the parameter MccDaq.DigitalPortType.

When I click on the options for that parameter in the UL library Help reference I get descriptions about options like FirstPortA,  FirstPortB etc.  This language of ports is totally unfamiliar to me.  All I know for a USB-201 is that I have DIO0 to DIO7.

Could someone please tell me how to specify which DIO I would like to configure and talk to? 

Better yet could someone please give me example code like in the above article for MATLAB that would say for example set DIO0 as an output and set its signal to high?

 

 

 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hey Jen,

Launch the UL Help, it's available from the Start Programs Measurement Computing folder (see below). If you're missing UL Help, reinstall InstaCal but this time from the MCC DAQ Software CD download. https://www.mccdaq.com/downloads/MCCDaqCD/mccdaq.exe

Click the Search tab and search on USB-201 to get to its reference page. Find the Digital I/O section and click UL Net function DConfigBit. Next, click on MccDaq.DigitalPortType in the C# function prototype. There you'll find the port types. Your port type is "AuxPort", which equals 1. Do the same for port direction (input = 2, output = 1). Bit numbers are 0 - 7. To set bits, use DBitOut or DBitIn to read it state.

Best regards,

John

image.png.502aa64ae5c347fafeddd3de45c910bb.png

Link to comment
Share on other sites

  • 0

Hello JRys,

Thank you for your help.

The matlab code provided in the 50779 support example with a small modification works now to set a digital output.

I added two lines of code to that example in order to set DIO0 to an output and to a high value:

daq.DConfigBit(MccDaq.DigitalPortType.AuxPort, 0, MccDaq.DigitalPortDirection.DigitalOut);

daq.DBitOut(MccDaq.DigitalPortType.AuxPort, 0, MccDaq.DigitalLogicState.High);

 

The main confusion was what to set the DigitalPortType to and thank you for telling me that it was AuxPort.  Another big confusion was that I did not know what was meant by Port or Bit.  As far as I understand now Port means all the digital IOs together and Bit means just one of the digital IOs specifically. 

Thank you again.

 

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...