Siemens TIA Portal: Making a heartbeat

LindeBerger

Member
Join Date
Nov 2023
Location
DK
Posts
12
Hi everyone

I've created an FC that includes the blocks TCON, TDISCON, TSEND and TRCV.

This block has to be as generic as possible across hardware so I can't use the TSEND_C and TRCV_C as these compact blocks aren't compatible with e.g. ET200S CPU. PUT/GET is out of the question because that's what I want to move away from.


I can make connection between two 1200 CPUs. I can also send/receive both ways without issues.


However, I need to create a "watch dog" that functions something like this:

PLC 1 sends the value of 1
PLC 2 adds 1 to the value of 2 and sends it back to PLC1
PLC 1 adds 1 to the value of 3 and sends it back to PLC2

if the value doesn't change then I have lost ccommunication between the two PLCs.


This task is very difficult to me because I'm not allowed to use any timers (IEC), CTUs, CTDs of any sorts with an instance.

I have to use an "Add" instruction and count up in a variable (1 byte) and perhaps use "Move" instructions.


I've uploaded a simple layout/topology of how it's structured and also a snippet of the logic for sending receiving watchdog values but I'm missing the last pieces.

I would really appreciate some sparring regarding this. I know what I want to do but I lack the skills to execute the plan.

I can upload the projectfile if nessecary.

Thank you in advance.

TconPNG_1.png TconPNG_2.png
 
This task is very difficult to me because I'm not allowed to use any timers (IEC), CTUs, CTDs of any sorts with an instance.


Wait, why aren't you allowed? Is this a challenge project for a school class?
 
This task is very difficult to me because I'm not allowed to use any timers (IEC), CTUs, CTDs of any sorts with an instance.
Please elaborate on this.
Who doesn't allow you to use any timers ?
You are programming a timeout function. Without at least one timer, it cannot be done. You can make some kind of pseudo-timer, but at sounds as if that is also not 'allowed'.
 
Wait, why aren't you allowed? Is this a challenge project for a school class?

It's in our 'standard protocol', unfortunately.

A variable called 'tmpAlwaysON' makes me nervous.

Every block has to be able to handle itself without memory bits in them. There are 100 different projects that have memory bits scattered on different addresses.

"tmpAlwaysOn" is latched and in network 1 in this FC. Its sole purpose is to energize the T-blocks.
 
Last edited:
Make it an FB with the timers an instance within the FB.

It's self contained and can be copied across multiple CPUs.

Exactly what an FB is designed for...
 
Please elaborate on this.
Who doesn't allow you to use any timers ?
You are programming a timeout function. Without at least one timer, it cannot be done. You can make some kind of pseudo-timer, but at sounds as if that is also not 'allowed'.

Yes, I have to create a pseudo timer/counter
 
Last edited:
Make it an FB with the timers an instance within the FB.

It's self contained and can be copied across multiple CPUs.

Exactly what an FB is designed for...

Yeah, that was my thought. Until I was told it has to be contained in an FC.
 
I presume you're also not allowed to use system clock byte? It's the only thing I can think of being simple enough to 'count' time without timers. But again that option needs to be enabled on hardware so it can work and would needed to be passed to FC as input, where I guess your FC should be without input/output parameters?


My suggestion would be to check watchdog is equal to last value each clock byte 1s pulse, increment some number if yes and when number reaches some value you declare timeout. If number isn't equal you reset to zero.


My 2 cents.
 
For a timer count scan cycles via an unconditional count := count + 1; (or equivalent in your language of choice); there may even be an internal scan cycle counter.

The average scan cycle time can be empirically determined and will be fairly consistent; the worst single case will be a rare long scan cycle i.e. a scan cycle that is interrupted by many or all higher-priority and overhead tasks, but I doubt that would make more than a few milliseconds of difference.

Assuming a UDINT (32-bit) counter, the only issue would be overflow about once per month and a half or so (assuming average 1kHz rate), and that is straightforward to deal with.

Don't even call it a timer; add a comment like "heartbeat has not been received for 5000 scan cycles; communication has been lost," so any high-frequency noise in individusl scan cycle durations will cancel.
 
Last edited:
The TCON, TDISCON, TSEND and TRCV instructions all have error bits and error codes, do they not?

And being FBs, you will need to make them Parameter Instances inside the FC to ensure no memory issues. Is there some restriction on calling an IEC timer with a parameter instance?
 

Similar Topics

I am currently am in a PLC class and need urgent help on how the ladder logic would be laid out. I understand how to get the traffic lights to...
Replies
19
Views
446
Hello, If the date on the license manager of tia Portal has expired, can I still work with it? or is this just to keep the program up to date...
Replies
7
Views
210
Hello, i can find the CPU when searching for it. But when I go Online i just get the icon for "Not compatible" everywhere. I get no additional...
Replies
4
Views
1,180
Hi, I want to initialise some tags on first scan only. As they are related to wall-clock time, I want to do the initialisation when the PLC first...
Replies
4
Views
1,173
good , how do i calculate the instantaneous flow according to the flow totalizer in the tia portal ? 1 pulse = 1m3/h
Replies
18
Views
1,568
Back
Top Bottom