Presentation is loading. Please wait.

Presentation is loading. Please wait.

Joe Blubaugh Diana Mui David Sutherland Matthew Swallow.

Similar presentations


Presentation on theme: "Joe Blubaugh Diana Mui David Sutherland Matthew Swallow."— Presentation transcript:

1 Joe Blubaugh Diana Mui David Sutherland Matthew Swallow

2 Two seperate devices to be programmed DSP (dsPIC33) DFT algorithm performed on audio input Peak detection and frequency analysis SPI communication with micro Micro (PIC24) SPI communication with DSP SPI communication with USB controller UART communication with LCD Menu/push buttons Motor control

3 Discrete Fourier Transform Peak Detection Frequency information PIC24 dsPIC33 Audio In String Frequencies SPI Where the magic happens…

4 Tuning mode? Full ADC sample set taken? FFT Peak detect (precise) Build SPI transmission packet Transmit packet over SPI Take more samples Message received from micro? Start Note detect (not as precise) Determine request YesNo Yes Transmission error Mode change Tuning mode MIDI mode

5 Interrupt driven code ADC triggered on 2800 Hz timer interrupt when sampling SPI Polling loop code FFT on ADC complete Frequency analysis (note, peak detection)

6 Why the hybrid interrupt/polling approach? ADC sampling rate is timing critical, must be interrupt triggered FFT, frequency calculations must happen after samples taken Calculations should be completed in order and as fast as possible, should not be interrupted. Hence, polling loop is best option for these steps

7 Frequency Decode SPI1 PWM Motor Control User Interface MIDI Assembly USB Control PWM UART SPI2 Motors LCD Vinculum USB Controller PIC24

8 Interrupt driven code SPI packet reception from DSP Saves data to circular buffer to be processed later Menu/UI Pushbuttons are externally debounced and attached to EXTINT pins LCD commands added to a circular buffer and serviced by low-priority ISR triggered by 50Hz timer interrupt USB communication via SPI Only active during “MIDI transcription” mode Bytes assembled from MIDI polling loop routine ISR entered on first SPI2 write Highest priority interrupt

9 More interrupt driven code… Motor control algorithm 20 Hz timer interrupt Timer initialized for 20Hz to set PWM period Interrupt will be enabled and utilized to perform motor control calculations Take frequency information from circular buffer Determine rotation direction which increases frequency Decrease motor speed as frequency becomes close to desired one by varying PWM duty cycle

10 Determine new motor speed Determine motor directions Start YesNo Determine new motor direction Is this the sixth motor? Write PWMDTY register No Yes Has this positive motor direction been determined? Exit ISR 20Hz timer ISR

11 Interrupts can be prioritized so that certain ISRs take precedence over previously operating ones LCD timer interrupt (50Hz) USB SPI transmission DSP communication SPI Motor control timer interrupt (20Hz) External push button interrupts (EXTINT)

12 Polling loop code MIDI transcription Save off pointers to header section for later modification Write corresponding note data to buffer when note changes Either when mode has stopped, or 128 bytes have been acquired, initiate USB SPI interrupt by writing SPI2TXBUF Modify the header sections with number of bytes written to each “track”

13 Why is the code mainly interrupt-based? Prioritization Certain processes need precedence USB over… well, anything Pushbuttons/UI service before LCD UART transmission Some routines are big… Organization ISRs help to organize code into manageable chunks that happen at discrete periods of time In contrast to… A giant, unruly polling loop where higher priority tasks have to wait for lower ones to complete

14 Questions?


Download ppt "Joe Blubaugh Diana Mui David Sutherland Matthew Swallow."

Similar presentations


Ads by Google