Autor Thema: Völlig binäre Serienschnur (ausgedehntes ASCII) zur hexadezimal  (Gelesen 9466 mal)

0 Mitglieder und 1 Gast betrachten dieses Thema.

matt_SD

  • Gast
Hallo, Ich verwende Beckhoff Twincat und würde etwas Hilfe bei der OSCAT Bibliothek fordern, wenn möglich. Ich kippe spreche Deutsches, also habe ich übersetzt, hoffe, dass es sinnvoll, ich kann alle deutschen Antworten zurück umwandeln ist. Ich lese eine Serienschnur des Bewegungs-Sensors RS232 für einen Bewegungs-Sensor, dieser bin ein völlig binäres also herauskomme in das ausgedehnte ASCII-Format, z.B. in das ' úÿ2$12 ¾ Â! V ¼ ' Ich muss dieses in Hexe umwandeln, also kann ich die Daten verwenden. Notwendigkeit IE-I ein Modul, ¾ úÿ2$12 in faff32243132c0 umzuwandeln Bietet OSCAT ein Modul an, um dies zu tun? Auch, wenn ich die OSCAT Bibliothek in Twincat hinzufüge, erhalte ich viele Störungen, da ich Twincat Standardbibliotheken anbringen lasse und diese die gleichen FunktionsSpeicherbereichsnamen haben. Gibt es eine leichte Art oder muss ich, suchen/ersetze den Namen jedes kontroversen Funktionsblockes? Dank für irgendwelche Hilfe Respekt Matt


In English:-

Subject:Fully Binary serial string (Extended ASCII) to Hex conversion

Hello,

I am using Beckhoff Twincat and would require some help with OSCAT library if possible. I cant speak German so I have translated, Hope it makes sense, I can convert back any German replies.

I am reading a motion sensor RS232 serial string for a motion sensor, this is a fully binary so comes out in the extended ascii format, eg 'úÿ2$12¾Â!V¼'
I need to convert this to hex so I can use the data.


ie I need a module to convert úÿ2$12¾ into faff32243132c0

Does OSCAT offer a module to do this?

Also when I add the OSCAT library into Twincat, I get many errors as I have Twincat standard libraries installed and these have the same function block names. Is there an easy way, or do I need to search/replace the name of every conflicting function block?

Thanks for any help

Regards

Matt.
« Letzte Änderung: 16. Februar 2009, 06:30:52 von matt_SD »

Offline hugo

  • Global Moderator
  • *****
  • Beiträge: 2 150
    • Profil anzeigen
Re: Völlig binäre Serienschnur (ausgedehntes ASCII) zur hexadezimal
« Antwort #1 am: 16. Februar 2009, 10:48:08 »
yes oscat allows you to convert extended ascii characters into bytes: the function code does exacltly this

since a string is defined as a series of bytes where a 0 is terminating the string, a code of 0 cannot be transferred as a string.
except the limitation of 0 which is a limitation of string code can convert all codes from 1..255

matt_SD

  • Gast
Re: Völlig binäre Serienschnur (ausgedehntes ASCII) zur hexadezimal
« Antwort #2 am: 20. Februar 2009, 05:42:44 »
Hallo Hugo, Dank für Ihre Antwort.

Ich habe erreicht, dies unter Verwendung einer twincat ASC (ASCII-Bekehrtfunktion) und twincat DWORD_TO_HEXSTR Funktion und OSCAT HEX_TO_DWORD der Funktion zu tun.

Ich habe das Problem, das Sie erwähnten, die Beschränkung von 0, die nicht gebracht werden kann. Ich kippe sehe eine Weise, dies zu tun, ich habe ersetzt 0 für ' ' (Raum) aber andererseits ist Raum ASCII 32/hex 20 und wenn ich einen niedrigen Messwert vom Sensor habe, ich erhalten den falschen Messwert.
Gibt es irgendeine Weise um dieses?

Danke Matt



In English:-
Hello Hugo, thanks for your reply.

I have managed to do this using a twincat ASC (ASCII convert function) and twincat DWORD_TO_HEXSTR function and OSCAT HEX_TO_DWORD function.

I am having the problem you mentioned, the limitation of 0 that cant be transferred. I cant see a way to do this, I have substituted 0 for ' ' (space) but then space is ASCII 32/hex 20 and when I have a low reading from the sensor, I get the incorrect reading.

Is there any way around this?

Thanks

Matt

Offline hugo

  • Global Moderator
  • *****
  • Beiträge: 2 150
    • Profil anzeigen
Re: Völlig binäre Serienschnur (ausgedehntes ASCII) zur hexadezimal
« Antwort #3 am: 22. Februar 2009, 00:11:11 »
hello matt,

the definition of string is such that a string ends with a 0 so transferring the code 0 within a string is impossible, because this would end the transmission / string.
if you need all codes 0..255 the data type of sting is not the one of choice.
i would recomment to collect your data in an array of byte there you do not have this limitation and every byte of the array can stroe all codes from 0..255