Addressing a 'bit' in a dataword with S5

Johnny T

Member
Join Date
Jul 2003
Location
Fife, Scotland
Posts
642
How do I address a bit directly within a dataword in S5.

I know in S7 I could have DB10.DBX50.0

But what is the equivalent in S5?

I'm trying to map a flag into 1 bit of a dataword. So I'm trying to do the following S7 code in S5 for instance..

A M10.0
= DB10.DBX50.0

I know in S5 its
C DB50
A F10.0
= D??50.0

Anyone any ideas whether this is possible or not?

I know I could just load a value into DW50 in order to set that bit but that isn't really what I'm wanting to do.

Also...

Am I right in thinking that in S5 DW0 and DW1 are two separate words and not overlapped like in S7.

In S7 DW0 encompasses byte 0 and byte 1 and DW1 encompasses byte 1 and byte 2 so if you were to write to DW0 and then write to DW1 you would be overwriting the least significant byte of DW0.. is this the same in S5 or not..

Many thanks

JT :)
 
You are right,

C DB10

A F10.0

= D50.0

D0 is a 16 bit word

D1 is the next

only if you use DD (double word) is the next word taken up

DL & DR are the bytes of a DW

i.e. DL50 is left byte of DW50
 
Hi Johnny T

At first, I'am sorry but I have to use "German" commands.
I know in S7 I could have DB10.DBX50.0
But what is the equivalent in S5?
A_DB_10 // Open DB10
U_M_10.0 // And "Flag" 10.0
=_D_25.8 // Control databit 25.8 = DBX50.0


Maybe this helps you to understand the difference between S5 and S7 DB's.
Lets compare S5 and S7 datawords:
________DL__________DR_______________DBB-even____DBB-odd
DW_0_0000_0000_|_0000_0000_____DBW_0_0000_0000_|_0000 0000
DW_1_0000_0000_|_0000_0000_____DBW_2_0000_0000_|_0000 0000

In S5, datawords are from 0 up to 255.
* Dataword, can Read/Write L/T DW x.
* Databyte, -" "- DL x or DR x -> so, you can use words "Left" or "Right" byte.
* Databit, It starts allways from right side of bit (LSB) and ends (MSB). Set first DW-Nro (0-255) dot (.) Bit-Nro (0-15)

S7________S5
DBX1.0_->_D_0.0
DBX0.0_->_D_0.8
DBX51.3_->_D_25.3
DBX50.0_->_D_25.8


BR
-Pete-
 
Last edited:
You can have a DB longer than 255 words but you then haver to address it using 20 bit addressing, you would need to find the location of the db in memory (can't remember how to do it now) then find the offset, you can even determine if a block exists this way as well & if you are clever enough you could make a program modify it'self but I don't recommend it, I once had to find a problem on a 155 where the programmer checked how much room was left in the memory & then generated a DB to fill up the rest of the memory, needless to say you could not do any mods, thiswas for a printer buffer (he also used relative addressing so any changes between would crash it or at the very least cause problems.
 
Parky


So that method would be similar to an area pointer in S7 presumably.

I didn't realise this was possible in S5.

Interesting stuff.

Cheers

JT :)
 
You can have a DB longer than 255 words but you then haver to address it using 20 bit addressing, you would need to find the location of the db in memory

That is true, some CPU's can use more than 255words. Wild guess CPU's 945 and 948 only, I'am not 100% sure?
But anyway, if you don't have a good reason to extend DB lenght over 255 words, I don't recommended to use it. "Simple is nice" ;)
 
Last edited:
Johnny T said:
So that method would be similar to an area pointer in S7 presumably.

I didn't realise this was possible in S5.

The last project I worked on prior to using Step 7 involved some of the more esoteric areas of Step 5 programming (for example scanning code blocks for a particular instruction operand) Although Step 7 provides a "tidier" instruction set, it does not provide the same low level access that you could achieve with Step 5. (Caveat: I'm led to believe that some low level access tools exist for Step 7 but I've yet to hear from anyone who's actualy used them)
 
S5 was a very powerful toy, using the RS area i.e. loading the equivelent MC5 hex code into the RS0 then DO RS0 it would run the instruction, it would be possible to write the complete code in a DB in the MC5 (raw code), then in a loop load each dw in turn & using the RS instruction run the code, I came across some of those instructions on a project I was working on, some code had been written (standard code used by the factory) by an ex siemens engineer.

Don't really see the point unless you want self modifying code as this did, fortunately it was only a few instructions & did not need to get to know it as it worked anyway.

Oh.. what a nightmare if you needed to debug it?????
 

Similar Topics

See the screenshot of EIP tag list. We are trying to read in a digital input that is hard-wired. It is shown here as I31.1. I believe we cannot...
Replies
7
Views
273
I am currently using Micrologix 1100 connected to my pc using RSLinx Lite. I need to file data from Keyence IL series lasers using DL-EP1 module...
Replies
2
Views
1,259
I am working with a Siemens 1515 CPU and I have created a ladder function block to use like an AB Add-On Instruction to control a Danfoss VFD. I...
Replies
6
Views
1,721
Hello everyone... I need to enable a float value(Analog output) through a bit input. Kindly help me to do the same
Replies
1
Views
1,458
I am trying to use indexed addressing to store a long series of bits in a "file" via a bit shift left function in RSLogix 500. The file I want to...
Replies
8
Views
3,894
Back
Top Bottom