Konvertieren einer WinCC Double Variable in zwei interne WinCC Tags

ITBuxi

Level-1
Beiträge
40
Reaktionspunkte
0
Zuviel Werbung?
-> Hier kostenlos registrieren
Hallo zusammen,

ich hoffe Ihr könnt mir helfen.
Ich habe eine WinCC Variable als Double.
Daraus möchte ich bei Wertänderung die Daten in zwei interne Variablen mit dem Typ int oder long aufsplitten.
Aber ich komm leider nicht weiter.
Könnt Ihr mir helfen?


Ich hab zwar in der Siemens Hilfe das gefunden:
int wert, high, low;
wert = GetTagWord( "16Bit" );

// Get the 16 Bit process value
high = wert>>8;

// filtering high byte of the process value
low = 0x00ff & wert;

// filtering low byte of the process value
SetTagByte( "8Bit_1" , high );

// save high byte of the process value
SetTagByte( "8Bit_2" , low );
// save low byte of the process value


aber das macht halt aus 32 bit 16ner.

Vielen Dank schon mal vorab.

Gruß

Thomas
 
Nicht dass ich sehr viel Ahnung davon hätte, aber ich würde es in etwa so probieren:

Code:
dint wert; 
int high, low;
wert = GetTagDWord( "32Bit" ); // Get the 32 Bit process value [COLOR="#FF0000"]//Gibt es "GetTagDWord"???[/COLOR]

high = wert>>16; // filtering high word of the process value

low = 0x0000ffff & wert; // filtering low word of the process value

SetTagWord( "16Bit_1" , high ); // save high word of the process value

SetTagWord( "16Bit_2" , low ); // save low word of the process value

Wenn du Double hast, müßtest du diese dann nicht erst eine DINT wandeln?
Oder willst du die Double am Komma trennen?
 
Zuletzt bearbeitet:
Aber jetzt hab ich dennoch eine Frage.
Da das in WinCC ja leider nur mit VBS in den Faceplates funktioniert brauch ich den Code in VB.
objTag.Value = varStatusCMD And &H8000FFFF
Das funktioniert ja noch,aber weiter??? Irgendwie steh ich grad völlig auf dem Schlauch.
Wie ist es jetzt mit dem anderen Wort?
Danke für Deine Hilfe vorab.
 
Zuletzt bearbeitet:
Viel Spaß - musst halt noch an dein Format anpassen...
Und dann Zweimal aufrufen. Einmal fuer das Low-Byte und einmal fuer das High-Byte

' +----------------------------------------------------------------------
' | Ein Int aus Ulong extrhieren
' |
' | Function Name: KovertUintAusUlong
' |
' | Parameter (Uebergabeschnittstelle)
' | InUlong
' | LH_Int
' |
' |Steuerung LH_Int=0 => Low Word
' | LH_Int=1 => High Word
' +----------------------------------------------------------------------

' Variablendeklaration
Dim lIn, iOut , nTemp

' Bausteincode

'Byte auswaehlen
If (LH_Int) Then
nTemp = 16
Else
nTemp = 0
End If

' Typenwandlung
InLong = CLng(InUlong)

' Ausmaskierung (um n Positionen schieben und dann ausmaskieren)
ShiftAndMask lIn, iOut, nTemp, &h0000FFFF

' Ausgabe
KonvertUintAusUlong = iOut
 
Zurück
Oben