I'm currently working on a colony picker project and for that we need to get the height of the agar gel so that our robot arm knows where the surface of the agar is.
We took a sensor which is a microsonic +25/F one (an industrial sensor) because we though this would be easier to get a data bus instead of having an analog sensor which could have been less accurate. So the fact is we're trying to get the data on a digital pin through an arduino Mega 2560 and we're supposed to get a 16 bit message with 1 bit for the state of the output and 15 for the measured distance.
But what we get is really messy, it does not look like a 16 bit message. I'm reading the message at the same baud rate as the sensor specification (I suppose writing .begin(38400) makes the arduino getting data at this rate which is the same as the sensor). I then just digitalRead the pin and I also tried waiting for a high bit and then putting the 15 next bit in a table and then print it but the result doesn't change whether I put my hand closer to the sensor or just let it watch the ground (it's usually 1111 + 12 zeros) but when there is nothing in its range it does not send any data (only 0 bits).
So we are wondering if we should get another sensor (an analog one) which would be easier to analyze as far as you just need to read an analog pin and then calculate the value with the specifications of the device or is there any way to get the data from the IO-Link one?
Just to know there are 2 outputs on the sensor, one giving like 64 0 then 64 1 bit and the other one is probably the one to get the distance which does not send any 1 if nothing is in front of the sensor and then gives a randomly 1 and 0 that does not seem the same at all (even if the sensor isn't moving).
I apologize for the english mistakes I may have done and for my poor knowledge in arduino.
Thanks for you help !