LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

[FPGA] - NI 9401 - Input & Output Issues

Solved!
Go to solution

I am attempting to set my Input and Output channels on the NI 9401 digital modules on my compact RIO to power a photogate and read the input back into the module. However, my FPGA code is not working as how I expected... as my Output is not generating my expected 5V and I am getting nothing into my input.

I have set my desired lines for Input and Output and have my power for my photogate at DI0 and my Input at DI5 and when the two match I should obtain a high value through my comparsion. This would then light up my LED on my front panel.

Untitled.jpg

0 Kudos
Message 1 of 15
(4,742 Views)
Solution
Accepted by topic author AllanIL

First, you should set the line directions outside the main while loop, then power your device with your DO, and see if your DI rises up.

Then your code seems not to be reading or setting any digital values, since you are using the reference terminals not the digital value terminals.

So actually comparison is always false (you are comparing two references).

 

 

Message 2 of 15
(4,728 Views)

Hi Marco,

Your solution has worked. However, there is one odd thing that I observed and that is the LED indicator on the front panel lights up quickly and never relights again after the program has run. It will do the same thing and will only light again after I restart the controller. Do I need to place a while loop around the entire sequence to fix this?

0 Kudos
Message 3 of 15
(4,689 Views)

maybe this depends by how your device works.

When the FPGA starts to run, it sudden puts your DO state to TRUE and let it so indefinitely.

You should check with a multimeter that the DO value is always high and never goes down.

Otherwise, try to put the DO->TRUE control inside the while loop.

The while loop simply put the FPGA in a state to read indefinitely the DI state as given from your device.

Maybe your device, once it is powered, drives up its output just for a while.

 

Or maybe you need a code to power ON and OFF your device by HMI and to see if the device's feedback is OK.. please describe better your issue.

 

Bye

M.

 

 

0 Kudos
Message 4 of 15
(4,673 Views)

The output channels are reading out 5V constantly and remains this way. I have tried the while loop approach as you suggested, but it did not work. Can you elaborate a bit more about the ON & OFF code you are talking about?

The photogate will only light up once and it appears that the code will no longer detect when the gate has been closed (high) after the initial reading. It perhaps latches?

0 Kudos
Message 5 of 15
(4,662 Views)

The code reads the DI state continuously.

Maybe you have to put your DO to F after a while (i.e. give an impulsive control in digital output to your device), or to control manually your output from interface in order to see variations over your DI feedback.

Anyway, could you send your project files?

Message 6 of 15
(4,634 Views)

Hi Marco,

I have attached my code below, in the meantime I will try to set my output false and delay to see if it will work. I have tried to turn on the input and it actually worked for a little bit, but no longer works.

 

0 Kudos
Message 7 of 15
(4,596 Views)

Why are you writing to your input?  Once upon a time (I can't find it in the help right now), that would actually which your line to be an output, which I am certain you do not want.

 

And how are do you plan on changing the status of your output line?  It is just set once and then never touched again.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 8 of 15
(4,588 Views)

Hi crossrulz,

It was me toying around in an attempt to the make the sensor read, but I have eliminated that from my code recently. I want the half of the ports on my NI 9401 to be output and half inputs, which I have done in the first step of the sequence. I want my status of my output line to be a constant supply voltage to power my sensors and then read the output of the sensor at an input line, but this is proving to be more difficult than it should be.

0 Kudos
Message 9 of 15
(4,584 Views)
Solution
Accepted by topic author AllanIL
Hi I am sorry I am currently out and cannot see your code in these days. But I have just one doubt... Are you sure that the TTL DO has current enough to supply tour device? Maybe trying with an external power supply just to see if your DI is working properly could help.. I will evaluate tour code laterali. Bye marco
Message 10 of 15
(4,578 Views)