Showing results for 
Search instead for 
Did you mean: 

Labview writing incorrect DIO port in USB 8451

Go to solution

Hello! I am using a NI USB 8451 for controlling a relay using the 8 DIO ports. I'm using a Labview code to write port P0.4 as high or low. I am checking the voltage using DMM. However, P0.4 is not being activated at all, but instead the port P0.0 is being activated. I tried this with port P0.5 and still P0.0 is being activated. I'm attaching my VI here. as well as an image of front panel and block diagram. Whats the error in my code which is triggering P0.0 always? Thanks a lot!



0 Kudos
Message 1 of 13

I have not used that piece of hardware before, but I suspect you problem could be the DBL you have chosen to represent your port. You actually have it as 0.4 (i.e. four tenths) which is being coerced to an integer which would be rounded down to zero. Hence why port 0 is getting the value.


Try changing your DBL to an I32 (or whatever the write VI expects).

0 Kudos
Message 2 of 13

Hey, I tried changing the DIO active port input in property node and port number input in DIO write function from DBL to I32 or U8, but both are giving me an error 301750: NI-845x:  "The DIO port is not valid for this device. Refer to your hardware documentation for the number of DIO ports supported"

I tried using highlight execution and what you're saying is right.. since I had set it to DBL, it was considering the input as 0 instead of 0.4 (or 4).


Actually, I was coding using I32 earlier but encountered this error, so I changed the inputs to DBL. How do I troubleshoot this error 301750?

0 Kudos
Message 3 of 13

The property node is looking for a string, not a Double- try using a String constant.

0 Kudos
Message 4 of 13

Yes, the DIO active port is looking for a string, hence I'm using a number to decimal string converter. I changed the input to the converter from DBL to I32, and it is giving me an error. The port number input in DIO write function is looking for an integer, but using I32 instead of DBL is still giving me an error 301750.


P.S. Earlier, I tried using a direct decimal string input instead of a converter, but it gave me the same error. 

0 Kudos
Message 5 of 13

I don't have this hardware driver installed so I can't try it myself, but typically port numbers for DAQmx DIO digital ports are strings, but they're not just "0.0". It'll look more like "dev0\p0.0" or something, and you can't just format a number into a string. The 8451 might be different, I just don't know.


Can you find any examples in the Example Finder that might show you the right format to use?

0 Kudos
Message 6 of 13

What happens if you wire P0.4 directly as a string? I am assuming that P is a part of the string that you want to send.

0 Kudos
Message 7 of 13
Accepted by topic author vedsoni1996

My recommendation is that you just get rid of your Port Number and Active Port inputs.  There is only 1 port on that device, after all.  So just let them be the default.


EDIT:  Oh, and since you just want to write to a single line in the port, you should be using the Write Line VI, not the Write Port.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Message 8 of 13

Yes, I did use the example finder. However, the examples they've provided are of writing individual lines in a port. So 8451 has 8 ports and each of them has 8 lines. I'm trying to operate multiple relays and hence I was planning of using multiple ports to do so. But, I suppose I could operate them using multiple lines on the same port, I'm not sure about it though. Using ports directly would be much simpler.

0 Kudos
Message 9 of 13

Using P0.4 directly as string is bringing up a new error 301712: "NI-845x:  The active property you set is invalid. Reasons include an improperly formatted active property string or the active property may not have been set."


0 Kudos
Message 10 of 13