Twincat FOR LOOPS

Thats the sequence i need to work.

I just think of another problem->

What if the tasks take to long? And I miss the received data?
 
brbrb

I don't really understand what you need.

You will do communication from CX to an other device over RS232. To what are you communicating ?

What do you mean by, if the tasks take to long ?
I don't think you need to write loops to achieve trustable communication.



Thats the sequence i need to work.

I just think of another problem->

What if the tasks take to long? And I miss the received data?
 
The receive buffer gets filled with a function block. Beckhoff states the function block take 3 cycles to finish.


Im communicating with a serial boatloader from a MCU. This things have unpredictable communication.
 
But think about it, there is other driver in windows CE that really handles the coms, now, there is this beckhoffs FB that is interface to use that driver. Now. Think when they say it takes 3 cycles to finish, that really means, it takes three calls for that FB in three concecutive cycles to finish.

Do you have hw to test?
 
loop

I never wrote loops for doing communication with serial devices. I allways worked with Siemens, and indeed, there is also a standard FB that handles 99% of the communication.

I allways started with communicating to hyperterminal, first from device to hyperterminal, then from PLC to hyperterminal. If this works, then the step PLC <-> device could be made.

First you try to receive data, see how the data comes in, what faults can happen, what code you can write to prevent unvalid data etc etc...
Then you try to send and see if the device responds like it should...

There isn't much more that I can say.


But think about it, there is other driver in windows CE that really handles the coms, now, there is this beckhoffs FB that is interface to use that driver. Now. Think when they say it takes 3 cycles to finish, that really means, it takes three calls for that FB in three concecutive cycles to finish.

Do you have hw to test?
 
This is little bit difficult.

Twincat Soft PLC is a round-robin sheduler. It give process time to the task. This time u need to configure.

So when i give my main task 10ms process time. After that time it saves its context and execute the next task in the priority list.

After all tasks have run it gets the context back from main and it execute where the PC last have been.

How can u handle the communication when u not get the code on hold somewhere?

The CE driver would it hold a buffer of his own? So i would not miss any receiving data?
 
Last edited:
That is too much **** to wade through

Isn't there a yield() function?

It it used like this:
Code:
   WHILE WAITING_FOR_CHAR
      YIELD();
   END
   DO_SOMETHING_WITH_THE_CHAR;
The WHILE loop looks like it will hang up until a character arrives but the yield function switchs to another task. All the other tasks will run and then the yield function will return to this task and check the character again. The YIELD() function makes writing co-operative multitasking code easy.

So is your operating system a co-operative multi tasking operating system? IF so it better have some form of YIELD function. I will leave it to you to find it.

I tried looking on both the Beckoff and MS sites and they both draw a perfect vacuum when it comes to getting technical details. They focus too much on marketing garbage.
 
I tried looking on both the Beckoff and MS sites and they both draw a perfect vacuum when it comes to getting technical details. They focus too much on marketing garbage.

Nice said my friend. :)

I dont fully blaim them. Cause even the support guys get there hands of my case when I call them.

Maybe this problem I have is a rare case for them.


There is no YIELD function supported for their OS.
 

Similar Topics

Hi guys, I am using TwinCAT 3 and I have a laser sensor that sends me data in Array. At the beginning of the measurement I run reference scan...
Replies
6
Views
2,603
I am using twincat 3 to send some strings over TCP/IP. Where the server is a sensor and my PLC is the client. I noticed that the sensor didnt...
Replies
2
Views
95
I'm trying to control a device via MODBUS RTU and the ModbusRtuMasterV2_PcCOM in Twincat 3. I've configured a device with the right com port and...
Replies
7
Views
233
Hi! I am trying to run the 'SimpleSample' (https://infosys.beckhoff.com/content/1033/TF5100_TC3_NC_I/Resources/3438746891/.zip ) to understand the...
Replies
2
Views
116
I am developing a library in twincat and one of the function uses IID_ITcVnAccess_TcVnPoint2_DINT and the definition of this type is defined in...
Replies
0
Views
80
Back
Top Bottom