Welcome, Guest
Username: Password: Remember me

TOPIC: TCP Remote connection

Re:TCP Remote connection 13 years 9 months ago #854

  • claes
  • claes's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 3176
  • Thank you received: 501
  • Karma: 133
Hi Björn,

Check the spelling of I1.

Yes, you can make declarations inside the code, also static if you want to keep them to the next scan.

Yes, you are right, it shoud be OI. I will change that.

/Claes
The administrator has disabled public write access.

Re:TCP Remote connection 13 years 9 months ago #855

  • Bjorn
  • Bjorn's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 18
  • Karma: 0
I rewrote all I's in the code and know it compiles.

But the code does not responed to a command. I send 101 which should set factory to 1 and error-Handler to 0 and thus \"start\" the factory.

Have I thought complete wrong while creating the plc? Should I have a seperate PLC-thread and PLC-program for server, client and hardware?

Here is a dump of the code:
http://dl.dropbox.com/u/1125912/Proview/Client.pdf
http://dl.dropbox.com/u/1125912/Proview/Server.pdf
http://dl.dropbox.com/u/1125912/Proview/Main.pdf

Client and Server are sub-windows from Main.

I get the program to send me an error but I don't get the program to respond to receive. I know it gets the message but I can't see what happens after that.
The administrator has disabled public write access.

Re:TCP Remote connection 13 years 9 months ago #857

  • claes
  • claes's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 3176
  • Thank you received: 501
  • Karma: 133
You don't need different threads.

The problem, I think, is the send Dv, tcpConnection-send. If you look at the right DataArithm in the main program, the send Dv is set from od1 with a StoDv, ie the od1 value will copied to the send Dv every scan. Note that the od values (and other output values) of the DataArithm are stored in the object and keeps its values to the next scan. You set do1 to 1, but I can't see any reset, so it will be 1 for ever, and so will the send Dv. And the RemTransSend is just triggered the first time. The reset in the send window will have no effect.

One way to trouble shoot fast sequences is to use the logging function i rt_xtt and start a logging with the same, or faster, scantime as the plc. Then its possible to see what happends during the short time between receive and send.

/Claes
The administrator has disabled public write access.

Re:TCP Remote connection 13 years 9 months ago #858

  • Bjorn
  • Bjorn's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 18
  • Karma: 0
Ok, I thought the DataArithms reset there values automatically. I did reset the send-Dv in the send sub-window but that have no effect then. So all values have to be reset ( d1 = 0) in the start of all DataArithms?

The log is a TLog item that is to be placed where?
The administrator has disabled public write access.

Re:TCP Remote connection 13 years 9 months ago #859

  • claes
  • claes's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 3176
  • Thank you received: 501
  • Karma: 133
Yes, resetting at the start is one way of handling it.

The rt_xtt logging function is described in Operators Guide, section Navigator / System / Logging.

/Claes
The administrator has disabled public write access.

Re:TCP Remote connection 13 years 9 months ago #860

  • Bjorn
  • Bjorn's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 18
  • Karma: 0
That solved some problems with resetting values!

So, my next problem is incrementing, OI1 = I1 + 1; does not seem to work.
OI1 the new value and I1 the old.
error code example:
I1 = noError och OI1 = noError, so I take the current value and save over the old one
[code:1]// Set error flag is not set
if(d1 == 1 && d2 == 0){
od1 = 1; // set error flag
od5 = 1; // send error message
OI1 = I1 + 1; // increment error count

if(d3 == 1) // IR error
od2 = 1;
if(d4 == 1) // Temp error
od3 = 1;
if(d5 ==1) // Factory error
od4 = 1;
}
else{
od5 = 0; // Send
}

// Reset if no error
if(d1 == 0 && d2 == 0){
od1 = 0; //Handler
od2 = 0; // IR
od3 = 0; // Temp
od4 = 0; // Factory
od5 = 0; // Send
}[/code:1]
The administrator has disabled public write access.
Time to create page: 8.040 seconds