Hello Lubin,
I just wanted to confirm that I'm using the OC Output Compare block correctly...
First off, it seems like OC1max is a constant that is relevant to the chip. Is there a way I inherit it from the chip, because just making a constant block called [OC1max] does not work.
Additionally, if I wanted to set up a 50% wave at 2 KHz, then I would need Max / Channel to be set to 0.0005 and up would be (0.00025 / 0.0005 )* OC1max?
What do I set Period to, as it needs an integer input?
Thanks!
Using Output Compare
-
- Site Admin - Expert
- Posts: 616
- Joined: Wed Mar 07, 2007 11:23 pm
- Location: Bayonne- France
- Contact:
Re: Using Output Compare
Hello Jared
the dsPIC blockset evaluate this variable in the MATLAB workspace. Type "who" at matlab prompt to list all variable. Get the variable value typing its name "OC1max" (case sensitive).
There are two OC blocks :
OC hardware that create one variable OCmax.
OC that create variables OC(x)max with x, corresponding to each channel (1, 2 3 or 4)
==> use the correct one.
As you must use an integer value, roundoff result : round((0.00025 / 0.0005 )* OC1max).
Period must be set at OC1max (In your case, period is fixed at OC1max, thus, you can remove the Period input from the block).
Please feel free to edit the wiki pages about OC blocks to make them better.
Lubin
OC1max is relevant to the internal chip frequency (typically depending on quartz and PLL used).jmednick wrote:First off, it seems like OC1max is a constant that is relevant to the chip. Is there a way I inherit it from the chip, because just making a constant block called [OC1max] does not work.
the dsPIC blockset evaluate this variable in the MATLAB workspace. Type "who" at matlab prompt to list all variable. Get the variable value typing its name "OC1max" (case sensitive).
There are two OC blocks :
OC hardware that create one variable OCmax.
OC that create variables OC(x)max with x, corresponding to each channel (1, 2 3 or 4)
==> use the correct one.
That's correct. The OC(x)max value should be high enough (otherwise, you will not get a correct precision, workaround would be to increase the chip internal MIPS through quartz or PLL)jmednick wrote:Additionally, if I wanted to set up a 50% wave at 2 KHz, then I would need Max / Channel to be set to 0.0005 and up would be (0.00025 / 0.0005 )* OC1max?
As you must use an integer value, roundoff result : round((0.00025 / 0.0005 )* OC1max).
Period must be set at OC1max (In your case, period is fixed at OC1max, thus, you can remove the Period input from the block).
Please feel free to edit the wiki pages about OC blocks to make them better.
Lubin
Who is online
Users browsing this forum: No registered users and 17 guests