LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need assistance in making TCP settings between Labview 2011 and webrelay

Solved!
Go to solution

Hi,

 

I am using Labview 2011 and trying to establish communication with webrelay (X-WR-4R1-l) to control its relays.

I have downloaded an example from www.ni.com but it does not work.  (it has been attached with this thread as well)

 

I did not make any changes in the example program, as I don't really understand much about XML codes.

 

I turned ON all 4 relays of this webrelay, but in labview it still reads as all the relays are OFF.

and when I click the ON button on the front panel, it does not do anything.

There are several labview toolkits installed in my PC, namely:

- labview development system

- application builder

- data logging and supervisory control module

- database connectivity toolkit

- internet toolkit

- report generation toolkit for Microsoft office

 

I would appreciate it if someone could guide me through this setup process.

 

Thank you

 

Download All
0 Kudos
Message 1 of 10
(3,669 Views)

I did not find your example on NI.com (do you have a link), but it seems identical to the one from here.

 

This example is pretty bad. Large amounts of duplicate code. All three buttons don't have a label, making the event structure incomprehensible, because the three events look the same. What's the story with the "clear error" inside the case on the right??? 😮 Why are the booleans wired to the structure? Why aren't they latch action an in their respective cases with "value changed" event?

 

Well, I cannot really tell from your description what you are doing.


suren237 wrote:I turned ON all 4 relays of this webrelay, but in labview it still reads as all the relays are OFF.

and when I click the ON button on the front panel, it does not do anything. 


 

How did you turn them on initially? Did you use the web interface?

 

Is the LabVIEW program actually running? Are the network settings correct (e.g. can you ping the device)? Do you get any error messages?

 

Can you place an string indicator to display the actually received strings (e.g. in the timeout case). What does it show?

Message 2 of 10
(3,651 Views)

Hi there,

 

first of all, thank you for the reply.

 

Well I turned on the relays not by using the labview software as it doesn't make any sense to me al all.

So I turned on the relays through web based setup. It can be found attached on my first thread.

 

Now that after turning on that the relays through web based setup, I went into run-time mode with labview connected.
Here the "relay state"and "input state" are always in "off" mode even after I toggle the buttons provided.

However when I disconnect the Ethernet cable connecting my PC and the web really, it shows ERROR on "relay state"and "input state".

 

is there any alternative example available for this function?

 

0 Kudos
Message 3 of 10
(3,640 Views)

Well, according to the manual, there should be a  <CR><LF>(\r\n) after HTTP/1.1 in the request strings, but they only contain a <LF> (\n) in that location. It is possible that it does not matter, but why would the manual insist??

 

I took the liberty to rearchitect the VI to avoid all that duplicate code and meaningless clutter. Of course I have no way of testing, so there are probably minor bugs. I also converted it back down to LabVIEW 8.0. (I also attached a LabVIEW 2011 version)

 

For debugging, I also added an error indicator as well as string indicators for the raw sent and received strings. These can be deleted later.

 

Please try it on your setup. If you actually get something in the "received string", but the state display is not correct, please stop the VI, make the current values default, save the VI and attach it to a reply here. This way we can analyze what the response is.

 

Is the password correct on the device? If you change the password, you need to modify the base64 string.

Download All
Message 4 of 10
(3,620 Views)

hi there,

 

just curious, 

 

is it possible to just control 1 relay rather then all 4 relays?

the program is getting quite complex. Smiley Sad

 

I planning to control the relays individually, meaning to say:

 

  - labview button 1 = activate relay 1

  - labview button 2 = activate relay 2

  - labview button 3 = activate relay 3

  - labview button 4 = activate relay 4

 

i would still try to test the program that you sent though but the above mentioned funtion is what i am aiming to achieve here.
do we still have to go through this program or major modifications need to be done??

 

please advice

0 Kudos
Message 5 of 10
(3,604 Views)

hello there,

 

i tried your program and added the screenshot as attachment

still i wasn't able to turn ON the relay.

 

i noticed from 'sent string' that the command to ON the relay ok.

but for some reason it does not ON the relay and thus receiving the current relay status as OFF.

 

is there anyway of resolvong this?

 

 

 

0 Kudos
Message 6 of 10
(3,570 Views)
Solution
Accepted by topic author suren237

OK, we are making progress....

 

Something seems truncated. Is there anything after realy4state in the received string? Since the string is longer, you need to adjust the number of bytes read. It is more that the 157, which is the current setting.

 

In any case, their LabVIEW example is for a single relay device. You need to look at section 3.2 of the manual you have attached to get the correct commands. There is now always a number between "relay" and "state" for example:

 

relay1state=1 to turn relay 1 one.

 

You need to do two things:

 

Write a formatter that composes the correct strings based on the selected relay.

Write a parser that extracts the relay state of all four relays. (the offsets will be different, for example)

 

I would recommend to treat the four relays as an array of four booleans.

Message 7 of 10
(3,559 Views)

Yes, the WebRelay demonstration .VI was written for the single relay unit and needs a rewrite for the quad units.

 

Would anyone like to share this rewrite if they have already done it?  (I realize it's be 5 years but what the heck?)

0 Kudos
Message 8 of 10
(3,236 Views)

Well... since no one has confessed to tackling this problem, I took a swing at it.

 

Please find the attached .vi that will operate the WebRelay-Quad in a similar fashion to the embedded web server but using LabVIEW, of course.

 

http://www.controlbyweb.com/webrelay-quad/ 

0 Kudos
Message 9 of 10
(3,225 Views)

I revised Christian Altenbach's, October 2012 version of the WebRelay (single) demo for the quad unit.  His use of indexing functions, string concatenation, and the Case Event method greatly simplify the vi structure.

 

This version retains the 'webrelay' base64 control password from the original demos. I tested  without setting the control password on the relay box with no problems.

0 Kudos
Message 10 of 10
(3,220 Views)