Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with NI 9401

Hi guys,

 

I have a cRIO 9074 and a Digital I/O module 9401. I am trying to generate a PWM signal to control a motor. I connected my digital i/o channel DIO0 to the oscilloscope to check if I can generate a PWM signal. The connections I have done are Channel 1 from oscilloscope to DIO0 and ground from the oscilloscope to the COM on the module. I have also set DIO3:0 to "output. I have the attached vi running under the FPGA target. I dont have anyother vi's in the project. But no output on the oscilloscope. I am not sure about what I have done wrong, is it my VI, some kind of initial setup i missed out or something else.
Please help me out. I have attached a picture of the project explorer and also, the vi that I am using.

 

One more this under the option of each channel there were choice for Always attributed and never attributed. Don't know what they mean but I have tried both and none of it works. 

 

Thank you
 

Download All
0 Kudos
Message 1 of 5
(5,047 Views)

Pritesh,

 

The code you have in the screenshot is correct, however, in the attached VI itself, you never output the signal to the cRIO channel - make sure to use the I/O node.

 

I'm assuming the LED light on the front panel comes on and off, but your actual signal is not detected. Have you tried using a multimeter to make sure you're getting no output? Also, I'm not quite sure where you're seeing the "always attributed" and "never attributed" option. Can you point me to it? What version of Labview and the FPGA module do you have? 

What values are you inputting for high and low pulse inputs? Make sure you realize those numbers are measured in clock ticks (by default).

 

One more thing: there's an example of pulse generation in example finder at Help > Find examples > Hardware input and output > compact RIO > FPGA fundamentals > counters > pulse generation. You should be able to tweak this example to fit your needs. 

Misha
0 Kudos
Message 2 of 5
(5,010 Views)

Hi Pritesh,

 

My guess about why you don't see any output from the 9401 is because you are probably not setting the line direction of the DIO3:0 nibble to output anywhere. If that's the problem, you can find information on how to set on this thread:

 

http://forums.ni.com/ni/board/message?board.id=170&message.id=185258&query.id=300980#M185258 

 

Hope this helps.

 

JMota 

0 Kudos
Message 3 of 5
(4,995 Views)

Hi guys,

thank you for your help.

 

Sorry for the late respnse.

 

I was able to generate the PWM. The problem was with  my oscilloscope.

 

However, I am having another issue. I am not getting the desired frequency from the PWM signal. 

 

I want to generate a 20Hz, 20% Duty cycle signal. (i.e. Period = .05 sec and 20% duty cycle corresponds to .01 sec)

 

I am still using the same VI as earlier. To generate this signal i have set the loop timer to usec- 32 bit internal counter (not sure what exactly that means though)

 

I set the  High period = 10000 usec (.01sec) and Low period = 40000 usec

 

However, no matter what I input it generates a 10Hz, 50% duty cycle signal.

 

I am not sure how many Ticks corresponds to 1 usec or 1 sec but non the less, even with the loop timer set for Tick , it will generate on a 10Hz, 50% duty cycle signal.

 

What could be the possible issue. I can figure it out. Is my VI correct or something wrong with that???

 

Please help me out here

 

Thank you

 

0 Kudos
Message 4 of 5
(4,904 Views)

Pritesh:

 

A few things for you.  First, you are seeing a constant timer value since you are using a Loop timer.  When a loop timer is initialized in a loop(while loop in this case) it will hold the first value written to it unless the loop is restarted.  You can replace this loop timer with a simple wait function.  This will be 99% accurate at the speeds you are setting your duty cycle at(off by ~50-75ns or 2-3 clock ticks I would guess).

 

If you wanted more accuracy on your loop, you could set the loop timer rate to be very fast, maybe 100kHz or more, and use a counter/shift register to keep track of your high and low times.  Drawback is that your loop rate has to be divisible by your requested high and low times.  Example: Loop rate at 100khz, or 10 microseconds.  High time requested: .01 seconds, use a shift register with an increment to count to 999(zero indexed counter), then change to false and reset counter.  Low time requested:.04 seconds, count to 3999 then change to true and reset counte. More work, eliminates that minute amount of error of simply using a wait function.

 

Finally, I would suggest using U32 controls since you are making your FPGA do work to convert it to U32 when it inputs into the loop timer/wait function.

Rob K
Measurements Mechanical Engineer (C-Series, USB X-Series)
National Instruments
CompactRIO Developers Guide
CompactRIO Out of the Box Video
0 Kudos
Message 5 of 5
(4,886 Views)