LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Example: "Digital - Conitinuous Output" How does it work?

Solved!
Go to solution

I have to generate a sequence on three channels (with my NI 9375 Digital Output card on a cDAQ9188).

In 1 second, the sequence consists of, for example:

channel 1: starting low .. on 15 ms high .. on 865 ms low again

channel 2: starting high .. on 115 ms low .. on 650 ms high again

channel 3: starting low .. on 85 ms high .. on 920 ms low again

This have to be conituously generated and hardware timed.

 

For this application, they advised me to work with the example "Digital - Continuous Output". Can anyone explain to me how I get this sequence with the "Data To Write" Controls-box on the Front Panel? And how can I visualise my generated sequence?

 

Thanks in advance!

0 Kudos
Message 1 of 14
(3,564 Views)

Hello Hannes,

 

There are 2 major things that you have to keep in mind in this case regarding the example you're using:

- The sample rate you're going to use has to be high enough.

In your case the minimum sample rate has to be 200 Hz (seeing that your smallest step is 5 ms).
Of course you could also use any multiple of this.

- At the other side you have to check how the array of unsigned integers in the Data to Write is related to your digital outputs.

Depending on which Digital Outputs you're using one of the bits in your unsigned integer will correspond to one of your Digital Ouputs.

 

This mentioned the "difficult" part starts:

 

Seeing the period is 1 second and if you have selected 200 Hz (5 ms period sampleclock) as the sample rate, then:

- For channel 1:
the first 3 bits should be 0, the next 170 [= (865-15)/5] should be 1, the remaining 27 (200-173) bits should be 0.

- For channel 2:

the first 23 bits should be 1, the next 107 [= (650-115)/5] should be 0, the remaining 70 (200-130) bits should be 1.

- For channel 3:

the first 17 bits should be 0, the next 167 [= (920-85)/5] should be 1, the remaining 16 (200-184) bits should be 0.

 

To represent this visually the best thing you can do is to use 3 arrays of 200 booleans for the 3 channels.

These arrays can be easily shown in a Digital graph

You then have to make a very simple conversion algorythm to convert these 3 arrays of 200 bits/booleans to 1 array of 200 unsigned integers.

 

Is my explanation a bit clear to you?

 

Note: Here we took 1 as high and 0 as low.

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
0 Kudos
Message 2 of 14
(3,536 Views)

Thanks ThiCop!

 

So if I'm using my first three channels (DO 0, DO 1 and DO2) in the example described above, I have to send out the following array of unsigned integers:

Let's take the first 6 periods of 5 milliseconds (30 milliseconds in total):

array: 2, 2, 2, 3, 3, 3, ... 

(Vertically) split up in binary this is:

DO 0: 0, 0, 0, 1, 1, 1, ...

DO 1: 1, 1, 1, 1, 1, 1, ...

DO 2: 0, 0, 0, 0, 0, 0, ...

 

So this means (also for the first 30 millisecons): 

Channel 1 is low for 15 ms, then high ...

Channel 2 is constantly high ...

Channel 3 is constantly low ...

 

If I would take the same example, but I'd like to use channels DO 2, DO3 and DO4, I have to send out the following array of unsigned integers:

array: 8, 8, 8, 12 ,12 12, ...

(Vertically) split up in binary this is:

DO 0: 0, 0, 0, 0, 0, 0, ...

DO 1: 0, 0, 0, 0, 0, 0, ...

DO 2: 0, 0, 0, 1, 1, 1, ...

DO 3: 1, 1, 1, 1, 1, 1, ...

DO 4: 0, 0, 0, 0, 0, 0, ...

 

Now I have the same result, but for channels 2, 3 and 4.

 

Am I right by saying so?

0 Kudos
Message 3 of 14
(3,522 Views)

Hello Hannes,

 

That is indeed how I meant it..

Just for the sake of verification, you can always do a simple test where you just manually change the unsigned integer.

 

This can be useful to verify if what we are expecting is also what's happening.

Or we could just verify any mistake in conversions or mapping of the integers.

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
0 Kudos
Message 4 of 14
(3,506 Views)

What do you mean with a simple test? With the real hardware and an oscilloscope?

 

In case I want to use channels 2, 3 and 4, we see that the first channels have to be zero all the time so I can't use them for other things. For avoiding this problem I'll always have to take the first channels (DO 0, 1 and 2)? How can I use the following channels (DO 3, 4, ...)? I can change my array of unsigned integers U32 to unsigned integers U8, but then again are all 8 channels in use I guess?

 

0 Kudos
Message 5 of 14
(3,501 Views)

A simple test could be with real hardware and a scope or a DMM.

 

You could use a simple software timed example to do this.

And with this I mean:

Simply set the first boolean in your array to "true" or "1" and see which Digital Output turns "on".

If you know this, then you also know the relationship between the bits in the integer and the Digital Outputs.

 

Is suspect you mean "only 8 channels" instead of "all 8 channels"

U8's can indeed only be mapped to 8 different digital channels.

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
0 Kudos
Message 6 of 14
(3,486 Views)

Ok, I did a few tests now so I'm getting familiar with it. 🙂

 

When I performed the test, I supplied 24V DC to my device. When I set a channel ON, I measured 24 V but when I turned it OFF this became always 8.45 V instead of 0 V.

When I supplied 12V DC, the voltages were respectively 12V and 7.73 V.

Is this a normal phenomenon? There are also a few relays in my application so I'm worried it will already switch at a 'low' state of my outputs...

 

 

 

 

Message 7 of 14
(3,461 Views)

Hello Hannes,

 

How are you measuring these voltages (DMM, schematic, ... ) ?

 

Do you have a schematic of what is connected to the module when you're measuring it?

 

 

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
0 Kudos
Message 8 of 14
(3,426 Views)

I've measured these voltages simply with a digital multimeter.

At the moment I measured, nothing was connected yet. Because if I connect the relays, I have to place flyback-diodes I suppose? Although it's only a 24V, 20 mA relay.

 

0 Kudos
Message 9 of 14
(3,411 Views)

Hello Hannes,

 

Even if it's just a relay of 20 mA, you should still place the flyback diode to cope with the iductive parts.

 

There are 2 things I would like you to test:

- Can you do a self-test or self calibrate of the device from inside MAX (without anything connected)?

( I personally don't know if this is possible, because I don't have that module present and cannot simulate it)
If it is possible, then please try it (without anything connected) and let me know about the result(s).

 

- Do you have any resistors that you can connect between the DO COM and the used DO?

I'm curious to see if your relatively high "low" outputs are caused because nothing is connected between the COM and the output.

 

I also have to add 2 relatively simple questions just for the sake of it:

- Are you measuring between the DO and the DOCOM?

The reason I ask it is because recently there was a customer that had made a mistake with regards to the pinout.

- Are you using the DSUB or the spring terminal version?

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
0 Kudos
Message 10 of 14
(3,398 Views)