Zuviel Werbung? - > Hier kostenlos beim SPS-Forum registrieren

Results 1 to 3 of 3

Thread: WinCC, integer, Nachkommastellen

  1. #1
    Join Date
    Erhielt 9 Danke für 7 Beiträge


    Zuviel Werbung?
    -> Hier kostenlos registrieren
    Excuse me for using English.

    It goes about a complex FB (it's a self made HMI -profi- interface to a Sipart DR22 - (it was a LOT of work to make it function some 10 years ago)). This FB has an integer interface, also for the inputs for the sollwert and manual stellwert.

    I use PCS7 to generate the interface variables for this FB (it's giving a structure, NOT allowing scaling of individual values).
    Of course this give me problems with the decimals. It is easy to show an integer using x/10 in the IO field. But my problem is to input a setpoint value from this field from WinCC. I am totally ignorant on scripting, but I have imagined to use the mouseclick to copy the setpoint value into an internal real and use this to manipulate the value (i.e. multiply with f.x. 10) before it is copied back to the original setpoint. Okay, my scripting knowledge limit is exceeded by far... . My intermediate solution is using stupid sliders for manipulating the sollwert/stellwert.

    Have anyone of you solved this problem before?

    Reply With Quote Reply With Quote WinCC, integer, Nachkommastellen  

  2. #2
    Join Date
    Erhielt 1,428 Danke für 1,060 Beiträge


    there are two ways to do this:

    1. Variable scaling in variable properties

    I don't know if this is possible if you are using PCS7, but with raw WinCC you change the datatype of your PLCs integer variable to "Float 32-Bit IEE". And set "Formatanpassung" (don't know how it's named in english version) to "FloatToSignedWord".
    Check "liniear scaling" and set the range for process to 0..10000 and range variable to 0..1000 for factor 10.
    Then you have nothing to do with scripting or something else.

    2. Scripting in I/O field
    Add a C-script to property "outputvalue" like this:
    return GetTagSWord ("IntVarToScale") /10.0;
    Add a C-script on event "inputvalue" like this:
    /* Attention: atof excepts dot as decimal delimiter!
     * If you are using an english version you don't need this.
     * In german we must substitute "," with "." 
    char *st;
    st = strstr(value, ",");
    if (st != NULL) {
      *st = '.';
    SetTagSWord("IntVarToScale", atof(value) * 10);
    Last edited by Thomas_v2.1; 11.12.2010 at 01:01.

  3. Folgender Benutzer sagt Danke zu Thomas_v2.1 für den nützlichen Beitrag:

    kaputt (11.12.2010)

  4. #3
    Join Date
    Erhielt 9 Danke für 7 Beiträge


    Thank you, Thomas!

    I will try variant 2 on monday.


Similar Threads

  1. auf bestimmte Nachkommastellen runden
    By Thomas E. in forum CODESYS und IEC61131
    Replies: 4
    Last Post: 27.08.2010, 15:07
  2. Format mit 2 Nachkommastellen anzeigen...
    By schnecke in forum Simatic
    Replies: 33
    Last Post: 20.07.2010, 19:07
  3. Real Variable Nachkommastellen
    By boggle in forum CODESYS und IEC61131
    Replies: 4
    Last Post: 13.08.2009, 14:08
  4. Umwandlung Integer(32bit) in Integer(16bit)
    By Kojote in forum Simatic
    Replies: 4
    Last Post: 18.08.2005, 10:56
  5. Nachkommastellen einstellen WinCC6
    By Anonymous in forum HMI
    Replies: 1
    Last Post: 20.02.2005, 16:10


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts