Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

How to send digital pulse - USB-6509

Hi Everybody,

 

I am a complete novice at LabVIEW and need to get a simple program up and running quick. I am totally lost on where to start.

 

We recently purchased the USB-6509 to control 80 DO and use the remaining 16 DI for monitoring our system. For the 80 DO, all I need to do is pulse one line High "1" for about 2 seconds and stop. After that 2 seconds, monitor the 10 channels for any feedback for approximately 30 seconds. If the proper channel responds and the other 9 did nothing, continue onto the next output line and pulse High. This process will repeat until one of the wrong units respond back.

 

I am not sure if I explained that correctly, but looking through this forum I wasn't able to find anything that helped. Right now, I am currently simulating USB-6509 until the module arrives. Please help in any way.

 

 

I am currently running:

Windows XP Pro +LabVIEW 8.6 + NI USB-6509 (96 DI/O)

 

 

Thanks for your time and reading this post.

 

Henry

0 Kudos
Message 1 of 26
(7,757 Views)

Hi Henry,

         I would highly recommend taking a look at some examples to get started.  Though there's not an example that does exactly what you want it to, it will help you to get a feel for LabVIEW and the VIs that you'll need to use.  I would open up the NI Example Finder (when you're in LabVIEW go to Help»Find Examples...), then Browse According to Task.  I would take a look at some of the Digital I/O examples to get started.  Check out the examples in the section Hardware Inuput and Output»DAQmx»Digital Generation.  Also, you may want to look at one of the examples that uses a DAQmx read (so that you can see how you'll need to monitor your input lines).  A good one to look at would be Read Dig Chan.vi under the Digital Measurement folder.  Though these are simple examples, they'll give you a starting place.  Eventually, you may need to use a loop with a wait and your write function in it to output your 2 second high, then use a shift register to move through all of your channels.  

       Here's a link that I think you may also find helpful as you get started in your programming. Additionally, because you're looking to do some complex stuff, I would highly recommend ourtraining to save you some time and help get you started. Please post additional questions as you get started on your programming!

aNItaB

Applications Engineer

National Instruments

0 Kudos
Message 2 of 26
(7,730 Views)

Thank you AnitaB!

 

I received the USB-6509 module yesterday and those examples are great. Being able to see results makes feel better and I am starting to understand how this works. Right now I am trying to check the timing limitation on how fast I can pulse a single channel Hi/Lo with my computer. I modified the Write Dig Chan.vi from the Hardware Input and Output > DAQmx > Digital Generation > Write Dig Chan.vi....to take in Digital Pattern Generator (Toggle) with values 0 and 1 instead of manually pulsing the channel with the boolean ON/OFF push button.  However, checking the P0.0 (the line that pulsing) I see no output. Am I using the right DAQmx Write.vi or did pass in the data incorrectly? My vi may look crappy, but at least I'm trying! Smiley Happy

 

 Unfortunately with this economy, my company and I cannot afford the training. I already asked and got shutdown. I should be able to pick up a few helpful programming tips from all the tutorials available online.

 

Once again, thanks in advance!

 

Henry

0 Kudos
Message 3 of 26
(7,723 Views)

Sorry for asking this stupid question, but how do I cycle through the digital channels? I thought I had something right, but it didn't do anything.

 

 

0 Kudos
Message 4 of 26
(7,708 Views)

Hi Henry:

 

Since you can pass a DAQmx channel name as a string, you can programmatically cycle through channel names by using some for loops and string manipulation.  I have posted some example code showing this functionality to the NI Community here.

 

This example will cycle through your 80 digital outputs and write a signal for 2 seconds but in your application you will have to add the code to read the 16 digital inputs to the inner for loop.

 

Please let me know if something isn't working correctly with the example or if you have any further questions.  Good luck with your application!

Message Edited by A Person on 03-06-2009 12:11 AM
Alex Person
NI-RIO Product Support Engineer
National Instruments
Message 5 of 26
(7,691 Views)

Genius!

 

That is exactly how I wanted to loop through all the channels. You just saved me a whole days work because I started using a flat sequence and hard coding each channel to pulse high for two seconds. I'll try to add the code to monitor the 16 digital inputs and a way to break out of the loop if one of the wrong inputs goes high. I'll keep you updated.

 

Thanks for all those that helped!!! I am truly greatful for all the support this forum brings to everyone.

 

Henry

0 Kudos
Message 6 of 26
(7,675 Views)

Hi Everyone,

 

So far I have not managed to get the timing right to see any inputs on the lines being monitored. From what I found out recently, the unit sends its first response in about 15ms after each DO command and another response update 30 seconds later. At this stage, I would like to monitor all the lines continuously for the whole time the program is running and output it to same text file. I am not sure if I have my digital input in the right location for this to work.

 

I have attached my program for everyone to review. Thanks once again from a newbie!

 

Henry

0 Kudos
Message 7 of 26
(7,547 Views)

Hi Henry:

 

Earlier you had mentioned that you needed to output on a line for two seconds before listening.  Is this correct or will the instrument respond immediately after receiving a high signal?  The way you have it written right now, it reads immediately after sending the high signal instead of waiting the two seconds.

 

There are a couple other things to keep in mind while programming this.  The second sequence structure you have in place with the two second wait is not necessary because you don't need to wait after setting the DO line low.  The only reason for the first wait is because you mentioned the need for a two second high signal for the instrument to respond to.  In addition, if you are looking to continuously monitor the DI lines, you will need them in a separate inner loop.  Otherwise, you are only reading one sample after writing a DO line high.

 

Let me know if I wasn't clear with this explanation or if you have further questions.

Alex Person
NI-RIO Product Support Engineer
National Instruments
0 Kudos
Message 8 of 26
(7,529 Views)

Hi Alex,

 

Thank you for your response. It is correct that I would like to output on a line for two seconds but when I found out the first response time is approximately 10-15ms after receiving a high signal, I decided to change the program to continuously reading to make sure I am capturing that input. However, there is another response 30-45 seconds later from the same unit that sent the first confirmation DI earlier.

 

The second sequence structure that I placed is meant to delay the next DO line high output and capture the second response mentioned earlier. Currently I have it set to two seconds to troubleshoot not capturing the first response and will be set to full 60 seconds to break up each two seconds DO line into minute intervals. So the way that I have it setup now only takes one reading sample after writing a DO line high? I think I made the appropriate modifications to watch for the second response but I never see the lines go high on my front panel.

 

For continuously monitoring the DI lines, you mentioned I need to add them in a separate inner loop. Does that go inside the sequence structure in order to get the timing right? If it goes outside the sequence loop, how will the program know to move on to the next port/line if it is running continuously?

 

Hopefully my attached VI will show you my train of thought and let you know if I am on the right track. Thanks for all your help.

 

Henry

0 Kudos
Message 9 of 26
(7,524 Views)

Hi Henry,

          I took a look at your program and I think that one of the reasons that you're not seeing your first pulse is because of the sequence of your write/read (you'll want to start writing before you read), as well, in your  sequence structure, you're only reading once- which limits the chances of capturing your first response.  The attached program using two while loops to continuously check for your digital output (the first one uses the Elapsed Time express VI to run for 2 seconds, the second loop runs for 60 seconds).  Give it a shot and let me know if this works out any better for you.  Have a great weekend!

 

0 Kudos
Message 10 of 26
(7,464 Views)