Need guidance: Measuring encoder position and sending data with Ethernet/WiFi

Hi all,

I would like to use Arduino to read the value of an rotational optical encoder and use either the wifi shield or ethernet shield to send the recorded encoder value over a dedicated network to another computer (using UDP). The encoder I plan to use is a 16bit encoder, so a very high resolution (2^16=65535 counts per revolution). I think that the encoder will turn 180 deg/s at maximum (so 32768 counts per second. After reading the encoder value, I would like to send the rotation position (and some other things) in a small packet (1 float and a couple of ints) using UDP to another computer with the Arduino Wifi or Arduino ethernet shield.

So I would love to hear your thoughts on the following:

  1. Do you think that one of the board is fast enough to accurately measure the encoder position and send this data over a wifi/ethernet shield? I am a bit worried that the arduino might 'miss' some counts yielding an incorrect position. What Arduino board would you advice?

  2. Does anyone have experience with the speed and reliability of the wifi/ethernet shields? I read on the forums that the ethernet speed is pretty slow (4kB/s with Arduino as client, no idea how fast Arduino is as a server). The connection needs to be reliable (low lag and jitter, low count of lost packets).

  3. Should I use an incremental encoder or absolute encoder? Since you have to integrate the incremental encoder to get position, is it a better idea to use an absolute encoder?

As I said, I am new to the Arduino scene, and any thoughts would be greatly appreciated!

Thanks,

Niek

PS: I posted this note one time already, but I felt that I left out some vital information.

'How fast' will depend on how fast you expect the encoder to trigger, and how frequently you need to transmit updates. Hopefully you have designed it so that it isn't trying to transmit an update on every single encoder event.

Be careful about sending float values over the wire - you will need adopt an encoding scheme that the sender and receiver can agree on. If possible, it would be preferable to send the values using fixed point rather than floating.

Thanks for your reply!

As I said, I am trying to learn more about this, so bare with me :slight_smile:

Perhaps some background on what I am trying to do might be useful. I am designing a custom-made joystick, which I am going to use to control a motion simulator. So I would like to get inputs from the encoder, and send that over to the computer that commands the motion system (ideally via Ethernet, else via WiFi).

'How fast' will depend on how fast you expect the encoder to trigger, and how frequently you need to transmit updates. Hopefully you have designed it so that it isn't trying to transmit an update on every single encoder event.

I expect that the encoder will be rotated approximately 180deg per second. So if I understand correctly, for a 16bit encoder this would mean that the encoder will trigger 32768 times in one second.
As for the frequency of updates I want to transmit over the network from Arduino to the motion computer, I need to have an update rate of at least 600Hz (the higher the better).
Since I am controlling a motion simulator with this data, I would like to have a stable and reliable connection. Do you think this is feasible using Arduino? If not, what could be other options?

Be careful about sending float values over the wire - you will need adopt an encoding scheme that the sender and receiver can agree on. If possible, it would be preferable to send the values using fixed point rather than floating.

Thank you for the comment about sending float values. I will look into this.

Niek

Any other thoughts?

I would really appreciate your help :slight_smile:

Niek

I need to have an update rate of at least 600Hz (the higher the better).

Have you tried a telnet or UDP setup to see how fast you can send data using an arduino? Not sure what you are trying to accomplish in the end, but you will need to assume that there will be data transmission overhead.

I haven't tried a UDP setup yet - still in the 'design phase'.

I am trying to figure out if Arduino can accomplish what I need (2 steps):
(1) Arduino needs to read out an optical encoder,
(2) and send the position of the encoder to a computer over ethernet (or wifi) using the Ethernet or WiFi shield

Regarding the 600Hz; I need to send the encoder position to a computer with software that runs at 600Hz (it runs an integration at 600Hz). The packet I would like to send has 3 floats and one int. So the size of the data is (3*32+1) = 97 bytes (excluding the header). If I am correct, sending this packet 600x per second means that the data rate is 56kb/s at minimum (not counting the UDP header), right?.

--> Reliability of the data transfer is a big issue, the connection needs to be low lag, jitter and as little packets lost as possible.

Do you think that Arduino with the Ethernet shield is fast and reliable enough to do this? Or should I look at other options, such as Raspberry Pi?

but you will need to assume that there will be data transmission overhead.

Could you explain what "assume that there will be data transmission overhead." means (I am new to this) ? Does this slow down the connection?

niekb:
--> Reliability of the data transfer is a big issue, the connection needs to be low lag, jitter and as little packets lost as possible.

In that case you should be using TCP, not UDP. If you need to manage jitter and latency then you should include time stamps in your data stream so that the amount of jitter can be established.

The transmission speed requirement doesn't seem unreasonable, but you will need to test it to see what throughput you can actually achieve in practice.

If the arduino can't keep up with the encoder count, you can use a dedicated chip (or the count function on the 32Bit Due) or use and FPGA like Pappilio which can run Arduino as well. As this is done in Parallel there should be no real issues there.
As for encoders, Absolute encoders gets expensive and all they really do is have a battery onboard that allows the count to be saved when the power goes off.
Just need to a home position for the encoder on power-up, thats all.

K