S7 FB temp vars

CharlesM

Member
Join Date
Aug 2005
Location
Arkansas
Posts
1,129
I did this project about a year ago and everything was fine until today. My machine working in steps. The operator can look at these steps and turn on outputs for an adjustable amount of time. There is 2 outputs the first must come on before the second. So this is a common type of thing for me so I made an FB to do all this so I could just call the FB when I needed this type of control.

So this morning the customer calls me and tells me that the first output will work for 5-10 cycles then it does not come on. I put status indicators on the HMI that come from the FB directly and these inicators are not coming on either. So I feel that it is a programming problem not electrical. However the code has been working for a year without any problems. The only thing I could think of was the time was being lost going to the timer. So I removed the temp variable from the FB and connected the time direct. I also put the timer number directly into the FB. This fixed the problem but I don't know why. Has anyone had this problem before?

Attached is the call for the FB and Before changes after changes of the FB.
 
How do you ensure that the integer values of time will always stay in range for s5Time variables ?
 
I limit the input on the HMI. I think the max is 30 sec typical time would be from 5 - 15sec. This morning when I had the problem the time was set for 9 sec.
 
Are you changing the time constant somewhere? It looks like it would always be zero in your code, which would mean the longest time you could preset would be 9.99s (BCD 0999). To get 15 seconds, you would have to change the time constant to one and pass in 150 (BCD 1150).
 
You may have something. I am not setting the time constant however I do know they were using 9 seconds this morning. Looking back into WinCC Flex I see the limit for In_Ext_Time is 5000 which should be 50 seconds. I don't think this is the problem I am seeing but it is a problem.
 
Are you sure they weren't trying different values? If they input 10s, that would be BCD 1000, which is actually 0 seconds. I imagine you would get strange results.
 
Could be. I know it was 9 when I loged on but maybe they changed it before I got connected. That would explain alot if they did have 10. I'll check first thing in the morning.

I guess my next question is what is the best way to load more time into the timer?
 
Last edited:
It depends on what your range and resolution needs to be. If you need, say, 1 to 50 seconds with one second resolution, then all you would need to do is hard code a 1 into the last four bits of the timer value, pass in values between 10 and 500, convert it to BCD, and AND it with the time constant. If you need to get fancier and want something like 1.01s to 50.0s, then you need to evaluate what is coming from WinCC and change the time constant dynamically.

But from the looks of your app, it seems like a one second resolution will be fine.
 
It’s also possible to deliver the time value from HMI
in ‘TIME’- format [ dword ; milliseconds] and then use FC40 TIM_S5TI out of ‘IEC-Function Blocks’ library,to
convert 'Time' to S5time' format. -- or use IEC - timer
instead.
 
I got online this morning with my machine and 10 seconds did not work. After talking to the customer we decided to just limit the time to 9.9 seconds. This will work for them but I want to change it for our standard machines.

I will look into the FC40 that may be a cleaner solution than setting the time constant.

Thanks for the help
 

Similar Topics

The objective: Reach about 10’ horizontally into a 1300F furnace, and pick up a 140lb rectangular container, then pull the container back out of...
Replies
15
Views
1,864
Hi Everyone, We have Silo System which has temperature sensor and these sensor data will be communicating through RTU unit to the Dedicated PC...
Replies
2
Views
615
We have a small plastic parts oven (SP at 210F). It used to have an old bimetal temperature regulator. We are upgrading it using two temperature...
Replies
7
Views
1,531
We have a vertical Axis which was overheating while not moving. After further investigation I found that when the axis moves upward to a...
Replies
5
Views
1,203
Needing some help. I have a machine that was put in storage and has ended up in my lap. It had a 5/02 originally but the card was pulled and I...
Replies
3
Views
1,414
Back
Top Bottom