monolake Posted August 13, 2007 Report Posted August 13, 2007 Hello Forum, Hello Thorsten,my Monodeck II MIDI controler uses two core modules to drive LEDs, capture pots etc.... So, DOUT modules are connected to both modules for controling a lot of LEDs. Additional hardware allows to dim R,G, and B of all LEDs based on phase width modulation of simple oscillators.It works somehow but is far from being perfect since it creates all sorts of flickering and moiree effects as a side effect of five clocks sources running free.I think there is a much more elegant way:The three phase width oscillators shall be replaced by three astable oscillators that are triggered by one common clock source and this clock shall be derived from the clock oscillator of Core 1. Core 2 shall be slaved clockwise to Core 1. According to the microcontroler data sheet it is very simple to achive.But before reinventing the wheel, i'd like to ask if someone here allready did this and if it works like expected. ( idea: Microcontroler 1 provides clock on OSC2 output, Microcontroler 2 gets this clock signal on OSC1 input, MIOS needs to be altered to reflect oscillator slave mode on Microcontroler 2. Microcontroler 2 puts out Clock/4 on OSC2 and this is used, maybe after more clock divisions, to drive the LED dimmers. This should create a 100% flicker and moiree free solution...)comments, ideas, suggestions ?Thanx, Robert Quote
TK. Posted August 13, 2007 Report Posted August 13, 2007 Hi Robert,I don't have much experiences in this area, but synchronizing the PWM oscillators from a global clock sounds like a good plan and will propably already solve the problem.You could use J7:SO (PIC pin #17) as a clock output, it can be driven from the PWM peripheral (don't mix with the PWM oscillators), accordingly the frequency can be easily controlled.Here an example for a 1 MHz clock: ;; Initialize Clock Generator (the PWM unit is used to generate a 1MHz clock with 1:1 duty cycle) movlw 0x09 movwf PR2 movlw 0x24 movwf T2CON movlw 0x0f movwf CCP1CON movlw 0x04 movwf CCPR1L[/code]It isn't possible to synchronize the PICs this way, as they are running with an internal PLL which quadruples the clock (-> jitter). Also the reset (pin #1) is asynchronous, and the firmware doesn't always execute the same code.A software-wise synchronisation could cure the problem a little. E.g., the firmware could reset timer1 whenever a special MIDI event has been received. You could use MIDI event "0xff" for such a purpose, it could be checked within the USER_MIDI_NotifyRx hook, which is triggered at interrupt level and therefore guarantees best response time.If the MIDI In ports of the two cores are connected together (in parallel), your MIDI host software needs to send such an event. If the cores are chained, you could do it the same way (merger forwards the sync event, this causes an additional but compensatable delay).Alternatively the first core could send the sync event e.g. one second after startup to the second core (requires some additional firmware changes).This procedure has to be repeated periodically (maybe once each hour) depending on the clock drift between the two cores.Best Regards, Thorsten. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.