PDA

View Full Version : Beckhoff BC start up


Jon R
September 26th, 2009, 03:24 AM
:scratch:

I am trying to detect the start of a BC controller, from a stopped condition(not a full restart) but there is no function available in the standard library.

I have implemented the GetSysTick function, which increments every 1ms, and then I will use this to do a compare. Only problem is when I run my project, the value of the variable I point at the function does not increase.

My line calling the function is below, with isystem_tick declared as a DWORD:

isystem_tick := GetSysTick(bDummy);

The variable bDummy is always set true by declaring it in VAR as:

bDummy : bool := true;

Has anyone got any ideas, or used this before? I am feeling particularly blonde about this, I must be missing something.


Jon.

LadderLogic
September 26th, 2009, 09:42 AM
I cant't remember at the moment if a BC has a real-time clock. That is the only method I can think of: read RTC at the beginning of each scan and compare the reading with the stored value from the previous scan.

When you stop the code execution, everything in essense freezes so there is no way to detect the changes. The RTC, however, should still be ticking, regardless of the code execution. If present, of course.

Jon R
September 26th, 2009, 11:30 AM
Yes there is an RTC block in the TcPlcUtilitiesBC.

I thought the GetSysTick may be easier to implement as it should function in the same way, but I shall try the RTC instead.

Thanks,

Jon.

SteveMaves
September 28th, 2009, 05:35 PM
Hi Jon R, The BC9000 has no battery backup for the RTC, so it must be read from an ADS server on powerup. If you have a TwinCAT PC anywhere on the network you should be set, otherwise you'll need a BX or higher. PM me if you'd like some sample code for RTC read function.

LadderLogic
September 28th, 2009, 09:49 PM
The BC9000 has no battery backup for the RTC

If I understand the problem correctly, it should not matter. A hard reset can still be detected by "first scan" bit method. For the soft reset, the RTC should still be ticking.

Jon R
September 29th, 2009, 10:34 AM
Problem solved.

GetSysTick does not work in simulation mode :banghead:.

It does exactly what I want. It is reset to zero on a full reboot and continues incrementing when stopped so a simple compare will do the job.

That was an extreme blond moment. Thanks to LadderLogic and Steve for their input.

Jon.