2022-11-10 (Th) PoweredInlineSkatesRev2 Checking pulse width with interrupts

Interrupts are a feature where a program will stop whatever it is doing if a hardware pin goes to a designated state. In this example, I want to check the time the instant a motor pulse rises and again when it falls. I had never learned interrupts, and this seemed like a perfect time to teach myself. The results were similar to yesterday's, but some differences are worth noting. Measuring a steady signal with pulseIn() spanned 14 microseconds but interrupts showed a span of 24 microseconds. The Arduino Micro's processor has a 16MHz clock speed, so it should have had a resolution of 2 microseconds, but with interrupts, it appeared to be 4, and with pulseIn(), it seemed like it was 1.

A motor timing pulse is 1,000 to 2,000 microseconds, so erratic behavior in the range of 14 or 24 microseconds is 1.4% and 2.4%, respectively. I don't have the experience to know that an ESC won't respond poorly to these differences.
Side-by-side comparison of measurements

I am not confident in my code for generating the timing pulses, so I got a servo expansion board connecting up to 16 motors with a chip designed to generate modulated pulses. I had to circumvent the typical wiring to power everything from USB without adding wire splitters. I will test this signal's quality against the ones I've been generating.
Servo control board

The rest of the posts for this project have been arranged by date.
First time here?

Completed projects from year 1
Completed projects from year 2
Completed projects from year 3
Completed projects from year 4
Completed projects from year 5
Completed projects from year 6
Completed projects from year 7
Completed projects from year 8

Disclaimer for http://24hourengineer.blogspot.com and 24HourEngineer.com

This disclaimer must be intact and whole. This disclaimer must be included if a project is distributed.

All information on this blog, or linked by this blog, is not to be taken as advice or solicitation. Anyone attempting to replicate, in whole or in part, is responsible for the outcome and procedure. Any loss of functionality, money, property, or similar, is the responsibility of those involved in the replication.

All digital communication regarding the email address 24hourengineer@gmail.com becomes the intellectual property of Brian McEvoy. Any information contained within these messages may be distributed or retained at the discretion of Brian McEvoy. Any email sent to this address, or any email account owned by  Brian McEvoy, cannot be used to claim property or assets.

Comments to the blog may be utilized or erased at the discretion of the owner. No one posting may claim property or assets based on their post.

This blog, including pictures and text, is copyright to Brian McEvoy.
2022-11-03

Comments