How to change Constant with address in CASE loop TIA Portal 15.1

I don't understand your requirement. Please show the hours on your timing diagram.

This is how it should work I created video from my screen.
https://vimeo.com/user117954686/revi...219/e91e715863

I don't use real time stamp or hours, I start the process from button. It is for simulation stand just to show that if smth was ON, we have data from sensors thats all. Then according to buttons the output is ON for 3 sec, this time (3 sec) is fixed and I wrote it using CASE. If button is ON and period time from 0..3 for button 1 I activate OUT, if time 3..6 for button 2 and so on. Time is used from 1sec counter, it counts till 24 sec, then I reset it and process start again.
So I wanted to change somehow that time for output would be flexible. That's a question for that's why I asked how to do it.
Thanks a lot.
 
If all twenty-four [duration of action out] values are 3s, then this pattern (6s on, 15s off, 3s on, etc.) would repeat every 72s.


Is that correct?

Yes, yes. So I want that those 3 sec I could change from HMI for example. But I need to rewrite it, cause it is fixed through CASE loop.
 
Are all of the durations in each of the slots the same i.e. twenty-four 3s or twenty-four 7s?


Or could the duration in slot 1 be different from the duration in slot 2, and slot 2 different from slot 3, etc?




Because if the first case is true, and all twenty-four durations will have the same value at any time, but that value can be changed from the HMI, then your code from the OP will work, but you would have to

  • scale Tag_11 by [2/duration],
  • and truncate the resulting product to an integer,
before the switch statement.






But a cleaner solution would be to run a counter from 0 to 23, representing "hours" 1 to 24. Implement a self-repeating timer* with the [duration of action out] as its preset (PT?). Increment that counter every time the timer expires** and the counter is less than 23; assign 0 to the counter when the timer expires and the counter is 23. And then do what LD said forty-four posts ago: https://www.plctalk.net/qanda/showpost.php?p=854749&postcount=4.


It might be possible to write the timer .PT value directly from the HMI event, but to be safe (because who knows what happens if .PT is set less than .ET while the timer is timing), it might be better to cache the latest values from the HMI in a variable, and only change the .PT when the counter is being incremented, or maybe even only when the counter is being assigned a 0.



There are probably clean ways to do this, as well.



* I have no idea how to do that in ST; it is trivial - to me, I have so much to learn - in ladder.


** [timer expires] => .Q is 1
 
Last edited:
Are all of the durations in each of the slots the same i.e. twenty-four 3s or twenty-four 7s?


Or could the duration in slot 1 be different from the duration in slot 2, and slot 2 different from slot 3, etc?

It should be the same time for any slot, but the only thing is possibility to change before starting sequence. So it can be 3 sec instead of 1 hour or 5 sec or 1 sec or 20 sec. So e.g. if it is let say 5 sec, the whole period is 5 * 24 = 120 sec.
 
Here it is in Ladder*; the last "network" (i.e. rung;)) is equivalent to LD's code from post #4 of this thread; the rest is prelude. It seems to work.

  • cv is an Int
  • rollover_counter is a Bool
  • .bitarr is an <ARRAY [0..23] of Bool> in Data Block DBArr**
  • time_2nd_second is an IEC timer
  • 0_to_23 is a counter
I did not implement the update of, or the caching for, the preset [time_2nd_second.PT] from the HMI:

  • I assume that would be straightforward to someone who knows the relevant incantations;
  • actually changing .PT itself should probably only happen when rollover_counter is 1;
  • perhaps another branch in the middle of Network 1?


* I had enough trouble doing this in the TIA interface; I don't even want to think about doing it in ST ;)
** Why cannot an ARRAY be created in a Tag table?

xxx.png
 
Here it is in Ladder*; the last "network" (i.e. rung;)) is equivalent to LD's code from post #4 of this thread; the rest is prelude. It seems to work.

  • cv is an Int
  • rollover_counter is a Bool
  • .bitarr is an <ARRAY [0..23] of Bool> in Data Block DBArr**
  • time_2nd_second is an IEC timer
  • 0_to_23 is a counter
I did not implement the update of, or the caching for, the preset [time_2nd_second.PT] from the HMI:

  • I assume that would be straightforward to someone who knows the relevant incantations;
  • actually changing .PT itself should probably only happen when rollover_counter is 1;
  • perhaps another branch in the middle of Network 1?


* I had enough trouble doing this in the TIA interface; I don't even want to think about doing it in ST ;)
** Why cannot an ARRAY be created in a Tag table?


Thanks a lot, so helpful and easy...
 

Similar Topics

Hey all, i have a panelview screen (image attached), with 4 items on it. Program 1, Program 2, ...3, ...4. The PLC i am using is a compactlogix...
Replies
5
Views
158
Greetings I have a problem, my system is the following: wincc v8.0 (demo), logo8.3, abb m2m analyzer. I created some pages to display the...
Replies
0
Views
55
We had one go down. we have a new one. Their emergency Number don't work. The Model is TLSA046AAH-330N01-007 A catalog says we need software TET...
Replies
2
Views
167
“The HMI files we cannot open—they were saved in V13—we do not have that—I cannot restore file –please have them save in V11 and send them back to...
Replies
4
Views
173
Hi guys! I'm working in Studio 5000 and have a bunch of armorstarts there (+- 40). I need to set up parameters for each of them, mostly just same...
Replies
0
Views
90
Back
Top Bottom