Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

NI 6501/9 - Knowing state of Digital Out pins... (in C#)

Hi,

 

I'm trying to work on a "driver" for an NI 6501 (and down the road, 6509) DIO device.  We've got a method that sets the state of a pin and creates all the necessary digital out channel calls.  It appears that the command works fine, by having LED's connected up to the pins.

 

However, when I run this code:

 

        public virtual byte ReadLineInput(int channel)
        {
            if (IsSimulated)
            {
                return 0;
            }

            var readTask = (Task) taskChannels.GetValue(channel);

            var reader = new DigitalSingleChannelReader(readTask.Stream);
            var data = reader.ReadSingleSamplePortByte();

            CheckForErrors();

            return data;
        }

 

where "taskChannels" is where we stored the tasks set up for 3 8 bit ports to be Digital Outputs...

 

I don't get the values I'd expect.  I'm reading from a Digital Output, so I'd expect it just to tell me what pins are on and off.  However, I have noticed it's actually switching them to Digital Inputs, and then it is setting all the pins to high (which I'd expect with the pullup resistor and nothing hooked to the pins) except for the pins which are connect via LED's... They go low (because they're connected to ground) and I get 0's.

 

How do I view the state of Digital Output pins without storing them in the driver?  For all intents and purposes, this device will be all digital out....  there are no commands to change the channels to Digital In...  so the "read" is doing that on it's own... Is there a "Peek" or "View" on the digital outputs?

 

Thanks,
Rich

0 Kudos
Message 1 of 4
(4,556 Views)

Hello Rich,

 

Can you tell me why you are trying to create a driver?  Since NI provide the driver functions I am curious why you're doing that.  What NI DLLs and APIs are you using?  There should be a digital outread function within the DLL that NI provides.  

 

Thanks, 

Jonathan R.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 4
(4,516 Views)

Hey Jonathan - 

 

Driver may be a strong word... We're creating a functional "layer" so that we can send in an int value to a channel (8 pins) and the pins would be set appropriately for that value to control a device attached to those 8 pins of the NI-6501/9.

 

We're using the 9.8.40.45 version of the NationalInstruments.DAQmx.dll and 13.0.40.190 version of the NationalInstruments.Common.dll.  I realize this puts us a version behind the newest, so we have that on our plate as a possible change to get what we're looking for....

 

I looked within the Digital Out Channel functionality and didn't find anything that didn't swap functionality (as I mentioned above)... Doing a read on an output channel acted like it changed the channel into an input channel (due to the LED connections showing values, where it should have been showing what pins it had previously set high..)

 

If code was added to the 9.9 version of NationalInstruments.DAQmx.dll, then I can hunt that down...   It just seemed odd you couldn't read what you had set pins to...

 

Thanks.

Rich

 

0 Kudos
Message 3 of 4
(4,514 Views)

Hi Rich,

 

Can you tell me why you need to verify what's being written out by the hardware where in fact you can just check on the software side?  You can check what's being written to the DAQmx write function before writing and cut the hardware side of things altogether unless there's a reason you need to do that.  If you really need to check you can do a simple loop back test by wiring the digital output pin to the input.  

 

Thanks,

Jonathan R.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 4
(4,495 Views)