LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using NI VISA to control relay card

Hello,

I am tryng to write a labview program to switch on and switch off relays on the 8fachrelaycard produced by Conrad ( instruction manual attached with the interesting part at page 31-32-33-34). The task should be really simple but the relay card behaves in a way that I don't understant. I wrote a program that writes 4 bits at the same time as written in the instruction manual: first beat for the comand , second beat for the board address,third bit for the relay addres, fourth bit for the XOR controll.

My intention was to initialize the card, inizialize the relay and then write the comand for switching on the relay. Even if the switch on command corresponds to writing 3 on the first position of the bits array,the realy card doen't respond.Furthermore it switches on 2 realays(the second and the third) when the command  1 is selected (which should correspond to initialize). Furthermore sometimes the same program acts like said before, sometimes it doesn't work at all. It doesn't give me error either.

I also am using the software used by conrad for testing the card and that works perfectly.

Do you have any suggestions?

Thank you a lot

Download All
0 Kudos
Message 1 of 10
(2,879 Views)

Sounds simple enough but I only have LabVIEW 2017 installed. 

 

Can you save your test.vi for LV2017 and post it?

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 10
(2,852 Views)

hello,

thank you a lot for the response. I converted the file. Thank you!

0 Kudos
Message 3 of 10
(2,841 Views)

In the VI you sent, you do not set the BAUD rate; the default is different than the manual. You are also sending a termination character, which I did not see in the manual. Also why are you converting your U8 bytes to U16?

 

mcduff

0 Kudos
Message 4 of 10
(2,829 Views)

Thank you a lot for the responce, you are very kind.

I had already tried with the baud rate set at 19200 but it wasn't working so i was trying to change that value. I was also trying with the conversion from u8 to u16. I don't know what you mean for termination charachter,where is it? I modified the program as you said but it still doesn't work. Could it be a driver problem too? I installed the latest drivers but the are update until windows 8 and I'm unning windows 10. On the other hand I don't think it's a driver problem either since the conrad program that comes with the relay card comunicates perfectly with the card. I sent you as attachment the modified vi. Thank you a lot again.

0 Kudos
Message 5 of 10
(2,801 Views)

The baud rate has to be set correctly for communication to work. The termination character is what is added at the end of the message. In your original VI you had the termination character enabled when initializing the com port; it adds a new line character, \n, to the end of every message. To disable it set the value to false on the initialization. I do not have LabVIEW here to look at your new VI, nor will I have for the next few days. 

Sorry

 

Mcduff

0 Kudos
Message 6 of 10
(2,791 Views)

McDuff.

 

That is incorrect.  Having the termination character enabled at the Serial Configuration subVI (default is enabled, linefeed if nothing is wired) does NOT cause VISA Writes to automatically send a termination character.  It only causes VISA Reads to terminate when it receives that character.

 

Termination characters on Write has to be explicitly added to the string being written, or use a separate property node to enable the termination character to apply to the Write automatically.  I prefer the former when it is needed.

Message 7 of 10
(2,764 Views)

@RavensFan wrote:

McDuff.

 

That is incorrect.  Having the termination character enabled at the Serial Configuration subVI (default is enabled, linefeed if nothing is wired) does NOT cause VISA Writes to automatically send a termination character.  It only causes VISA Reads to terminate when it receives that character.

 

Termination characters on Write has to be explicitly added to the string being written, or use a separate property node to enable the termination character to apply to the Write automatically.  I prefer the former when it is needed

 


Oops! Sorry for giving bad advice.

 

mcduff

0 Kudos
Message 8 of 10
(2,761 Views)

Hello,

Thank you a lot for your reply. I'm still stuck on the program. The rely card doesn't seem to comunicate correctly or maybe i'm doing something wrong in the labview VI which i cannot see. DO you have any suggestion on what i should check? I ran out of ideas. Thank you

best

0 Kudos
Message 9 of 10
(2,744 Views)

Are you sure you have the board address set correctly?  You are writing to address 0.  I can't find it in the manual, but often on multi-device busses, address 0 is considered a broadcast address to all devices.

 

Do they provide software that you can use to verify the device is working correctly?  If they do and it does work, try using a packet sniffer such as Wireshark to see the messages that software is sending.

 

 

0 Kudos
Message 10 of 10
(2,725 Views)