1 / 11

Drawing Circles on a Tight Budget

Drawing Circles on a Tight Budget. Using an 8-pin PIC12F675 microcontroller, harmonic oscillator theory and software PWM to generate in-phase sine and cosine signals Catalin Patulea < cat@vv.carleton.ca > Second year Software Engineering student Carleton University. Overview. Microchip

brygid
Download Presentation

Drawing Circles on a Tight Budget

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Drawing Circles on a Tight Budget Using an 8-pin PIC12F675 microcontroller, harmonic oscillator theory and software PWM to generate in-phase sine and cosine signals Catalin Patulea <cat@vv.carleton.ca> Second year Software Engineering student Carleton University

  2. Overview Microchip PIC12F675 Harmonic Oscillator Software PWM Reconstruction Filter Oscilloscope Y Harmonic Oscillator (90° out of phase) X Software PWM Reconstruction Filter

  3. Harmonic Oscillator: Theory • Second order recursive relation • Can be modeled using the z-transform • Can verify stability and period over integers (FSM) Y(n-1) Y(n-2) Y(n) = K·Y(n-1) - Y(n-2) Y(n)

  4. Harmonic Oscillator: Design • “Angular increment” • Frequency determined by K • Phase and amplitude determined by Y(0) and Y(1)

  5. Harmonic Oscillator: Implementation • Three 16-bit state variables • “Seed” the oscillator • Compute next sample (2cos(5°) ≈ K = 21- 2-7) • Shift samples down static signed int x0, x1, x2; x0 = 0; x1 = 11; x2 = (x1 << 1) - (x1 >> 7) - x0; x0 = x1; x1 = x2;

  6. Software PWM • PWM is Pulse Width Modulation • Constant frequency, variable duty cycle • Average value proportional to duty factor • Easily generated on a digital μC output pin • PWM + reconstruction filter = poor man’s DAC 10% 40% 100%

  7. Reconstruction Filter • Intuitively, a short-term averager • Low-pass filter with corner frequency between output frequency and PWM frequency • Cut out high-frequency “garbage” • Avoid attenuating useful signal • If PWM frequency is high enough (compared to output frequency), RC will do just fine Re- construction Filter 70% 70%

  8. Summary • 8-pin PIC12F675, two resistors, two capacitors • 62 lines of C code (17% ROM, 46% RAM) • Room for optimization in assembly • ~ 1 Hz in-phase sine and cosine, sampled at ~ 70 Hz • Applications • QAM (Quadrature Amplitude Modulation)

  9. Small, few components No external oscillator Cheap About 3 $ Low footprint No look-up table Dynamically changing the frequency requires recomputing only 3 coefficients Dynamic frequency variations are limited by reconstruction filter Probably needs an amplifier to drive anything significant Probably not well-suited for high frequency or high quality conditions Pros and Cons

  10. Demo

  11. Microchip PIC12F675 Harmonic Oscillator Software PWM Reconstruction Filter Oscilloscope Y Harmonic Oscillator (90° out of phase) X Software PWM Reconstruction Filter Q & A

More Related