Seite 1 von 1

RS232 Receive String

Verfasst: Dienstag 9. Dezember 2008, 20:48
von DikkyDik
Hello Abacom and all,

I would like to use Profilab to create a pc application to control a machine. Now this is done with a terminal with RS232 interface. Sending strings to the machine is not a problem, however i do encounter some difficulties in receiving the data. The data which i would like to receive is normally displayed on a LCD display on the terminal.

When i use the "Receive String by RS232" the data is being buffered until a recognized character is seen, and the buffer (data previous to character) is sent out. I would like to have a starting character ($0C) after which the received data will be received and handled.
(The "Receive String by RS232" buffers the text before the starting character so i will constantly be 1 line/string behind ...)

Is this possible, and if so, how can i accomplish this?
Thanks in advance for your help!


Antworte in Deutsch sind kein problem, ich habe nur schwierigheiten in Deutsch zu schreiben ... ;)

Re: RS232 Receive String

Verfasst: Mittwoch 10. Dezember 2008, 09:54
von abacom
Wie könnte das möglich sein? Irgendwie muss dass Ende Daten doch gekennzeichnet werden, es sei denn man hätte immer eine feste Länge an Bytes.

Re: RS232 Receive String

Verfasst: Mittwoch 10. Dezember 2008, 12:43
von DikkyDik
Thank you for your fast answering!

I will explain some more:
With a port monitor i can see the following being received by the RS232 port:

Code: Alles auswählen

                                 0C 4E 6F 2E 20               .No. 
 4D 6F 76 65 6D 65 6E 74 73 3F 1B 3D 21 22 3A 1B   movements?.=!":.
 3D 22 22 20 20 20 20 20 20 20 20 33 36                =""        36
The following is displayed on the 2*16 LCD on the terminal:

Code: Alles auswählen

No. Movements?
:           36
As you can see the string starts with the '0C' but does not have an end. When sending a new command to the machine, a new line is returned, also starting with '0C'.
I've tried to use the '3D' as divider, but i will always not be able see the second line, until a new command is given. Maybe i using the wrong approach of the application?
Please advise.

Thanks in advance for your help!

Re: RS232 Receive String

Verfasst: Donnerstag 11. Dezember 2008, 10:11
von abacom
If you neither have an unique end character nor a fixed length of data, there is no chance to solve this problem.
You must have some indicator for "data transmission ready", otherwise it´s impossible. Think about.

You could try RECEIVE BYTE instead. Convert the byte to analogue value, then to ASCII character and add each received character to a $BUFFER. Receiving $0C you clear the buffer to prepare next transmission. Unfortualtely you will have a "growing" string in buffer during transmission, in that case. If there is a longer pause between two data strings, you could try to solve this, building a "stand still" indicator that triggers a $HOLD component.

Re: RS232 Receive String

Verfasst: Donnerstag 11. Dezember 2008, 10:22
von KAKTUS
@DikkyDik
With a port monitor i can see the following being received by the RS232 port:
Können Sie mal noch mehr empfangene Daten hier einstellen, vielleicht ist ein System erkennbar.

Re: RS232 Receive String

Verfasst: Freitag 12. Dezember 2008, 21:41
von DikkyDik
Thanks for your answers,

I've tried the option with 'Receive Byte' and it worked!!! Thanx Abacom!
The bytes are converted to ASCII and put in a buffer. 0C clears the buffer. In outlines it is working. Some finetuning left.

Now up to the next challenge: translating the string into a readable format.
The handheld terminal does have 2*16 LCD where the text is displayed. I've seen, Profilab does also have a LCD controller in the hardware. I don't have any experience with LCD. Can this unit being used to use the control characters ( ) to format the text in a readable way?
I've found the following logic in the strings:
Textline1: starts with '!!'
Textline2: starts with '!"' (or line1 does have a linebreak)
It would be great if the LCD unit in Profilab can make these kinds of 'translations'. Or do have to create these 'rules' manually?

Re: RS232 Receive String

Verfasst: Montag 15. Dezember 2008, 16:15
von abacom
The LCD component is NOT what you need. It is made to CONTROL display, not to "READ" them.
You have to use $Function components, to extract the information you want, from the received data.
Hard stuff!