Thread Tools
Sep 26, 2019, 12:26 AM
Registered User
vollrathd's Avatar
Thread OP
Originally Posted by GeoffS

The downside is that you can't do *anything* else while the data-acquisition is running.

int i = 0;
bool notDone = true;
        dataArray[i++] = readValueFromPort;
        if( i > totalNumberOfPointsToRead) notDone = false;
        while(valueReady) {}  // Wait for the external flag to drop.
I used this technique a number of years ago (8 MHz 68000) when I needed to read values from an ADC at a rate much faster than the interrupt latency of the 68000.

One issue with interrupts, depending on the IDE, the microcontroller has to save its operating registers before working with the interrupt. That takes a bit of microcontroller time.

I did something similar years ago without interrupts when I added an internal frequency counter to my Ebay special 20 year old 100 Mhz Tektronix oscilloscope. Got it to work up to 50 Mhz with a 1/10 frequency divider at the front end of the PicChip microcontroller.

That counter added a tiny little blip to the scope trace once per cycle though, could never get rid of it. I had three of those Tek scopes, still have one of them. It interesting, that old scope has little noise on its input at high input gain settings. That can't be said about my Siglent SDS2102X $1200.00 scope I currently use. That POS scope is so noisy at the 5 mv input setting, it's useless trying to track down noise issues on microcontroller A/D circuits.

Sad to say, I've got a $28.00 DSO150 scope that is far more useable for working with A/D noise issues than that $1200.00 scope. And that $28.00 scope has a 5 mv vertical capability. And, yes I did file a complaint with the Siglent scope mfg, their response is they checked their inventory, their other scopes work the same way. I had several dozen emails flying back and forth with Siglent on this issue.
Last edited by vollrathd; Sep 26, 2019 at 12:35 AM.
Sign up now
to remove ads between posts
Sep 26, 2019, 08:32 AM
AndyKunz's Avatar
The PIC chips will have the SAME interrupt latency with a jitter of 1 instruction clock. This is because a single-clock instruction will start to respond to the interrupt at the end of the current instruction, while a 2-clock instruction it may be delayed for 1 extra cycle.

One instruction clock jitter is pretty good timing for most applications.

Using interrupt-on-change, you can have 1 clock jitter at the start of the pulse and 1 at the end, giving you a pulse measurement accuracy on a 1ms pulse of 0.2% accuracy if running a 1 MHz instruction clock. Boost your clock speed and it gets even better.

A better way to measure the pulses is to use the hardware counter, using the pin as a gate. This will allow you to measure very short duration pulses. But servo pulses are quite long, so unless there's a specific need you can skip this path.


Quick Reply

Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Discussion No output signals from output headers of SP F3 FC ShoC Beginner Multirotor Drones 4 Aug 03, 2018 11:32 PM
Cool Dual input/output 5A electronic switchjack failsafe system for RX/servos Inflexo Batteries and Chargers 1 Jan 09, 2011 03:02 AM
New Product Dual input/output 5A electronic switchjack failsafe system for RX/servos Inflexo Sailplane Talk 2 Jan 09, 2011 03:01 AM
Discussion Spektrum receiver servo output signals? foxflier DIY Electronics 11 Aug 20, 2008 06:29 PM
Question 10-bit analog output from servo input, anybody have a canned solution available? EddieB DIY Electronics 33 Mar 11, 2005 02:47 AM