FORUM TOPIC · READ ONLY

Enable a code Block at 480Hz

Enable a code Block at 480Hz

Forum : General Remark and Questions

4 message(s) · archive en lecture seule

jnewmill
Hello,



I'm using the dsPIC33FJ256 Explorer board. I want to enable a block at 480Hz. I can't use any of the simulation timers or signal generators. Is there a way to use an on board timer to make an internal 480Hz signal using the block set? Or do I have to look into the C code?



Best ,



- Jared
Ender

Re: Enable a code Block at 480Hz

Hello,



If the goal is a synchronization with another device you better have to use an Input or Output compare or the PWM peripheral. Can you give a better description of your project and the accuracy you want for the frequency? Because there is several solution, included to use an external clock, change or add a quartz etc…



Attached a clumsy solution to get 480Hz with the original Explorer16
    One Led blinks at 1Hz, another at 480Hz with an error lower than 0.25%

    I set the Master at his maximum speed, so 40MIPS

    In configuration parameter the solver Fixed-step time to 0.00008s, cause it's an integer divider of 40e6

    The pulse block sample base time is the same 0.00008s than the solver

    The pulse period is 26 sample time, with 50% of duty cycle so 0.00008 * 26 = 0.00208s => 480.77 Hz

I didn’t test the code on a target, maybe tomorrow ;) So I can be wrong !

Pièce jointe : P480HZ.mdl

Pièce jointe : P480HZ.hex

resodad

Re: Enable a code Block at 480Hz

Hi Jared,

I think you mean to say you want to enable a block when the frequency of an EXTERNAL signal equals 480Hz. Is that right?

If so, you might try connecting the signal to an input capture pin. set up the input capture to output period (type [4]) and compare the signal period to a constant ("compare to constant" block) to generate a trigger signal.

John
Ender

Re: Enable a code Block at 480Hz

It just tried to measure the 8th Harmonic of a USA power line. But because he doesn't know how ........

R.I.P Jared :mrgreen: