PICBASIC has a feature to count the number of pulses on a pin in a specified time, so it shouldn't be too hard at all.

Best regards,
Matthew