Siemens Micro Win S7-200 - Reading bits of a word

Andy S

Member
Join Date
May 2006
Location
England
Posts
40
I’m struggling to read the individual bits of a word with a Siemens S7-200 PLC.
With other PLC types this wouldn’t be an issue but I don’t have much experience with this PLC type.

I’m writing a value (up to 31) into a word (MW10) and I need to map this value to 5 outputs, but I cannot see how to look at the individual bits of the word to do this?

Any help with this would be greatly appreciated.
 
"MD10" is a double-word starting at byte address 10 (10 through 13)
"MW10" is a word starting at byte address 10 (10 and 11)
"MB10" is a byte starting at byte address 10 (only 10)
"M10.0" is Bit0 starting at byte address 10.0
"M10.1" is Bit1 starting at byte address 10.0
 
OpZed said:
"MD10" is a double-word starting at byte address 10 (10 through 13)
"MW10" is a word starting at byte address 10 (10 and 11)
"MB10" is a byte starting at byte address 10 (only 10)
"M10.0" is Bit0 starting at byte address 10.0
"M10.1" is Bit1 starting at byte address 10.0
Already answered above.
M10.0= 10(Word) 0(bit), treat as a Bool
M10.1= 10(Word) 1(bit), treat as a bool
And so on.

M10.0 = 1 ---> Then Output on.
I cannot draw ladder on here like other members
 
Last edited:
Thanks for the reply.
So am I right in saying that if I map the following:

M10.0 to Q0.0
M10.1 to Q0.1
M10.2 to Q0.2
M10.3 to Q0.3
M10.4 to Q0.4

then these outputs will now show the binary value of MW10 (MW10 will always have a value of between 0 and 31)?
 
Though if it exeeds 31 you will have issues.
A value above 31 can also light up bit M10.4 you won't have a way of knowing that unless you utilize all 16 bits in the word.
I'd use at least 8 bits/outputs

0000 0000
!!!! !!!!
7654 3210

Map bit0->output0
bit1->output1
and so on.
Even if you go above 31 you should be covered.
Actually you should be good to go up to 99 (2 digits)
 
0000 0000
!!!! !!!!
7654 3210
3 1

The first 4(0-3) bits will dipsplay your 1
The following 4(4-7) bits will display your 3
 
One thing is wrong in this thread: if you are writing a value of between 0 and 31 to MW10 then the bits M10.0 through M10.4 will always remain at 0. The bits you're looking for are M11.0 through M11.4. MB10 is the high byte of MW10, MB11 is the low byte.

bkottaras, you're confusing the integer 0-31 with the BCD value 0-31. Integer 0-31 fits in 5 bits, for BCD 0-31 you'll need 6 bits.

Kind regards,
 
You are right.
Never paid attention to BCD or Integer, assumed integer.
Andy , what are you trying to do? How do you get the value of 31?
 
Hi bkottaras,

Just to let you know - For this application I'm using MW10 to show the value of a step counter in the PLC software, but there is some handshaking in the form of I/O to the clients PC.

Therefore I know that the count value will only ever reach a maximum value of 31 and the client has assigned 5 outputs to me so that I can send them this value. So it looks as though mapping M11.0 - M11.4 to the relevant outputs will now solve this problem.

Apologies if I didn't make myself clearer to begin with and many thanks for your help with this, it's really appreciated.
 

Similar Topics

Hi, I'm new to this forum and have been programming plc's for about 2 years now. I have done programming and mods on different small systems and...
Replies
3
Views
3,337
Just when you think your problem is solved..... new problem! My Siemens rep came through with with the Step7 Micro/WIN software I needed for a...
Replies
4
Views
6,923
I have an opportunity to quote an HMI project for one of my customers. It's a small project, and the customer is not the type with deep pockets...
Replies
3
Views
24,864
Am I correct to think the Offset is the start and the Number of Elements the end? MB Offset = 14, Number of Elements = 18 Means, MB 14 to MB...
Replies
1
Views
1,675
Can the status of the unit be saved in the L memory so after the unit experiences a power failure, the unit starts up in the last saved status?
Replies
2
Views
1,704
Back
Top Bottom