kcox1980

ABS Instruction

12 posts in this topic

When using an ABS(absolute value) instruction, can I use the same tag for the source and destination or do they have to be entirely separate tags? 

I assume they would need to be different but I thought it would be worth asking.

Edited by kcox1980

Share this post


Link to post
Share on other sites

? It would need to be different. ABS is a math operation. It expects a source and destination. 

Share this post


Link to post
Share on other sites

That's what I thought, but as I was going to put the instruction in, the thought occurred to me that it might accept the same tag for both.

Share this post


Link to post
Share on other sites

It would be kind of interesting to see what happened but not on a machine or process lol

It would be like using an add instruction and calculating X = X +1 except of course ABS would just strip the decimal places from a real and do nothing to an integer. Really fast unless you controlled how often it performed the function

Share this post


Link to post
Share on other sites

Yeah I knew with something like an ADD instruction like what you mentioned(X=X+1) would cause an infinite loop though presumably it would error out and not compile that in the first place, but since all the ABS instruction is doing is essentially just stripping off the negative symbol I don't see how(logically speaking) that would cause a problem. 

But yeah I didn't want to experiment on a running process so that's why I asked first :)

Share this post


Link to post
Share on other sites

Oops. My bad. You are correct, it makes it a positive number not strips the decimal places

The thing I'm not following is how you are populating the input tag. In theory, if you did something like

Test for new value

Shift new value to tag

Perform ABS on the tag (logically only let it run when there is a new value

Shift result to a different tag (or not if it doesn't matter)

Loop back

Then I suppose it wouldn't matter.

I've typically just used it like so: Tag1 := ABS(Tag2) or something like that. 

I think this is a good question...

Share this post


Link to post
Share on other sites

We run rolls of a flat extruded rubber product. At our Winder machine we use two different devices to measure the length of our rolls, one is a laser pointed at the material and the other is a physical encoder wheel. The point of the logic I'm working with is to subtract the values from each device and use that result to set up a trigger point in case one of them starts to exhibit problems. So I wrote some logic to do the math and obviously I needed to be sure I have a positive number all the time.

This is what I wound up doing:

Untitled.jpg

My thought was that maybe I could skip having to use that HMI_REALS[10] tag.

Edited by kcox1980

Share this post


Link to post
Share on other sites

Are you licensed for Structured Text?

If ABS(Wdr_Len_Wheel_Laser_Diff) > HMI_Real[0]; <--- or just a constant like 0.4

THEN 

Alarms[133] := 1;

Else

Alarm{133] := 0;

End_If;

You could also use the CPT block. Make a new rung and type CPT on top of it. In both cases you would want to latch Alarms[133] with itself like you did in rung 134 only no GRT box

Edited by Michael Lloyd

Share this post


Link to post
Share on other sites

I'm not at the level to be messing around with Structured Text. My main PLC background is with Mitsubishi and I've only been at this job for about 3 months so I'm basically self-taught as far as Allen Bradley is concerned at this point. I don't even have anyone to bounce ideas off of because I'm the only Process Technician we have which is why you'll see me here from time to time asking basic questions like this. I'm actually starting my Basic class next week though and I've got the Intermediate and Advanced classes all next month to get me caught up though.

Share this post


Link to post
Share on other sites

I understand. I was just trying to help you cut down on tag count. 

Just a heads up, when I first started with CLX (longer ago than I care to admit) I made tags like you do:

This_Is_a_tag_for_something_and_I_don't_want_to_forget_what_it_is

which is = to way too much typing. Typing takes time. Time is money. Your better off documenting the tag in the description and calling it WLWLD (Wire Length Wheel Laser Differential) or something simple like that. The Description will show up when you use the tag in ladder.

It's especially important if a tag is going to be used in an HMI. I make use of UDT's and in those I've even trimmed a tag called Timer1 to T1. My motor UDT has T0 thru T10 in it. Sometimes I used all of the timers (start delay, shutdown delay, failed to start, failed to stop... all kinds of stuff that is associated with a specific motor.

I never went to an AB class but I started on S7-300 and S7-400. Actually I started with Direct Logic, SLC, Siemens S5, and TI-505. Then went to S7. Then CLX. The transition from S7 to CLX was easy. The transition to S7 required a 2 weeks school and then baptism by fire. We started building burner management systems. Lots of them...

1 person likes this

Share this post


Link to post
Share on other sites

Haha it's funny you mention that about tag names. Mitsubishi doesn't use a tag system, only a non-descriptive address, so tags are fairly unfamiliar to me. That long tag you're referring to, Wdr_Len_Wheel_Laser_Diff, was actually one of the first ones I created a couple weeks after I started here(I was using it for something else). The other tag there, HMI_REALS was actually the most recent tag I've created. So you look at the difference there and I think that's a pretty good metaphor for my progression since I've been here.

CLX isn't totally new to me, in college I had 2 semesters of Logix500, then about a year after I graduated I worked at an integrator that used 5000. The only thing I had to do there that was PLC related though was to download a pre-made project after I wired up the machines. I spent about a year and a half there and then I got a job in maintenance at a place that exclusively used Mitsubishi PLC's and there I had a lot of freedom to hook up a machine and watch the logic run. Eventually I got confident enough to start making changes and after 3 years or so I had grown to one of the top PLC guys we had there. So I feel like I know the fundamentals of how ladder logic works, but I'm still adapting my skill set over to the different platform.

Share this post


Link to post
Share on other sites

Yeah... tagnames were the evil thing that didn't make sense when I first moved to S7. I can think of more than one location that I would like to go back and "fix" lol

I'm all in now but I'm stingy with my tagnames. I hate working on the legacy stuff. Actually. No I don't. I just whine about it lol Working on the old stuff keeps the brain sharp and makes me appreciate the new stuff more. 

The "system" that I use now came about because I needed a way to develop the program and HMI very, very quickly. I worked on the Eagle Ford boom and the PL company that I work for was building big, up to 7500HP pump stations, 3 and 4 a year PLUS interconnects. A coworker / friend and I spent 3 years working really long hours to build a SCADA system from nothing. I designed the systems and programmed the PLC's and he built the ClearSCADA interface. He could've done what I was doing but not vice versa. He was and still is an amazing ClearSCADA programmer. By year 4 he was promoted to a manager and I had to learn the graphic programming too. I was used to Wonderware of RSView but CS is a lot different (and better IMHO). I never have liked the graphic side of the business. I call them cartoons lol. But it's part of the deal. In the end there were 53 PLC programs with matching graphics written in about 4 years. We got it down to less than 1 week per station (lots of drag and drop). Most big stations had up to 1,000 IO points. One station has about 1,500. The interconnects were much easier with only 30-50 points or less.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now