LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Having problem sending a constant value to PLC using data socket.

Hi,

  I am using RSLinx OPC server to communicate between Labview and the Input register of the AB PLC. I have used Datasocket earlier to switch a light on and off. but now if i use the same program to change the content of the register but for a different PLC program the value is being set and reset continuously, but i need that value to be set once i give a on option and reset when i reset. I could upload the vi that i am using if u need it.

 Can anybody send some examples on using the datasockets, and I also want a vi where I could generate square wave using pulses from an encoder.


Thanx in advance.

Anand
0 Kudos
Message 1 of 9
(4,636 Views)

Anand,

What do you mean exactly when you say "same program to change the content of the register but for a different PLC program".  Do you mean that your LabVIEW program is the same but the program running on your AB PLC is different?  If so it just sounds like there is something in your PLC's program that is toggling the value of the register independant of LabVIEW.  Also, there are many datasocket examples in the example finder.  If you select Help->Find Examples and then navigate to the Networking->Datasocket->OPC directory you will find 5 or 6 examples involving using datasocket to read/write OPC items.

I hope this helps,
Justin D
Applications Engineer
National Instruments

0 Kudos
Message 2 of 9
(4,620 Views)
Hi justin,

I have a program written to write a value to the
register contact of a PLC through OPC server using
Datasockets. but my value is being set and reset for a
about 10ms or so..I dunno why it is happening, I dont
find any timing elements in the program. Can you
modify the program to send a constant value...without
being set to the userdefined value and zero every
10-20ms.

I am a novice in labview so I am seeking your help, I
am attaching the vi that we have created.

0 Kudos
Message 3 of 9
(4,593 Views)

msu,

I don't see anything inherently wrong with your application.  Do you really need to write the value to the register so fast?  With a 0ms wait in your loop, the loop is essentially running as fast as possible.  If you just take the loop out of the program and write the value once does it still reset?  If so, this definitely seems like an issue with your PLC.

-Justin D

0 Kudos
Message 4 of 9
(4,574 Views)

hi justin,

 

   Is there any other way i could send the data to the plc registry content apart from using the datasockets. Can we use DSC module to acheive that. if so can u send me some simple examples on how to send the value to the register content of the PLC and how to use them in a program.

 

Thank you

Anand

0 Kudos
Message 5 of 9
(4,561 Views)

Hi Anand,

You can use the DSC module to bind a shared variable to an item on an OPC server.  There is detailed information on how to do this in the DSC help.  Here is a link to where you can download the help from our website.

http://digital.ni.com/manuals.nsf/websearch/642E46FEB461C3A7862571D3000B86CB

If you look under "Creating an OPC Client Instance" it will tell you how to create an OPC I/O Server step by step.

-Justin D

0 Kudos
Message 6 of 9
(4,539 Views)
Hi Justin,


 I have written a program to send a 1 as output at the start of the run button and after user defined seconds of delay the value has to change to 0.
But in the program i have written the case selector line is 0 first and it has to give 1 as output, but it doesnt give 1 but after the user given seconds of time the case selector line is giving a 1 but the output from the case structure is no changing. What is the mistake I am doing here?

thanx

anand
0 Kudos
Message 7 of 9
(4,526 Views)

Hi anand,

Your program just outputs one number, not a series of 2.  The "output" will remain at its previous value until the delay is up and then it will change to 1.  To do what you want, I would reccommend using a FOR loop.  In the first iteration, write a 0 to the output and have a delay.  In the second iteration you could write a 1 and exit the FOR loop.  I would also really reccommend that you go through our "Learning LabVIEW in 3 Hours" tutorial.  Here is a link:

http://zone.ni.com/devzone/cda/tut/p/id/5247

-Justin D

 

0 Kudos
Message 8 of 9
(4,496 Views)
Hi,
 
There must be two control one location. This is very momon mistake in plc tags control.
 
Could you check the PLC item to see of you PLC code write value to the same tag (your tag name is Data)? Or you may be written a value to the input port of the PLC. The tag name on your vi(Local:7:I.Data) it looks like an input from one of the chanel, or module of the PLC at local 7 Input module.
 
Have great day,
Dam Nguyen


Message Edited by Chieudam on 12-20-2007 08:17 PM
0 Kudos
Message 9 of 9
(3,526 Views)