Arduino as a TTL Pulse Divider

Hi,

I am very new to the world of Arduino (I have a Mega 2560 and an Uno) and I am planning to start a little project to divide down a 5v/3v TTL pulse (50% duty cycle) twice and output the resampled pulses.

The input pulse will be in the range of 0-100kHz, the first output pulse should be in the range of 0-30kHz and the second output pulse should be in the range of 0-25Hz. I have tested a few ideas such as pulseIn() and Timer1 with a an interrupt, however both methods fail to give me the required speed and accuracy. I have also found a frequency counter library which I am going to investigate but I just wondered if anyone could offer any guidance as to whether Arduino is suitable platform for this project?

whether Arduino is suitable platform for this project?

Vast over kill.
All you need is a 74LS93 chip, that will divide your input by 2, 4, 8 and 16

I intend to build upon and around this basic principle including tasks such as wireless data comms of the pulseCounts/frequency and activating/deactivating items based upon the pulseCount/frequency and other input sensors. Right now though I seem to be struggling to deal with such a high speed pulse on my Arduino so I wanted to make sure that it was feasible and the difficulty was merely down to my lack of knowledge. The chip you mention could be used to reduce the signal at least once before I take it into my board making the frequencies more manageable?

you could use interrupt pins and handle it in the Interrupt routine. check attachinterrupt() for details.

divider by 2 ISR routine - not tested

void isr()
{
  static byte count = 0;  // static vars keep their value over function calls.
  
  if (count == 0) digitalWrite(outpin, HIGH);
  if (count == 1) digitalWrite(outpin, LOW);

  count = (count + 1) & 3; // faster way of %4;
}

The point is that if you have a wide frequency coming into the arduino that you need to divide you will spend a lot of the processing time coping with this. Why not divide it first?

This sort of problem is best done with edge triggered interrupts and then have the ISR count them and toggle the other pins at appropriate times.

I intend to build upon and around this basic principle including tasks such as wireless data comms of the pulseCounts/frequency and activating/deactivating items based upon the pulseCount/frequency and other input sensors

So how do you expect a good answer if you keep so much secret? If we don't know what you want to do we can't advise on the best way to do it.

I will look into the interrupt pins they should like they could be useful. Apologies I did not intend to be secretive about anything, I will try to be more complete in the future, however the chip you mentioned looks interesting as performing the first divide externally would definitely be beneficial. The hardware side of this is all quite new to me as I come primarily from a software based background so I appreciate the help.

If you need the Arduino to do other tasks as well, then doing the frequency division in the Arduino using an interrupt is entirely reasonable. If the only requirement is to divide the input frequency by a fixed value, then a counter chip (as suggested by Mike) is a simpler solution.