Dword comparation/conversion [Simatic S-300]

sinkoviak

Member
Join Date
Dec 2015
Location
Ljubljana
Posts
7
Hello,

i have a DWORD number, which i need to compare in simatic s-300. How can i convert it to DINT. It seems that MOVE order does not working.

Basically what i need is a SET marker when the DWORD value is bigger than zero.

How can i programm it, please help me.

Thank you all!

Simon
 
Your issue is with Type checking.
Either redefine the DWORD variable as DINT.
Or disable Type Checking in the LAD/STL/FBD-editor.
(Options > Customize > LAD/FBD > Type Check of Addresses)
 
Could you explain more exactly what you need?
I'm guessing you have a hex value in a doubleword and want to compare it to a doubleint value that is sometimes zero?

I attached a simple program that compares to the value 16, there isn't a need to convert though. In the simulator you can display it as a decimal or hex.

You just need to drag the compare block from the right side of the screen.

comp.jpg
 
TNX for answers, Jeebs and Diameter157.

What I have is a piece counter ''RealizedQuantity'', which is stored in DB adress and it is a DWord type [hex value]. I need to know, when the counter is bigger than 0.
Seems that the best solution would be to use a comparator to compare the ''RealizedQuantity'' number with 0, but im having problem with it. Is it even possible to convert DWord to Integer in S-300, to be able to use comparator?

I tried this, its working in simulator, but not on the machine:

L ''RealizedQuantity'' [DB100.DBD114]
T ''RealizedQuantityDINT'' [DB101.DBD36 - created a new adress DINT]
NOP 0

L ''RealizedQuantityDINT''
L ''DINT_0'' [DB101.DBD40 - L#0]
> D
= M 253.5

Any ideas? Thank you...
 
TNX for answers, Jeebs and Diameter157.

What I have is a piece counter ''RealizedQuantity'', which is stored in DB adress and it is a DWord type [hex value]. I need to know, when the counter is bigger than 0.
Seems that the best solution would be to use a comparator to compare the ''RealizedQuantity'' number with 0, but im having problem with it. Is it even possible to convert DWord to Integer in S-300, to be able to use comparator?

I tried this, its working in simulator, but not on the machine:

L ''RealizedQuantity'' [DB100.DBD114]
T ''RealizedQuantityDINT'' [DB101.DBD36 - created a new adress DINT]
NOP 0

L ''RealizedQuantityDINT''
L ''DINT_0'' [DB101.DBD40 - L#0]
> D
= M 253.5

Any ideas? Thank you...
First I think the move from your "dword" to "dint" does nothing special, their bits are the same, only the representation is different.
what values do you see when monitoring online the 'real' plc? are you sure this db101.dbd40 is 0? and why use a variable and not l#0 directly?
 
If some blocks in this CPU has been converted from Step5, it is a possibility that the MB's from 200 to 255 is used as scratchpad memory. Try to use a free Marker outside that range.


And this code must work:

CLR
L "RealizedQuantityDINT"
L L#0
> D
= AFreeMarker

Kalle
 
Tnx for help.

I did what you said, Kalle and if i monitor it online, it seems OK. I an adding the FP and NP for set/rst of merker M 199.3. Does this seems OK to you?

L ''RealizedQuantity'' [DB100.DBD114]
T ''RealizedQuantityDINT'' [DB101.DBD36 - created a new adress DINT]
NOP 0

L ''RealizedQuantityDINT''
L L#0
> D
= M 199.0

A M 199.0
FP M 199.1
S M 199.3

A M 199.0
FN M 199.2
R M 199.3

online.JPG
 

Similar Topics

I'm trying to set alarm as DWord where each bit is individual alarm. So far I have tryed with DWord.0, DWord.1, DWord.2, etc. DWord.L0...
Replies
8
Views
820
Hello, I am using Omron PLC: NX1P2 Software:-Sysmac Studio Plc in which I have to read data from an energy meter over Modbus RTU The data that I...
Replies
3
Views
876
Hello, I am provided with PLC tags with PLC_UDT datatype via symbolic connection. The structure of PLC_UDT (DI_hmi) is: DI_hmi.stat (UDINT)...
Replies
4
Views
1,414
This feels like a simple, elementary question, but I am a Siemens novice and know there are experts here. My S7-1500 project (TIA Portal v17) has...
Replies
10
Views
2,681
I am needing to convert the low DWORD of a timestamp into a LREAL. The DWORD is a 32bit unsigned number. In TwinCat2, I keep getting a negative...
Replies
3
Views
1,676
Back
Top Bottom