Author Topic: Scale factor of ChartBySampling  (Read 1983 times)

EchoBurst

  • Newbie
  • *
  • Posts: 7
    • View Profile
Scale factor of ChartBySampling
« on: May 15, 2017, 09:45:38 AM »
Hello Archie, this program is great and i would like to thank you for your efforts.
I have a problem with scale factor of ChartBySampling. My data that read from  plc is larger x10 times than actual value because of the plc. For example, temperature is 20.0 celcius and I read it 200. When I was using the scale factor of ChartBySampling 0,1 then the value is goes 1. or scale factor 0,5 then value goes 5. This feature is working without problems with Labels or analog value displays, but not ChartBySampling.Is there any solution for this?
Thanks again.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Scale factor of ChartBySampling
« Reply #1 on: May 15, 2017, 10:01:12 AM »
I tried this out and for me it is working as expected. Is the attached picture the way you set your ScaleFactor? What version of AdvancedHMI are you using?
« Last Edit: May 15, 2017, 10:02:54 AM by Archie »

EchoBurst

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Scale factor of ChartBySampling
« Reply #2 on: May 15, 2017, 10:29:38 AM »
Version is 3.99w . I cannot set the scale factor (0.1). It says "0.1 is not a valid value for Double." but i can set (0,1). 

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Scale factor of ChartBySampling
« Reply #3 on: May 15, 2017, 10:43:07 AM »
Does the same register scale correctly with an AnalogValueDisplay?

EchoBurst

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Scale factor of ChartBySampling
« Reply #4 on: May 15, 2017, 10:52:13 AM »
Oh sorry it also doesn't work with Analog Value Display. BasicLabel works. Same register "32537"

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Scale factor of ChartBySampling
« Reply #5 on: May 15, 2017, 11:47:06 AM »
Is the register a 16 bit integer?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Scale factor of ChartBySampling
« Reply #6 on: May 15, 2017, 01:32:54 PM »
I tried with both a Chart and AnalogValueDisplay using the same address you used and still getting the expected results. Is your register possibly a 32 bit or floating point?

EchoBurst

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Scale factor of ChartBySampling
« Reply #7 on: May 16, 2017, 02:18:00 AM »
I think it is 16 bit integer not a doubleword and I am sure that it is not floating point.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Scale factor of ChartBySampling
« Reply #8 on: May 16, 2017, 03:43:58 AM »
Add a BasicLabel to the form and put 32527 in PLCAddressValue. What does it show for the value when you run the application?

EchoBurst

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Scale factor of ChartBySampling
« Reply #9 on: May 16, 2017, 04:29:49 AM »
Sure. Same register. Same scale factors.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Scale factor of ChartBySampling
« Reply #10 on: May 16, 2017, 04:57:04 AM »
We are going to have to get deep into the code to try to figure this out. Try this:

- Use only a single AnalogValueDisplay on the form and no other objects
- In Solution Explorer, expand down the AdvancedHMIControls project
- Under that, right click SubscriptionHandler.vb and select View Code
- Go to line 292 and look for this line of code:
Code: [Select]
v = CStr(a.SubscriptionDetail.ScaleFactor * Value + a.SubscriptionDetail.ScaleOffset)
- Put a breakpoint at that line by clicking in the left margin and you will get a red dot
- Run the application
- When it stops at that breakpoint, hover your curser over ScaleFactor and Value to see what the values are (They should be 0.1 and 292)
- Press F10 to step to the next line of code
- Hover your mouse over v to see what the resulting value is

EchoBurst

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Scale factor of ChartBySampling
« Reply #11 on: May 16, 2017, 07:32:56 AM »
a.SubscriptionDetail.ScaleFactor = 0
Value = 292
a.SubscriptionDetail.ScaleOffset = 1 for scale factor 0,1  because of this  v=1.
I realized what the problem is. For example, If I set the scale factor 1,5  at the breakpoint scale factor become 1 and scale offset become 5. I think that comma between 1 and 5 is the problem. I cannot use dot because program says that "not valid value for double".

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Scale factor of ChartBySampling
« Reply #12 on: May 16, 2017, 01:59:40 PM »
You are exactly right. The object known as the type converter that parses values only looks for a comma. It is not global friendly. I will post a patch tonight for you to try.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Scale factor of ChartBySampling
« Reply #13 on: May 16, 2017, 06:00:21 PM »
- Download and extract Patch 4 for V3.99w

https://sourceforge.net/projects/advancedhmi/files/advancedhmi/3.5/Patches/

- Open your solution in Visual Studio
- In Solution Explorer expand down the AdvancedHMIDrivers project
- Right the Support folder and select Add Existing
- Browse to and select the file you downloaded and extracted
Make sure it asks you to replace the file
- Rebuild the solution

EchoBurst

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Scale factor of ChartBySampling
« Reply #14 on: May 17, 2017, 02:48:07 AM »
Hello Archie,
I did exactly what you said and I got this error. I cannot write the register adress.