Author Topic: Error writing to bit 31 of DINT  (Read 1449 times)

sb

  • Newbie
  • *
  • Posts: 4
    • View Profile
Error writing to bit 31 of DINT
« on: January 21, 2016, 05:16:25 PM »
I am using version 3.99a of AdvancedHMI and I have a pilot light that toggles the bits of a DINT array on ControlLogix. It is able to display the status of all of the bits (0-31), but when writing to bit 31 of each DINT,  I receive a message that says "WRITE FAILED! Input string was not in a correct format."

For instance, I can write to bits Output[0].0 through Output[0].30 or Output[1].0 through Output[1].30, but it fails to write to Output[1].31 and Output[1].31. I did a test and the same is true for bit 31 of a DINT (i.e. Output.31). Solution?

Thanks.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Error writing to bit 31 of DINT
« Reply #1 on: January 24, 2016, 09:11:18 PM »
Try this

- In Solution Explorer, go to the AdvancedHMIDrivers project
- Open \AllenBradley\EthernetIPforCLXCom.vb
- Go to line 395 and look for this code:
Code: [Select]
If Requests(TransactionByte)(0).Response.Values.Count > numberOfElements Then
- Replace that line of code with this:
Code: [Select]
If (Requests(TransactionByte)(0).AbreviatedDataType = &HD3 Or (Requests(TransactionByte)(0).BitNumber >= 0 And Requests(TransactionByte)(0).BitNumber < 65)) Then

sb

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Error writing to bit 31 of DINT
« Reply #2 on: January 25, 2016, 10:17:51 AM »
Thanks! That fix does allow bit 31 to be toggled ON and OFF. There is now a new issue where as long as the DINT value is 0, bit 0 can be toggled ON and OFF. But, if the DINT value is not 0, bit 0 cannot be toggled ON. However, it can be toggled OFF if it was already ON. Previously, this issue did not exist.

sb

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Error writing to bit 31 of DINT
« Reply #3 on: January 25, 2016, 11:59:48 AM »
I think I found the error. Instead of:
Code: [Select]
If (Requests(TransactionByte)(0).AbreviatedDataType = &HD3 Or (Requests(TransactionByte)(0).BitNumber >= 0 And Requests(TransactionByte)(0).BitNumber < 65)) Then

Line 395 should be:
Code: [Select]
If (Requests(TransactionByte)(0).AbreviatedDataType = &HD3 Or (Requests(TransactionByte)(0).BitNumber > 0 And Requests(TransactionByte)(0).BitNumber < 65)) Then

Stepping through the logic, the value returned on Line 398 for bits 1 through 31 is "True" or "False". Bit 0 returns the value of the DINT (e.g. -2), which gets translated to a "True" when it returns to the MomentaryButton_MouseDown routine of the PilotLight.vb. Changing it from ">=" to ">" forces it to convert the value to bits when BitNumber = 0. Making this code change has fixed the errors.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Error writing to bit 31 of DINT
« Reply #4 on: January 25, 2016, 06:29:36 PM »
I looked further into this and found the root of the problem.

- Go to line 812 in EthernetIPforCLXCom.vb
- Add an "=" to the line of code, so it becomes this:
Code: [Select]
If BitIndex >= 0 And BitIndex < BitsPerElement Then

sb

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Error writing to bit 31 of DINT
« Reply #5 on: January 26, 2016, 09:29:15 AM »
I removed my "fix" and tried yours and it works! I think I'll go with your version. Not fully understanding how the code works, I was worried that I might have broken something else with my fix.

Thanks for your help!

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Error writing to bit 31 of DINT
« Reply #6 on: January 26, 2016, 09:38:02 AM »
The purpose of most of that code is to accommodate BOOL arrays which are kind of exception to all the rules. I haven't tested yet, but those changes may have adverse affects when reading BOOL arrays.