Read two bytes together from Serial

Hi all :slight_smile:

I have a distance sensor that includes I/O link with speed 38400 bps and it has 16 bit data frame.
what is the best code that reads these 16 bit data? :roll_eyes:

Thank you all 8)

Hi palmood

Can you post a link to the sensor you are using?

Thanks

Ray

here is the web page below, and also i attached to you the sensor datasheet.
thank you for replaying.

http://www.leuze.com/en/deutschland/produkte/messende_sensoren/abstandssensoren/optische_abstandssensoren/odsl_10/odsl_9_high_resolution_3/selector.php?supplier_aid=50111174&grp_id=A1-2-1-1-2-2&lang=eng#{β€œtab”:β€œ0”}

DS_ODSL9L650_en_50120806_P.pdf (362 KB)

I looked in the technical description document. It looks like there are two models. ODSL 9/L uses an IO-Link interface. ODSL 9/D uses a serial interface.

If you can use the second one, it breaks up the data messages into 8-bit bytes (1 start, 8 data, 1 stop, no parity), which should work OK with serial interface on Arduino. See section starting at page 24 in the document.

You would need to check if the interface is at RS-232 or TTL levels, and a level converter may be needed.

mmmm

so what i can do for I/O link module?
how can i program it?

what is the best code that reads these 16 bit data?

There isn't a method to read the 16 bits at once. You have to know the order of the bytes sent, so that after reading both of them you can combine them again in the correct order.

so what i can do for I/O link module?

Buy or design an IO-link shield

How it happened with I/O link ?