Encoder Pulse Counting

Hi All,

I am looking into replacing a PLC on a system and was thinking an arduino board may be a good way forward.

What I require is a system which after receiving a trigger input starts to track encoder pulses and after receiving a certain number of pulses will fire a number of trigger outputs. I need to be able to count the encoder pulses at 10kHz. I will also need to be able to keep track of many triggers/outputs at once. The outputs could be a number of things, so I would need possibly three serial ports.

I have tried quite successfully at using a Raspberry Pi for this project. It performs quite well, however as expected it struggles to track the Encoder Pulses at the speed I require.

Is an arduino board suitable for a project like this? Does it run real time? Would it be able to track the encoder at the speed I require and cope with multiple inputs and outputs at the same time.

If so which board would be capable of doing this?

All this is relatively new to me, so any help and guidance would be appreciated.

Many thanks, Trevor

Hi,
How were you doing the encoder tracking with the Pi??

This is a case of interrupt-driven sensing for that encoder. The rest is probably workable OK…

Is an arduino board suitable for a project like this? Does it run real time? Would it be able to track the encoder at the speed I require and cope with multiple inputs and outputs at the same time.

If so which board would be capable of doing this?

An Arduino board may be suitable for a project like this. It absolutely runs at real time, and will be able to track the encoder at 10 KHz and can cope with multiple intputs and outputs at the same time.

I need to be able to count the encoder pulses at 10kHz. I will also need to be able to keep track of many triggers/outputs at once. The outputs could be a number of things, so I would need possibly three serial ports.

The Arduino normally runs at 16 MHz, which would give it 1600 clock cycles to deal with encoder pulses at 10 KHz. That would be plenty for one trigger/output, or even some, but how many is "many"? I know it is possible to deal with multiple serial ports, as well, though I haven't ever done it.

If so which board would be capable of doing this?

Arduino has a limited number of I/O pins, as well, although the Mega has more than the Uno. Which board is going to depend, again, on how many "many" is.

Hi Terry, thanks for your answer. I was doing the encoder tracking using the GPIO on the Raspberry Pi. I wrote a program in Python and then one in C. Both used a interrupt to check for the pulses. It worked well up to a point, but could not cope with the speeds I required, and fell down more if the OS was doing something else. Which as I was hoping to run an NTP server on there as well it was clearly not the right tool for the job.

Hi Tan, Great answer, and has made me think that trying one of these may be worth a try. Which is quite exciting!

I think I confused matters a little with saying it needed to deal with many triggers at once. The triggers would not be at the same time, but it would have to count from one trigger then fire the outputs relating to that trigger at certain periods after. The whole cycle of one trigger and several outputs would not have finished by the time the next trigger fires. I cannot say how many it will have to do at the minute, as its an unknown quantity. Basically I would like to track things down a production line and trigger certain things as the product hits certain points along the line.

I was thinking an Arduino Due would do the job nicely, but they are a little more expensive, so thought I would prototype on the Uno to begin with. I would image if it copes with the trigger counting then the rest should be fairly easy for it! I know the Uno has not as many ports as is required, but I assume the software is scaleable and it would not be too difficult to upgrade it to run on a Due if it was successful. By that I assume they are both programmed using the same language.

The Due is also capable of a lot more cycles, but it sounds as though that will not be the limiting factor for me anyway.

Thanks for all your input I appreciate it greatly.