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: 946
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: 946
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: 946
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: 267

Currently Online:
14 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 122

pramanj: 86

ibrahim: 74

rocket science: 65

kapsl: 57

gjevremovic: 49

Sabari: 46

Xavier: 42

fred: 41

TimK: 41

Member Stats:

Guest Posters: 0

Members: 3344

Moderators: 17

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1300

Posts: 5561

Newest Members:

UPtato42, fblvicky6629601, elliebloomer44, Manuelagibe, justinafavenc54, sarlaman9, nancymcneal1, elztaim591797, JeffreyAidet, sameisenhower7

Moderators: Jouni Aro: 946, Otso Palonen: 32, Tuomas Hiltunen: 5, janimakela: 0, Pyry: 1, Terho: 0, Petri: 0, Bjarne Boström: 836, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 25, Teppo Uimonen: 21, Markus Johansson: 41, Niklas Nurminen: 0, Matti Siponen: 221, Lusetti: 0

Administrators: admin: 1