![]() ![]() |
I am trying to implement remote metering using socket in vb 6.0 from different IPs of LAN. But the problem is in some cases getting negative value for big readings. In some cases results are abnormal.
I have used SerialServer(HMS) modbus RTU and L&T meters with RS 485.
Pl help me.
Otherwise advice for better program in VB6.0 or other.
I have used SerialServer(HMS) modbus RTU and L&T meters with RS 485.
Pl help me.
Otherwise advice for better program in VB6.0 or other.
![]() ![]() |
You are probably reading integers and need to use long integers.
![]() ![]() |
Older Visual Basic (& Python & many 'modern' human-oriented languages) lack the notion of 'unsigned integer'.
So by default, if you convert a 16-bit integer to VB, you'll see -32768 to 32767. This is problem if 0xFFFF means 65,535 and NOT -1.
You should do some Google/Bing research on importing data into VB. Since the Modbus message really comes in as a binary string, you probably have to manually convert the 2 (or 4) bytes into an Integer if 16-bit/2-byte as the VB Integer is signed 32-bit, or Long if 32-bit/4-byte as the VB Long Integer is signed 64-bit.
Now I think around VS 2005 they introduced the types of UInteger and ULong, but you are safer to use normal Integer & Long since not all VB add ons will be expecting unsigned data.
So by default, if you convert a 16-bit integer to VB, you'll see -32768 to 32767. This is problem if 0xFFFF means 65,535 and NOT -1.
You should do some Google/Bing research on importing data into VB. Since the Modbus message really comes in as a binary string, you probably have to manually convert the 2 (or 4) bytes into an Integer if 16-bit/2-byte as the VB Integer is signed 32-bit, or Long if 32-bit/4-byte as the VB Long Integer is signed 64-bit.
Now I think around VS 2005 they introduced the types of UInteger and ULong, but you are safer to use normal Integer & Long since not all VB add ons will be expecting unsigned data.
![]() ![]() |
Your use of this site is subject to the terms and conditions set forth under Legal Notices and the Privacy Policy. Please read those terms and conditions carefully. Subject to the rights expressly reserved to others under Legal Notices, the content of this site and the compilation thereof is © 1999-2013 Nerds in Control, LLC. All rights reserved.
Users of this site are benefiting from open source technologies, including PHP, MySQL and Apache. Be happy.
Fortune
Spouse, n.:
Someone who'll stand by you through all the trouble you
wouldn't have had if you'd stayed single.

Servo, stepping motor control, analog & web HMI in one system!
Control.com is the largest Automation community on the web. Learn how to advertise here now...








on 19 October, 2012 - 2:37 am