RS232 data transfer from PPS10 to computer

Hello to everyone,

This is a follow-up of a post I made some time ago. I now want to transfer from a PPS10 running in ‘ONCE’ trigger mode data

over the RS232 interface to a Visual C# (Visual Studio 2005) application. The data are received in the application by a

SerialPort object.

I understand that the PPS10 transmits all data as ‘BA’ packets of total 266 bytes length, of which 10 header parameter bytes

and 256 one-byte voltage values.

I assumed that the PPPS10, when running in ‘ONCE’ trigger mode, once triggered, would produce one scan on the screen and

would simultaneously transmit the scan data as one BA packet over the RS232 interface.

I now observed the following:

  1. Not all transmitted packets have the said 10 byte parameter header.
  2. Frequently no data are transmitted at all, since the application’s DataReceived event is not fired.
  3. The SerialPort object has a data member called BytesToRead. The value of this member is not identical to the length of the

byte array transmitted.
4) The length of the transmitted byte array is not always 266 bytes as required by the BA packet format.
5) The curve obtainable from a properly transmitted BA packet does often not look like the original scan. Sometimes the

transmitted data seem to have undergone at certain points an auto-sensitivity-re-ranging or auto-zero-re-setting, visible as sharp rises in the signal, not visible on the original screen. Sometimes the curve obtained from the transmitted data does not look at all like the original scan.
6) RTS/CTS flow control seems to work, but the “No flow control” recommended by the PPS10 manual does not work.

I assume that some of the above problems are due to a wrong setting in the SerialPort members. Here are some of these members

which I am not sure about what to use:

[ul]DiscardNull: Whether to discard null bytes received on the port before adding to serial buffer (Options: True or

False).[/ul]
[ul]DTREnable: Whether to enable the Data Terminal Ready (DTR) line during communications (Options: True or False).[/ul]
[ul]GenerateMember: Indicates if a member variable will be generated for this component (Options: True or False).[/ul]
[ul]Handshake: The handshaking protocol for flow exchange, which can be none (Options: None, XonXoff, RequestToSend or

RequestToSendXonXoff).[/ul]
[ul]ParityReplace: Byte with which to replace bytes replaced with parity errors (Integer value from 0 to 255).[/ul]
[ul]ReadBufferSize: The size of the read buffer in bytes. This is the maximum number of read bytes which can be buffered

(Integer value).[/ul]
[ul]ReadTimeout: The read timeout in Milliseconds (Integer value, -1 seems to indicate InfiniteTimeout).[/ul]
[ul]ReceivedBytesThreshhold: Number of bytes required to be available before the Read event is fired (Integer value).

[/ul]
[ul]RTSEnable: Whether to enable the Request To Send (RTS) line during communications (Options: True or False).[/ul]
[ul]WriteBufferSize: The size of the write buffer in bytes. This is the maximum number of bytes which can be queued for

write (Integer value).[/ul]
[ul]WriteTimeout: The write timeout in milliseconds (Integer value, -1 seems to indicate InfiniteTimeout).[/ul].

Further to the above, the setting of the trigger level in the PPS10 is not understandable according to the manual. It seems

that the trigger level remains fixed at the center of the screen, whereas the voltage level must be shifted vertically with

respect to that fixed trigger level. This will however then affect the vertical position of the scan.

Can someone help me?

Regards from MKMKMK.

Let’s start with the beginning

[ul]
[li]Baud rate = 57600[/li]
[li]Parity bits = none[/li]
[li]Stop bits = 1[/li]
[li]Data bits = 8[/li]
[li]DTR = disabled[/li]
[li]RTS = enabled[/li]
[li]No handshaking, no flow control[/li][/ul]

There are BS and BA packets

Dear Moderator,

Thanks for this first input. The last three parameters are different from what I used so far. The VisualStudio documention said that RTSEnable should be used together with RTS/CTS flow control.

I will check whether this solves the problems at the end of this week.

I forgot to to say that I am not using some RS232-to-USB converter. I am using a true RS232 port on a PCI extension card.

Regards, MKMKMK

Hello to everyone,

I now observed the following, in consideration of the latest Velleman support feedback (with reference to the problems 1)-6) in my initial post:

  1. Sometimes the BA packet parameter header is present but not at the start of the byte array, at later location instead. Nevertheless some transferred byte arrays have no parameter header at all.
  2. Persists.
  3. Persists.
  4. In view of above 1) I now retrieve a fixed 1024 bytes of data, without checking for any array lengths (see ReadBufferSize below). This seems not to cause any problems. However, as indicated in 1), sometimes the parameter header is not found anywhere even in these 1024 bytes.
  5. Persists.
  6. “No flow control” and “RTSEnable = true” work most of the times but not always.

The setting I now use in the SerialPort object are:

BaudRate: 57600
DataBits: 8
DiscardNull: True
DTREnable: False
GenerateMember: True
Handshake: None
Parity: None
ParityReplace: 0
ReadBufferSize: 1024
ReadTimeout: -1
ReceivedBytesThreshhold: 1024
RTSEnable: True
WriteBufferSize: 512
WriteTimeout: -1.

I have now made pictures concerning the auto-re-zeroing or auto-re-ranging I mentioned as problem No. 5 in my earliest post. This example was obtained from a clean scan and a corresponding clean BA packet with 266 bytes transferred and BA parameter header starting at byte 0.

For some reason this board does not allow uploading images from one’s local harddisk so I cannot post them. This would be an improvement to this board since the moderators are keen on seeing screenshots and images to illustrate the problems.

MKMKMK.

Since I don’t know anything about your software and how exactly you handle IO I can’t make any assumptions about what you are seeing. If you are doing raw serial port IO it is very easy to shoot yourself in the foot, so I would suggest that you use some kind of component or library for which you don’t need to worry about timing etc. Also be sure to handle all incoming traffic properly, one packet may be spread over multiple reads, or one read may contain multiple packets. Whether or not you use multithreading may also be an issue that is often overlooked.