Tip on a fast digital input module (spider mainboard)

I need to read (two) digital input ports with high timing accuracy. The connected device will be sensors detecting positions. The goal is to calculate the time between the to inputs being activated, in order to determine speed. Can the realtime clock be used to determine when an interrupt/event from an input module was received?

I’m currently using a spider mainboard, But to this application, any board that fits the need for the application could be used.

Any tip on this subject is valuable.

Thanks

The interrupt handler will pass the time when the interrupt happens in tics. I use this method to decode an IR signal. Works well. What is the frequency of your inputs?

1 Like

The time between the two signals will probably be a couple of seconds. It’s the actual time of receiving the signal that is interesting. Any specific module needed for that?

Cowboy is referring to the Interrupt event thrown by the InterruptPort class which can be used with any interrupt capable pin. No additional modules are necessary. This is a feature of NETMF.

1 Like

Can you define ‘high timing accuracy’ a bit better please. Are we talking nanosecond levels?

Edit. You’re using a Spider board

Thanks for answering guys!

Well I will try to explain the idea in more detail. The application is for measuring the speed of a runner or cross country skier. The sensors (ir-gate or similar) would be placed at a fixed distance (ex 10-15meters apart) and by measuring the time from sensor 1 to 2, the average speed is calculated. I’m trying to figure out how large deviation in average speed the latency of the board will cause.

To further develop this I thought of using two cards with one sensor on each card. Time synchronize the cards and in some way (using sound maybe) get the distance calculated. In that way a fixed distance would not be needed. Then have the cards use zigbee to send data to a central unit. No idea if its possible or just flat out stupid :slight_smile:

Not stupid at all, but normally the sensors are placed quite close together, several centimeters, certainly not 10-15 meters.

With a runner or skier, the speeds involved shouldn’t tax your system much at all. At 10-15 meters, your error would come from imprecise sensor placement, not timing error.

Sounds like an interesting application.

I guess the first question is what is the required timing accuracy to measure the speed of the skier to some level of accuracy.

For this purpose Ill ignore the errors introduced by the uncertainty of the actual sensor measurement. In real life you might have to consider that the posture of the target changes between measurements thus changing the measurement point on his/her person. Also you may need to filter out glitches caused by things like the ski pole blocking the sensor ahead of the main body. There are probably lots of things you can do to reduce these effect. E.g. by averaging out the sensor ‘entry and ‘exit times.

Ill make some assumptions

Max ski speed = 50km/h = 13.88m/s
Gate distance = 10m

The basic formulas are

Time = Distance / Speed,
Speed = Distance / Time,
Distance = Speed * Time

Time between gates then = 10 / 13.88 = 0.720

What time would give us a speed of 51km/h(14.16m/s)

Time = 10 / 14.16 = 0.706.

So to be accurate to less than 1km/h for a skier going ~50km/h your timing measurement must be accurate to less than 0.724 – 0.706 = 14milliseconds.

Based on that. If the interrupt handler works for IR as Cowboy says I would guess that it should be accurate enough for your application.

My first step would be to hook up an accurate signal generator (or use the 1PPS from a GPS module) and test the accuracy you can achieve.

The only other way I could think of is to use the SPI interface to clock in the raw digital inputs. You would probably have to put some simple external circuitry to switch from one sensor to the other, but you could achieve sub millisecond timing this way. I have seen someone do this on a dsPIC to sample a signal at over 1MHz.

1 Like