Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
LongWord values > 2^31 ?
May 2, 2012
14:14, EEST
Avatar
Juergen
Member
Members
Forum Posts: 3
Member Since:
May 2, 2012
sp_UserOfflineSmall Offline

Hello,

is it possible to transfer unsigned 32 bit OPC vars to Delphi unsigned 32 bit (aka Longword) vars? Whenever I try to do this with TPsInteger I receive ‘range check’ exceptions as soon as OPC values become higher than 2^31.

This happens if the OPC’s data type is set to vdtLongWord; if set to vdtInteger there are no exceptions, but, however, the OPC unsigned value becomes a Delphi signed integer. Is there a simple way for a to do longword – longword transfers without additional casts?

Best regards,
Jürgen

May 3, 2012
6:53, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1009
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

TPsInteger is indeed only accepting signed values.

But you could try to use TPsBitSet or TPsState for that.

May 3, 2012
13:32, EEST
Avatar
Juergen
Member
Members
Forum Posts: 3
Member Since:
May 2, 2012
sp_UserOfflineSmall Offline

Hi Jouni,

thanks for reply.

Tried TPsBitSet, TPsStatusBits and TPsVariant, but surprisingly got ‘range error’ exception when highest bit was set.

Moreover the trick stated above by handling PLC data as integer only works for PLC-to-Delphi direction. When data type is set to vdtInteger and integer casted longwords are sent from Delphi to the PLC with MSB set, then the PLC receives wrong values.

Unfortunately our PLC needs longword var communication in both directions. Any ideas?

Best regards,
Jürgen

May 3, 2012
15:02, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1009
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

OK, I see.

If you use vdtInteger, you must probably cast the values yourself. Does this work?

longWordValue := LongWord(PsInteger1.Value);

PsInteger1.Value := Integer(longWordValue) ;

May 4, 2012
7:49, EEST
Avatar
Juergen
Member
Members
Forum Posts: 3
Member Since:
May 2, 2012
sp_UserOfflineSmall Offline

Hi Jouni,

doesn’t work perfectly: reading values is ok, but writing give wrong values at PLC side (eg. trying so send 4.000.000.000 results in 125 at PLC).

If using vdtLongWord then writing values to the PLC is ok, but whenever the value changes at PLC side and must be transferred back to the Delphi application via OPC, then range check exceptions are thrown. There is no need to access the var (like x := PsInteger1.Value) but the simple fact that PSInteger1 is bound to the PsOPCConnector is enough to show this behaviour.

Btw. Setting and reading PLC longword values via an external OPC browser works fine, so the PLC should be ok.

All in all we still have now way to transfer longword values > 2^31…

Best regards and thanks for your help so far,
Jürgen

May 4, 2012
8:40, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1009
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Please, send an email to sentrol-support@prosysopc.com and I’ll see what we can do to improve your situation.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online: Matti Siponen, atdemir
14 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

ibrahim: 75

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 679

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6259

Newest Members:

elviralangwell4, Donnavek, Eddiefauth, DonaldPooma, fidelduke938316, Jan-Pfizer, DavidROunc, fen.pang@woodside.com, aytule

Moderators: Jouni Aro: 1009, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 983, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 321, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1