Rx3i/quickpanel+ VB Script



Code (Filename testing.vbs):
Function Low16(txt)
Dim i16
i16 = CInt(txt) ''' Throws an error if txt is
''' EITHER txt is not a decimal number
''' OR is outside valid Int range [-32768:+32767]

Low16 = CLng(i16) And 65535 ''' Cast 16-bit Int to 32-bit Long and mask the
''' high 16 bits to effectively convert to unsigned

'Low16 = CLng(i16) And CLng(&H0000FFFF ) ''' This apparently sign-extends the Hexadecimal
''' constant &H0000FFF and so does not work
End Function

WScript.StdOut.Write "Enter the value:"
RawTextLine = WScript.StdIn.ReadLine
WScript.StdOut.WriteLine " You entered: " & RawTextLine
WScript.StdOut.WriteLine " As an Unsigned 16-bit integer, that would be: " & CStr(Low16(RawTextLine))


Testing in console (Windows CMD):
C:\...>cscript //nologo testing.vbs
Enter the value:0
You entered: 0
As an Unsigned 16-bit integer, that would be: 0



Enter the value:32767
You entered: 32767
As an Unsigned 16-bit integer, that would be: 32767



Enter the value:32768
You entered: 32768
c:\Users\drbitboy\Downloads\testing.vbs(3, 3) Microsoft VBScript runtime error: Overflow: 'CInt'




Enter the value:-32769
You entered: -32769
c:\Users\drbitboy\Downloads\testing.vbs(3, 3) Microsoft VBScript runtime error: Overflow: 'CInt'




Enter the value:-32768
You entered: -32768
As an Unsigned 16-bit integer, that would be: 32768



Enter the value:-32767
You entered: -32767
As an Unsigned 16-bit integer, that would be: 32769



Enter the value:-1
You entered: -1
As an Unsigned 16-bit integer, that would be: 65535

 


Code (Filename testing.vbs):
Function Low16(txt)
Dim i16
i16 = CInt(txt) ''' Throws an error if txt is
''' EITHER txt is not a decimal number
''' OR is outside valid Int range [-32768:+32767]

Low16 = CLng(i16) And 65535 ''' Cast 16-bit Int to 32-bit Long and mask the
''' high 16 bits to effectively convert to unsigned

'Low16 = CLng(i16) And CLng(&H0000FFFF ) ''' This apparently sign-extends the Hexadecimal
''' constant &H0000FFF and so does not work
End Function

WScript.StdOut.Write "Enter the value:"
RawTextLine = WScript.StdIn.ReadLine
WScript.StdOut.WriteLine " You entered: " & RawTextLine
WScript.StdOut.WriteLine " As an Unsigned 16-bit integer, that would be: " & CStr(Low16(RawTextLine))


Testing in console (Windows CMD):
C:\...>cscript //nologo testing.vbs
Enter the value:0
You entered: 0
As an Unsigned 16-bit integer, that would be: 0



Enter the value:32767
You entered: 32767
As an Unsigned 16-bit integer, that would be: 32767



Enter the value:32768
You entered: 32768
c:\Users\drbitboy\Downloads\testing.vbs(3, 3) Microsoft VBScript runtime error: Overflow: 'CInt'




Enter the value:-32769
You entered: -32769
c:\Users\drbitboy\Downloads\testing.vbs(3, 3) Microsoft VBScript runtime error: Overflow: 'CInt'




Enter the value:-32768
You entered: -32768
As an Unsigned 16-bit integer, that would be: 32768



Enter the value:-32767
You entered: -32767
As an Unsigned 16-bit integer, that would be: 32769



Enter the value:-1
You entered: -1
As an Unsigned 16-bit integer, that would be: 65535



thanks for your comment. I'll take a look and go through it.
 
I think you mean this. But i can’t found it in the HMI only in the plc


I can only put the uint in the plc. It is not listed in the HMI.



Unfortunately I can't do it. I can't set the int to a uint. In the PLC it is possible to convert the int to uint. but if I have to create a tag for the script and the hmi then I cannot select uint. only an int. anyone have an idea?
 


Code (Filename testing.vbs):
Function Low16(txt)
Dim i16
i16 = CInt(txt) ''' Throws an error if txt is
''' EITHER txt is not a decimal number
''' OR is outside valid Int range [-32768:+32767]

Low16 = CLng(i16) And 65535 ''' Cast 16-bit Int to 32-bit Long and mask the
''' high 16 bits to effectively convert to unsigned

'Low16 = CLng(i16) And CLng(&H0000FFFF ) ''' This apparently sign-extends the Hexadecimal
''' constant &H0000FFF and so does not work
End Function

WScript.StdOut.Write "Enter the value:"
RawTextLine = WScript.StdIn.ReadLine
WScript.StdOut.WriteLine " You entered: " & RawTextLine
WScript.StdOut.WriteLine " As an Unsigned 16-bit integer, that would be: " & CStr(Low16(RawTextLine))


Testing in console (Windows CMD):
C:\...>cscript //nologo testing.vbs
Enter the value:0
You entered: 0
As an Unsigned 16-bit integer, that would be: 0



Enter the value:32767
You entered: 32767
As an Unsigned 16-bit integer, that would be: 32767



Enter the value:32768
You entered: 32768
c:\Users\drbitboy\Downloads\testing.vbs(3, 3) Microsoft VBScript runtime error: Overflow: 'CInt'




Enter the value:-32769
You entered: -32769
c:\Users\drbitboy\Downloads\testing.vbs(3, 3) Microsoft VBScript runtime error: Overflow: 'CInt'




Enter the value:-32768
You entered: -32768
As an Unsigned 16-bit integer, that would be: 32768



Enter the value:-32767
You entered: -32767
As an Unsigned 16-bit integer, that would be: 32769



Enter the value:-1
You entered: -1
As an Unsigned 16-bit integer, that would be: 65535


I can't figure this out. I can't do it with the vbscript. too complicated.
 
If I'm interpreting your initial post correctly, the variable is correctly defined in the PLC target as well as in the HMI target, since it displays the value you expect to see in both the programming software and on the HMI screen. If that's the case, there's something in the VBScript that is not correctly interpreting the pattern of bits and you should concentrate your debugging efforts there.

Correct. I think so too. Even when I access the HMI online, it shows the correct value. this is frustrating. The script was written by an old Ge Fanuc employee, but he couldn't figure it out himself.

384E8370-3086-40A0-AB49-187C8B2FDEE0.jpeg
 
Going back to the images you posted in your first post in this thread.

The third image shows what I believe is a line from the CSV file. Is that correct? If so, what are you using to view the CSV file?

The image shows 3 entries as negative numbers. You flagged those three entries.
The first negative number is -30157. If the bit pattern were interpreted as unsigned integer the number would be 35379.
The third negative number is -30702. If the bit pattern were interpreted as unsigned integer the number would be 34834.
Are those positive values greater than 32767 the values you were expecting to see?

If I'm totally misinterpreting, could you post an example showing the value of the tag as viewed in a PLC variable reference table, the value of the same tag as viewed on the HMI screen, and the value as viewed in the CSV file.
 
Going back to the images you posted in your first post in this thread.

The third image shows what I believe is a line from the CSV file. Is that correct? If so, what are you using to view the CSV file?

The image shows 3 entries as negative numbers. You flagged those three entries.
The first negative number is -30157. If the bit pattern were interpreted as unsigned integer the number would be 35379.
The third negative number is -30702. If the bit pattern were interpreted as unsigned integer the number would be 34834.
Are those positive values greater than 32767 the values you were expecting to see?

If I'm totally misinterpreting, could you post an example showing the value of the tag as viewed in a PLC variable reference table, the value of the same tag as viewed on the HMI screen, and the value as viewed in the CSV file.

Yes that is correct. that is the cvs file that creates the vb script and puts it on the sd card in the hmi. I can access it remotely using filezilla, for example. then create an excel file from it. As far as the first value you mention is concerned, it is also correct. Only the other 354834 you mention must be 145783. so more than that 32767. I will go online tomorrow and take pictures of the values ​​of the tags to give you a clearer picture.
 
My point is that the 16-bit integers -30157 and 35379 are identical when you look at the 16 bits that comprise them. The bits are:

1000 1010 0011 0011

The difference is in the interpretation of the meaning of the bits. Whatever you are using to view the CSV file may be interpreting the bits differently than the PLC and HMI.

As far as values like 354835 and 145783 are concerned, you need to be using a 32-bit data type to represent those values. And I don't see those values anywhere in the images you posted.
 
I went online with PLC and with the QuickPanel then with the Filazilla to show the CVS value. The following strikes me. When I go online with the quickpanel/hmi, I see that the value at the hmi is wrong, see photo (online quickpanel inspector from abs_prog2 and HMI_totaal_aant). But when I go online with the PLC, all values ​​are displayed correctly. (see photo) but with the html of the quickpanel (from emerson), the quickpanel shows hmi_total 17551 and rx3i total 148623. I also opened the cvs file with excel and it gives the incorrect values. I will post the other photos below. they don't fit here.

CCDA6638-5E14-42CF-AEBC-262D1497B2C5.jpeg 193180C0-FA8F-43EE-BD85-FD9D013C7EA8.jpeg 06654DE4-198C-469B-B458-4B3AC3325F6E.jpeg 19E534C6-D9BB-4236-A331-1A952162B2D0.jpeg ACD3465D-6DCE-4705-8874-ECE9427A8901.jpeg
 
My point is that the 16-bit integers -30157 and 35379 are identical when you look at the 16 bits that comprise them. The bits are:

1000 1010 0011 0011

The difference is in the interpretation of the meaning of the bits. Whatever you are using to view the CSV file may be interpreting the bits differently than the PLC and HMI.

As far as values like 354835 and 145783 are concerned, you need to be using a 32-bit data type to represent those values. And I don't see those values anywhere in the images you posted.

there is only 1 value that exceeds 100.000. the other one is not 354835 but 35483. is dint not enough?

the tag/varibale that is created in the hmi and then used in the script cannot be used as a data type unsigned integer. But this is possible with the PLC, the value visible on the HMI screen is correct. So it's really the tag/variable that is created in the hmi for the script.
 
I begin to see what's going on, and you may have a bug to report to Emerson.

The first attached image showing the value in the 'Properties' window of PAC Machine Edition is only showing the value of the sixteen bits in %R2305, despite the fact that the variable is defined as a DINT and spans the two addresses %R2305 and %R2306. I'm working with version 7.o of GE's Proficy Machine Edition and when I go online with a 90-30 CPU351 and look at the properties of a DINT variable the 'Current Value' field displays the correct 32-bit value.

So far, that's all I've looked at.

Instead of looking at variable values in the Properties window, try opening a reference view table or a data watch window. In the reference View Table you have control over how the data is displayed.
 
Please ignore the first part of my previous post and try to follow this:

The attached image that you called 'Online with PLC Rx3i" showing the PLC variable abs_aant_prog2, a DINT addressed to %R2305.
A DINT is a 32-bit signed variable, with the most significant bit (bit 31) as the sign bit, zero meaning positive, 1 meaning negative. This one occupies two %R addresses, %R2305 and %R2306.
By convention, the most significant bit is on the left.
The bit pattern in %R2305 is 1000 1101 1011 1010 this comprises bits 15 through 0
The bit pattern in %R2306 is 0000 0000 0000 0000 this comprises bits 31 through 16
Bit 31 being zero, this represents the positive value 36282

An INT is 1 16-bit signed variable with the most significant bit (bit 15) as the sign bit, zero meaning positive, 1 meaning negative.
When you interpret the bit pattern in %R2305 as an INT, now bit 15 is the sign bit, and you get a value of -29254, which is apparently what is happening in the image you have labeled as 'Online with Quickpanel'.
Is your VBScript writing 32 bits to the CSV file or only 16 bits?
 
Please ignore the first part of my previous post and try to follow this:

The attached image that you called 'Online with PLC Rx3i" showing the PLC variable abs_aant_prog2, a DINT addressed to %R2305.
A DINT is a 32-bit signed variable, with the most significant bit (bit 31) as the sign bit, zero meaning positive, 1 meaning negative. This one occupies two %R addresses, %R2305 and %R2306.
By convention, the most significant bit is on the left.
The bit pattern in %R2305 is 1000 1101 1011 1010 this comprises bits 15 through 0
The bit pattern in %R2306 is 0000 0000 0000 0000 this comprises bits 31 through 16
Bit 31 being zero, this represents the positive value 36282

An INT is 1 16-bit signed variable with the most significant bit (bit 15) as the sign bit, zero meaning positive, 1 meaning negative.
When you interpret the bit pattern in %R2305 as an INT, now bit 15 is the sign bit, and you get a value of -29254, which is apparently what is happening in the image you have labeled as 'Online with Quickpanel'.
Is your VBScript writing 32 bits to the CSV file or only 16 bits?

okay, the funny thing is that the photo shows a dint and not an int. the script therefore also adopts this value. honestly I don't know if the script writes 32 or 16bit. Can I find that somewhere?
 
honestly I don't know if the script writes 32 or 16bit. Can I find that somewhere?
Start with a value of 65537 in a DINT variable in the PLC. In the PLC, that DINT will use two consecutive %R addresses. If you open a reference view table in PME and look at the %R address, you'll see a value of 1 each of the two %R addresses involved. Now right click on the first %R address, select "Format View Table" and select DWORD as the format. You'll see the value is now 65537. Now write that DINT to the CSV file and see what value you get. If it's 65537, the script wrote a DINT, if it's 1, the script wrote an INT.
 

Similar Topics

Hi all, I'm trying to setup communications between an RX3i PLC and a GE QuickPanel View touchscreen. I have a CPU315 (IC695CPU315) with an...
Replies
7
Views
4,763
I have a system using Rx3I CRU320 redundant CPU with Proficy Machine Edition Software. In the hardware configuration of each CPU module, under...
Replies
14
Views
389
Hi, we are using Rx3i CRU320 redundant PLC system and we noticed a discrepancy between Primary and Secondary controller. Couple of variables (DI)...
Replies
8
Views
284
Hi there, I'm doing some extensive testing and commissioning with a slew of new Emerson PACSystems RX3i PLCs. It would be convenient to...
Replies
5
Views
106
Hi there, Trying to get some ascii serial communications working via RS485 (COMMREQ functions). I have attached our wiring for the COM2...
Replies
1
Views
977
Back
Top Bottom