Feedback

Bob O

Member
Join Date
May 2003
Location
Posts
1,873
I have written some code that I could use some feedback on. I have a situation were I need to start a timer when valve 1 goes true and then stop this timer when valve 2 goes false.
As an example, valve 1 starts at time = 0 and stays on for 4 sec. but then valve 2 starts at say 1 sec. and stays on for 5 sec. for an elapsed time of 5 sec. The code I wrote works from what I have tested. Any other ideas on how to write this?
P.S. Sorry I coulndn't get a pic of the ladder diagram to post. I will be working on that.

Thanks,
Bob
SOR XIC I:0.0/0 BST OTL B3:0/0 NXB RES C5:0 NXB ONS B3:0/1 RES T4:0 BND EOR  SOR XIC I:0.0/1 CTU C5:0 1 0 EOR  SOR XIO I:0.0/1 XIC C5:0/DN BST OTU B3:0/0 NXB OTE B3:0/2 BND EOR  SOR XIC B3:0/0 RTO T4:0 1.0 32767 0 EOR  SOR XIC B3:0/2 MOV T4:0.ACC N7:0 EOR  SOR END EOR 


 
Huh?

As a public service, I'm posting your code

[attachment]

Since your code contains no annotation, I have no idea what exactly it is you are trying to accomplish.

But...

On rung zero, you reset the counter on the Input. On rung one, you are incrementing the counter on the same Input. With a preset of one, the counter is acting just like your Latch of B3:0/0 - just remembering that you've indeed pushed the button. Although it works, it's not the best use of a counter.

My impression is that you are trying to use the counter as a modified flip-flop. Pushing the button the first time records how long the button was pushed. Pushing it a second time resets the timer.

Is this what you are trying to accomplish? If so, this code won't do it.

But if had plugged that into a PLC, you'd know that.

If you need help, state what you are trying to do (as clearly as possible.) Use as many words as needed. Don't be affraid to challenge Phil's 10K character limit - only Terry, Ron B, and I have posted such tomes that we needed to split up our posts.

Then I, or someone else here, will help you walk through HOW to write code that will produce that result.



As far as posting ladder, you forgot the '/' in you final LADDER tag (it should have read [/ladder], not [ladder])

Even so, that wouldn't have produced what you wanted. All that SOR XIC stuff is strictly AB coding. The LADDER tags are used to do ASCII line art, and allow everything to line up, not to convert AB-speak into a graphic.

So either draw your rungs by hand in the Reply Window, or do screen capturing to get the ladder from RSLogix to a JPG. (For the above, I first narrowed the LAD pane so that the resulting picture would not be too wide (not everyone has Belgian monitors). Next I selected the first rung in RSLogix, copied it, and pasted it into Paint. Next, I set the attributes of bitmap in Paint to be long enough to paste all the rungs. Then I copied one rung at a time into Paint, and then saved the whole thing as a JPEG.

It sounds like a lot of work, but it took more time to write about it than to do it.

img.jpg
 
Last edited:
Hope this works

Thank you for telling how to insert pic.

I have written some code that I could use some feedback on. I have a situation were I need to start a timer when valve 1 goes true and then stop this timer when valve 2 goes false.
As an example, valve 1 starts at time = 0 and stays on for 4 sec. but then valve 2 starts at say 1 sec. and stays on for 5 sec. for an elapsed time of 5 sec. The code I wrote works from what I have tested. Any other ideas on how to write this?

time.jpg
 
Sorry about my error. I tried to paste your code into a SLC project that I had open, and RSLogix complained about the ONS instruction, so I pasted it into a PLC-5 project instead. RSLogix5 didn't like the I:0.0/1 address, and decided it must be I:0/0 instead of I:0/1. I didn't verify the conversion, so I didn't realise that you were working with a Mircologix.

Anyway....

I have a situation were I need to start a timer when valve 1 goes true and then stop this timer when valve 2 goes false.

If I were to program the above statement, I would code it as:

|"start... when | |"and then stop... when |
| valve 1 goes true" | | valve 2 goes false" |
v v V V

VALVE_1 RUN_TIMER
-------| |--------------------------------------------+--------( )
|
|
RUN_TIMER VALVE_2 |
-------| |---------------------------------| |--------+


RUN_TIMER
-------| |----------------------------------------------------(TON)



This could be simplified if using an AB PLC. Combine it all into one rung and use the TimerTiming bit instead of the internal RUN_TIMER.

To capture the accumulated value, just do a MOV as long as Valve_2 is open.

I'm pretty sure that the above code does the same as yours, but I don't feel like checking all the premeutations of the valve positions to verify it.
 
In comparing your code to mine, I see that yours will continue to time even if Valve 1 closes before Valve 2 opens. This may be a requirement - I don't know.

My biggest criticism of your code os that you are using a counter (3 words worth of data, and three instructions), just to record the fact that Valve_2 has openned after Valve_1 started the timer.

I'm no fan of latches/unlatches, but they're better than using counters. The problem is really a simple sequencer:
Code:
[B][U]Step |       Description    |      Action      | Transition       |[/U][/B]  
   1 |                 Idle | None             | Valve 1 opens    |
   2 |            Run timer | Run Timer        | Valve 2 opens    |
   3 |  Allow Timer to Stop | Run Timer (cont) | Valve 2 closes   |
   4 |                 None | << Go to step 1>>|      N/A         |

And the latch/unlatch sequencer of the above is:

VALVE_1 TIMING
-------| |-------[ONS]--------------(L)


TIMING VALVE_2 ALLOW_STOP
-------| |--------| |-------+-------(L)
|
| TIMING
+-------(U)


ALLOW_STOP VALVE_2 ALLOW_STOP
-------| |--------|/|---------------(U)

TIMING
-------| |---------+---------------(TON)
|
ALLOW_STOP |
-------| |---------+



This does everything that yours does, but without the counter. I think it's a little easier to follow.
 
I'll try again.

Allen Nelson said:
Sorry about my error. I tried to paste your code into a SLC project that I had open, and RSLogix complained about the ONS instruction,

If you create a new application with a Micrologix 1500 processor, the code will paste without a complaint from RSLogix.
 
I agree with Allen - your application isn't the best use for a counter. In looking at Allen's code, the only thing that looks different in behavior is the timer reset - yours toggles with every "Valve1 Opening".

I also noted that you are MOVing your data (the same data) until Valve1 or 2 opens again. You could use something like the Timer Enable bit to move it only once.

My only other thought is that I also personally don't like one-shots and avoid them whenever possible.

How about this?


Valve1 TMR_Reset Timer
----| |------------+---|/|--------(RES)--
|
| Timer_On
+----------------(L)--
|
| TMR_Reset
+----------------( )--

Valve2 Timer_On V2+TMR
----| |-------| |-------------------(L)--

V2+TMR Valve1 Valve2 Timer_On
----| |-------|/|-------|/|---------(U)--

Timer_On Timer
----|/|-------| |--------------+--------+
EN | MOV|
+--------+
Timer_On
----| | -----------------------+--------+
| RTO|
+--------+




Marc
 
I agree about the counter, one shots and from what I have been reading on here (other threads) the latch/unlatch should be eliminated. As Terry would say and maybe will, I was hacking through it and I would have to agree. Thanks again for the feedback.

Bob
 

Similar Topics

It's been a long time since I've had to think of P&ID tag nomenclature myself (and not gone along with some scheme devised by someone else). I've...
Replies
1
Views
240
The PMTR has a timeout parameter for run feedback during a start, but once the motor has been running for a while and loses that run feedback (to...
Replies
0
Views
223
Hi all, One of the Kinetix 5500 in a machine is getting a Feedback Device Failure, subcode 66: INTERNAL RESOURCE ACCESS ERROR. Studio 5000 V.34...
Replies
4
Views
933
Hi, I'm trying to understand a couple of things with a feedback signals that are used in a SRP/CS that I'm working with. Quick disclaimer: I'm...
Replies
2
Views
535
I swear I post this yesterday but can't find it. Don't see any notification about the post removal either. Maybe my memory is malfunctioning...
Replies
3
Views
2,569
Back
Top Bottom