I try to write a device driver that will get the PPM signal
from a Radio Control transmitter and return the joystick
positions. I use the trainer cord output from a transmitter
connected to the ACK signal on a parallel port.
If you heard of jrcsim, I try to use the same type of connection.
The signal to the port is:
1. A start pulse.
2. N pulses for N channels. The delay between pulses
is 1-2 ms, relative to stick position.
3. Long delay to the begining of the next start pulse.
A new frame starts in every 20 msec, so this delay if we have
4 channels is about 12-16 msec.
It is important to accurately time the delay between pulses.
The thing which I have working is using interrupt on the
port. In each interrupt read the time (do_gettimeval) and
subtract it from the last time. The driver returns 4 values
in the range of 1000-2000 (time in usec for 4 channels) as
well as other junk which I needed for debugging.
The problem is that I cannot get precise timing. I tried to
interface this driver with a flight simulator and that thing
has too much jitter. I guess that rather than using interrupts
I could use polling (like the joystick driver) but that means
hogging the CPU for average of 30% of the time.
I thought I could try to put the driver in tight loop only
for the predicted time that I need it (assuming that
the controls are moved slowly I can predict the timing of the
next pulse and allow a small mitake (start polling earlier).
If I do not allow enough mistake the original interrupt handler
can take over and give the base for the measurement in the
next frame. It will still give a monotonic movement and
stabilize when the sticks are not moved.
I tried to look at the "timer" code but it does not
have enough resulution. I need a source for a timer interrupt
which can be programmed in the up to 10ms range and has
a resolution of about 10usec or better.
Is there a "free" system timer that can do that?
Which interrupt can I use with it?
Where can I find programming info (eihter free or is anyone can
recommend a good book).
The other approach may be to build a special hardware to time
these events. It would be much easier, I know. I would like
to explore the software approch first.
also to this newsgroup.
Itai
--