3 ms·
Are you polling the sensors, or using interrupts? I don't see how going from one sensor to eight increases latency.
by bjt2n3904 9y ago
Are you polling the sensors, or using interrupts? I don't see how going from one sensor to eight increases latency.
- jononor 9y agoPolling. The atmega32u4 only has 4/5 external interrupts, and our instrument has 8 pads. The CapacitiveSensor Arduino library used does this sequentially, busy-looping for each pin. It would be possible to rewrite this to do all 8 pins in parallel. Right now the readout for different pads is sampled as slightly different times, which works but non-ideal. A more modern uC can have capacitive sensing pherirals, like in the Teensy 3.0
- the-dude 9y agoIIRC, on a 328 you can turn on external interrupt for an entire port ( 8 pins ) at once. Once the interrupts fires, you detect which pin has changed. This doesn't work for the 32u4 ?
- jononor 9y agoLooking at the datasheet for 32u4, port B does have pin change interrupt. So one could maybe use that. Depending on what pins are exposed on Leonardo board, might need to combine with with external interrupts on pins to get a full 8. A challenge is that the capacitive sensing works by sensing how long it takes. For small capacitance (depends on your sensor pads) and resistor values, this is in the order of tens of clock cycles. That can be challenging to measure with a timer. Several such measurents are summed up to suppress noise. However for bigger sensors with higher capacitance, like for distance sensing, then interrupt-based code makes more sense because the uC would actually wait for a significant time.