Member Login
member
passwd
remember me on
this computer.

- join now -
- forgot username or password? -

Search

Jump to a Date

Sponsored Communities
Cool stuff
Select a topic of interest:
...and press:
Neat Stuff
Control.com Stuff

Visit our shop for nerds in control lifestyle products.

Fortune
While having never invented a sin, I'm trying to perfect several.
RSS Feed
RSS feed Use this link to get an RSS feed of the Control.com article flow, for private, non-commercial use only:
www.control.com/rss/
To get a personalized feed, become a member at no cost.
Select a Page Style
Select one of the following styles:
- BluFu
- Classic
(cookies required)
advertisement
from the Automation List department...
How can you mask an output card in Step 7?
PLCs and related questions. topic
Posted by o4a0e1 on 8 August, 2008 - 7:45 pm
G'day,

I'm new to this forum and to Step 7, so Hi to all and thx Siemens... What I'm trying to do is use 3 outputs on a card as a BCD to another device. I'm getting some obvious issues and would like to find out the best way to overcome them.

I'm using a S7-300 PLC and programming in statement list. I'm loading a decimal value, when an alarm happens, and transferring it to the output byte, which works well in the simulator. Now if I do this with the actual PLC... the rest of the card becomes useless because I'm writing to the whole card during my load and transfer statements, which means the other outputs are written to as well. I tried to make sense of the help file with the AW (and word) statement, as I have seen something like this before for "masking out" part of the byte so the rest of the card works for anyone else who comes along later and programs, but I couldn't do it. Is there an easier way? If not... Does AW work in a binary mode? Thx.


Posted by Michael Griffin on 9 August, 2008 - 1:25 pm
A M1.0
= Q1.0

A M1.1
= Q1.1

A M1.2
= Q1.2

What's wrong with that?


Posted by o4a0e1 on 14 August, 2008 - 1:12 am
Hi,

Thanks for your reply.

I was going to do it that way, but I would have used a fair few m bits... I'm using 3 outputs as a BCD to another small PLC... So if I want to want to turn on say output 3 on card 7,

L 8
T QB7

and then for another alarm to the second PLC could be outputs 3 and 1 on card 7,

L 10
T QB7

As outputs 4 to 7 are spare at the moment, it's not a problem, but if I use them later, then the Load and Transfer will overwrite the new code... So I need to use the AW (and word) command, but I'm not sure how it works. I think it will mask out the outputs that I'm not using, so that they can be written to later without any problems...

Cheers


Posted by Michael Griffin on 15 August, 2008 - 1:59 am
The conventional way of modifying certain bits in a word without affecting the rest is to use an AND with mask followed by an OR.

For example:

Temp1 = Destination AND 0x07
Temp2 = Source AND 0xF8
Destination = Temp1 OR Temp2

With a PLC though, nobody will thank you for doing it this way because it won't show up in a cross reference in an obvious way.


Posted by Luca Gallina on 16 August, 2008 - 7:04 pm
dear Michael,
I disagree with your last statement.

Masking an output byte is a commonly used method, regardless in PLCs or any other platform, and it's more elegant than chopping a number into a series of flags to be output separately. We just should do the masking in the proper place and possibly comment it out clearly.

If it were up to me, a mask using AND and OR instructions (just like your example) is the "obvious" way to go ;-)

Kind regards
Luca Gallina


Posted by David Adams on 10 August, 2008 - 3:45 pm
First, transfer the decimal value to a storage byte. Next use another storage byte to hold the results of your bit manipulation that will be writing to the other 5 output bits. Finally and both storage bytes together an transfer the results to the output byte.

David Adams

From Control Engineering magazine...
Related articles from Control Engineering magazine
Above articles copyright 2009 Reed Business Information. Subject to its Terms of Use.
Your use of this site is subject to the terms and conditions set forth under Legal Notices and the Privacy Policy. Please read those terms and conditions carefully. Subject to the rights expressly reserved to others under Legal Notices, the content of this site and the compilation thereof is © 1999-2009 Control Technology Corporation. All rights reserved.

Users of this site are benefiting from open source technologies, including PHP, MySQL and Apache. Be happy.

Internet Explorer 6.0 Fix

Advertisement
Our Advertisers
Help keep our servers running...
Patronize our advertisers!