LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I want to control two relay, but Labview says I have something wrong with my VI

Solved!
Go to solution

From the picture, I have 2 relays to control, they are both toggle on/off type, I want to control them at the same time, but fail to do it.

 

I already set digital>multiple channels>single sample> 1D boolean(1 line per channel) and before I run, i pick channel 0 and 1 in the front pannel

 

When I run, the program doesnt give error, however, I use voltmeter to test the voltage at port 0 and port 1, they are 5V and steady....which doesnt correspond to the VI i write

 

After I hit stop, Labivew says,

 

pecified read or write operation failed, because the number of lines in the data for a channel does not match the number of lines in the channel.

If you are using the Digital Waveform datatype, make sure the number of lines in the digital waveform matches the number of lines in the channel. If you are using boolean data, make sure the array dimension for lines in the data matches the number of lines in the channel.

Number of Lines in Channel: 8
Number of Lines in Data: 1

Task Name: _unnamedTask<4>

 


What's wrong with my VI? thank you

Download All
0 Kudos
Message 1 of 13
(3,345 Views)

You have 8 lines defined in your task.  Some of the arrays you have going into you DAQmx Writes only have a single element (True).  The other DAQmx Writes have empty arrays, i.e. no elements are defined..  You can tell that by the False elements that are faded out.

 

You need to stretch your array constants to show 8 elements, then click on the 8th element to define it true or false as needed. Now you will have 8 elements defined.  Then you can change each of the 8 elements to True or False as needed.

0 Kudos
Message 2 of 13
(3,339 Views)

thank you, however, I can click on the false to make them not faded, and before I run, i only pick channel 0 and 1, but still give me problem

 

Could you tell me how to sketch array constant? thank you

0 Kudos
Message 3 of 13
(3,330 Views)

If you have only 2 lines now picked, then your array constants should only have 2 elements selected.  (It is hard to tell now since the constants only show the first 2 elements.)

 

If it is still now working, then give the error message and error code, and reattach your latest VI.

0 Kudos
Message 4 of 13
(3,323 Views)

thank you here are the VI

 

I already picked channel 0 and 1, when i hit run, no error, but volmeter show steady 5V at channel 0...

 

WHen I hit stop, labview give me similar errors:

 

Possible reason(s):

Write cannot be performed, because the number of channels in the data does not match the number of channels in the task.

When writing, supply data for all channels in the task. Alternatively, modify the task to contain the same number of channels as the data written.

Number of Channels in Task: 1
Number of Channels in Data&colon; 2

Task Name: _unnamedTask<E>

 

 

I am using USB 6008

Download All
0 Kudos
Message 5 of 13
(3,319 Views)
Solution
Accepted by topic author godpaul

It doesn't seem to like the layout of the 1-D boolean array.  It doesn't make sense.

 

But I did find a way to get it to run without errors.  I'm not sure without having a real daq device to know if the outputs will be correct.

 

1.  Change all of the DAQmx Writes to 2D boolean array, (N lines per channel).  So Digital >> Multiple Channels >> Single Sample >> 2D Boolean.

2.  Change all of the array constants to add a dimension turning them into 2-D boolean arrays.

 

Now it will run without errors.  But whether the output is correct or not, you'll have to test.

 

You said you are trying to control relays.  I don't know what types of relays you have, or what your DAQ device is, but beware that most DAQ cards do not supply enough current to drive a relay directly.

0 Kudos
Message 6 of 13
(3,302 Views)

it run it run!!!!!!!!!

 

thank you!

 

How do you know that??

 

please look at the picture.

 

The relay board is transitor type, it requires external 12 V, and the manufacturer helped me add a resister to keep the current under 700mA which satisfied USB 6008 output current requirement

 

one more question, how to add a indicator to show the status of the relay board, it's easy when using express Vi, but how to do it manually here?

 

Thank you very much!!

 

Yi

0 Kudos
Message 7 of 13
(3,296 Views)

I figured there had to be some combination of settings in the polymorphic writes and the input going in that would have to make it work.

 

For an indicator, I would consider using a sort of state machine architecture where there is a case structure, each case handles one of the writes, (and the corresponding delay).  The loop iteration terminal would determine which state of the case structure to run.  Then the boolean constants in each case structure could feed an indicator that is outside the case structure but still inside the while loop.

0 Kudos
Message 8 of 13
(3,290 Views)

The USB-6008 digital outputs can sink a maximum of 8.5 mA. The maximum voltage is 5 V. 

 

700 mA and 12 V sounds like a sure path to destroying your USB-6008.  If you need currents and voltages like that you need some kind of buffer or driver between the USB-6008 and your relay board.

 

Lynn

0 Kudos
Message 9 of 13
(3,281 Views)

no, Mr Lynn.

 

the board has three connections, port 1: 12V DC    port 2: TTL trigger    port 3 relay contact , that 's it

 

and here is his reply:

 

It looks like you want to use a TTL pulse from your DAQ to control my relay. That is fine - I will have to make a design adjustment in order to do that.  No problem. I will also put a 680 ohm resistor on the TTL input to make sure that the current draw on your signal never exceeds 8 mA. To trigger the relay on my board, you will need to have your DAQ provide a short pulse every time that you want to toggle on or off.

0 Kudos
Message 10 of 13
(3,277 Views)