Enable a code Block at 480Hz

Create new topics, add your comment, remark, bugs...
Post Reply
jnewmill
Posts: 1
Joined: Thu Apr 29, 2010 2:19 am

Enable a code Block at 480Hz

Post by jnewmill » Thu Apr 29, 2010 2:29 am

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
Posts: 38
Joined: Thu Oct 09, 2008 5:20 pm
Location: Phoenix USA _ Grenoble Fr

Re: Enable a code Block at 480Hz

Post by Ender » Thu Apr 29, 2010 6:11 am

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 !
Attachments
P480HZ.hex
(9 KiB) Downloaded 411 times
P480HZ.mdl
(27.2 KiB) Downloaded 430 times

resodad
Posts: 71
Joined: Tue Jul 07, 2009 1:06 pm
Location: West Point, New York

Re: Enable a code Block at 480Hz

Post by resodad » Wed May 05, 2010 5:06 pm

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
Posts: 38
Joined: Thu Oct 09, 2008 5:20 pm
Location: Phoenix USA _ Grenoble Fr

Re: Enable a code Block at 480Hz

Post by Ender » Thu May 06, 2010 5:55 pm

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:

Post Reply

Who is online

Users browsing this forum: No registered users and 32 guests