Siemens S7-300 time loging

Taiger

Member
Join Date
Mar 2014
Location
Finland
Posts
8
Hello all experts,

I'm a total beginner on PLCs and would need some guidance if possible. Basically I'm building a house (for my family) and I'm going to have a PLC system to control basically everything.

I'm only in the starting phase, have lighting from switches and similar to work. And now I'm trying to get something more fancy into the program.

From the beginning I was thinking of having power monitoring on a lot of places to determine power consumption in the house. But I have come to the conclusion that it would be rather expensive with HW and everything + using lots of space in the cabinet. So started thinking that PLC can basically calculate this for at least some of the consumers such as lighting.

For example I know that a specific light is 45W, and if I monitor the time it is on I know how match it have used. So what I basically would like to do is to put a time stamp when each lamp is turned on in a data base. And when it is turned of put a off time stamp in the data base. Then calculate the amount of power it consumed. (The database of everything the PLC is doing is later on going to be written to log files in a PC in time intervals.)

Then later on I would of course try to make this on-line so that it can be monitored live. I started with timers but if I understand it correctly the max time of a timer is 9990s = 2H 46M 30s. Maybe some counter to count the times the timer came to the end would be possible. But in the end there would need to be lots of timers and counters.

My current HW:
Siemens S7-300
CPU: 313C
Eth: CP343-1
and many DI/DO

Have anybody worked with similar time stamping and can guide me in the correct direction. Or knows a better/smarter way of doing above? Remember I'm not that advanced yet so basic explanation so that I understand :D
 
Hi
You can use an IEC timer with a lot longer runtime...search this forum for examples

How accurate do you need to be?

I would forget timers and use clock pulse seconds and then increment a minute counter / hour counter /day counter /week counter etc to give you a total for each device and then you could simply multiply
by kwh or whatever and unit costs

Does your CPU support a webpage? Some do but I am not familiar with the capabilities of that
 
Hi
You can use an IEC timer with a lot longer runtime...search this forum for examples

How accurate do you need to be?

I would forget timers and use clock pulse seconds and then increment a minute counter / hour counter /day counter /week counter etc to give you a total for each device and then you could simply multiply
by kwh or whatever and unit costs

Does your CPU support a webpage? Some do but I am not familiar with the capabilities of that

I do not require is to be in millisecond accurate, this is only to be used as rough information. If I get in 1s accuracy I'm more then satisfied.

Okay so I tested a little the IEC timers and it might be that SFB4 is closest to what I need it takes something like 24Days and 20hours. So I would still need to have a counter to calculate how many times it goes over 24days (Will not be very often, but in-case)
But the thing with the SFB4 is then that it stops counting after it have counted for 24days. It does not look like it have any reset input, so that it can start over?

So maybe your suggestion of clock pulses would be best. Could you give an example on how those are used, with the minute counter / hour counter /day counter /week counter etc.

Unfortunately my Communication processor (CP343-1) does not support a user web server, only a web diagnostic server (to my understanding)

Br
Taiger
 
Hi
create a db and make entry 1 ..secs of type int. Make entry 2 ..mins of type int. Make entry 3 hours of type int and make entry 4 days of type dint.

look in the cup configuration for clock word and set it if needed. I will post a screen shotlater.

Then use a (P) to get a pulse of the 1 sec clock bit.

use the pulse to add 1 to your db secs.

Ifsecs Iis greater or equal 6 add 1 to db mins and reset db secs.

etc etc for hours and days. Days is a dint so it can store a massive number.

You could goto years if you wanted to.

Sorry if any typos I'm on my phonettyping this
 
Hi
create a db and make entry 1 ..secs of type int. Make entry 2 ..mins of type int. Make entry 3 hours of type int and make entry 4 days of type dint.

look in the cup configuration for clock word and set it if needed. I will post a screen shotlater.

Then use a (P) to get a pulse of the 1 sec clock bit.

use the pulse to add 1 to your db secs.

Ifsecs Iis greater or equal 6 add 1 to db mins and reset db secs.

etc etc for hours and days. Days is a dint so it can store a massive number.

You could goto years if you wanted to.

Sorry if any typos I'm on my phonettyping this

Thanks for taking your time :)
I have the data base ready, but I will wait for your screen shot as I cant find the CUP (maybe typo) function block. I assume that you are meaning a normal counter? But from where will a get the continuous (P) pulse to increase the counter with 1s for adding to DB? and why not directly use this (P) pulse to increase the DB?

Sorry if I have stupid questions. But this is my first real thing I'm doing with any PLC.
 
You can call FB1 as many times as you like for each device in your house, Replace I1.0 with whatever the input is

Use a different DB for each device. DB1..DB2..DBxx

Look in the DB for the devices run times

house6.png house7.png house8.jpg
 
You can call FB1 as many times as you like for each device in your house, Replace I1.0 with whatever the input is

Use a different DB for each device. DB1..DB2..DBxx

Look in the DB for the devices run times

Okay, Now it's set up according to your screen shots. Network 5 however I could not get it to approve days as long as they where of type dint (they become red in colour) same with L#0. So I now temporary set it to INT so that I could test it. And ITS ALIVE !!. Sort of :) I already had something configured on M1.5 (ClockBit) so now the time (Secs) run really fast :)

One question, we configured ClockBit on address 0.0 But you set it to M1.5 in OB1, or did I miss something with why M1.5 should be connected to ClockBit??
 
Got it working, I was using memory bit M1.5 earlier an that was what was causing the speedy clock.

Now it is working when activating an output !!!

Thanks a lot. It's very easy when a professional is doing things like this. And I learned something in the same time. I will now try myself to get some calculations and similar on my own. Might be that I come back when I get stuck :)
 

Similar Topics

Hello all. I have an ESA HMI that is connected to a Simatic S7-300 (CPU312). I have uploaded the program from the PLC which is written with Step7...
Replies
6
Views
1,437
Hello. There is a problem with Siemens S7 300. We got a replacement PLC but it does not run the program from the MMC. The new PLC is dated 2011...
Replies
3
Views
684
Hi to all, Our company does not usually use Siemens PLCs, but have a press with one in it. We are trying to change the IP address in our Simatic...
Replies
2
Views
1,064
G'day guys, I am setting up a s7-300 as a test rig for the workshop and when I downloaded the PLC is not going into run mode, I keep getting a...
Replies
35
Views
5,205
I am trying to write just MSEC to S7 300 Controller date/time using OI.SIDIRECT Aveva communication driver? The old HMI (WINCC) tag is assigned...
Replies
1
Views
1,057
Back
Top Bottom