How do I copy a string every 0.1 seconds?

opmal7

Member
Join Date
Dec 2014
Location
Moline
Posts
35
I'm guessing there is a simple way to do this, but I'm not very experienced with timers, so maybe one of you can help me out.

I have two string variables set up. Lets say ST1:0 is incoming data, and ST2:0 is outgoing data. I have a pre-defined string message in ST2:1 that I want to copy to ST2:0 every 100 msec. I want to continue to do this until the content in ST1:0 matches a pre-defined string in ST1:1.

I set up some timers and COP instructions, but I think I made a mistake somewhere. My timer is copying the string, but only for the 1st iteration. Once the DN bit is '1' the timer doesn't reset itself. Like I said, I'm still kind of new to using timers, just wondering if there is a better way to approach this. Thanks, and let me know if there are any additional questions or info needed.
 
Put a XIC infront of the timer, pointing at timer.DN. that way when it is done, next scan it will turn off and the scan after that it will turn on again.
Timers are not super accurate though, so if you need 100ms consider a periodic task or accessing the PLC clock.
 
You could put your code in a cyclic task and perform a move until your logic says otherwise. You don't need to use timers that way. And using timers would probably be more inaccurate as well.

It's always helpful if you post what plc you're using.

Edit: AustralIan was faster. :)
 
Put a XIC infront of the timer, pointing at timer.DN. that way when it is done, next scan it will turn off and the scan after that it will turn on again.
Timers are not super accurate though, so if you need 100ms consider a periodic task or accessing the PLC clock.

Exactly what he said, except use an XIO instead of an XIC 🍻
 
You can try to program a "blinker" routine with 2 timers, so you can use 1rst timer to copy strings (every 100 msec) and the second timer to reset 1rst timer and then reinitiate the cycle.
 
You should put your platform in your question.

The easy way to make a timer cycle continuously is to do MyTimer.IN:= NOT(MyTimer.Q).
In Rockwell land, which I'm assuming you're in, that is putting an XIO of MyTimer.DN in front of your timer.

Doing the thing you're trying to do, I probably wouldn't use a timer and just setup a 100ms task class to run that logic. AB timers are notoriously inaccurate because of the way they work (which is different from how everyone else does timers). I'm also familiar with how terrible working with strings is in AB and can't believe anyone puts themselves through that when just about any other brand makes strings a lot easier.
 

Similar Topics

Hello Inside a FB, I´m trying to transfer a string from a DB to a IN_OUT var that was define as a UDT. The problem is that i can´t determine the...
Replies
4
Views
121
I feel like I'm going crazy, new to Siemens, coming from AB, and I cannot get a dang string copied in SCL. This is a S7-300, V16 PLC. I have a...
Replies
10
Views
3,451
HI Guys So i am trying to write a real SINt or DINT value into a string tag. If in string browser I write it manually, no problem. But how can I...
Replies
8
Views
5,880
I am using v14 with a 1215 dc/dc/dc. I need to copy a 50 element array of strings to another 50 element array of strings. I can work it out for...
Replies
3
Views
4,000
Productivity3000. I have a 32 bit integer, 1d array that i need converted to a string. The string to array seems to work with the same time type...
Replies
0
Views
2,164
Back
Top Bottom