FPGARelated.com
Forums

Is a CPLD appropriate for this triple PWM application?

Started by they call me frenchy September 13, 2005
I am thinking of using a lowcost CPLD as a brain to do various logic
functions in addition to driving 3 separate PWM generators.  The PWM
generators will receive their intputs from a state diagram that is
cycled through via a pushbutton.  Sounds simple.  Does anyone object
to using a very low cost CPLD for this?

Obviously there are many more details involved, like the battery
powered, low power requirement (Coolrunner II, maybe)...but I just
wanted to have a general discussion at this point.

thx,
frenchy
they call me frenchy wrote:
> I am thinking of using a lowcost CPLD as a brain to do various logic > functions in addition to driving 3 separate PWM generators. The PWM > generators will receive their intputs from a state diagram that is > cycled through via a pushbutton. Sounds simple. Does anyone object > to using a very low cost CPLD for this? > > Obviously there are many more details involved, like the battery > powered, low power requirement (Coolrunner II, maybe)...but I just > wanted to have a general discussion at this point.
The choice will depend on how many macrocells you actually need, and the cost relative to alternatives. eg there are many small uC that can handle 3 PWMs, but a CPLD might give speed or resolution or protection advantages. Lowest power 5V parts are Atmel ATF150xASL, and lowest power 1.8V parts are Xilinx Coolrunner and Lattice Mach4000Z series. -jg
I've done that 2 times already !
First was a dual stepper-motor controller (on a EPM7064),
Second it was a GPS frequency control, dac output was a PWM filtered (on a 
EPM3064
and later on a MAXII)

These are the kind of things that usually don't take a lot of LE's
and fit well inside small CPLD's
But of course I know little about what else you need besides the
PWM...

lc.


"they call me frenchy" <solarfrenchyNO@SPAMhouseofharmonystudios.com> wrote 
in message news:takei1lj59t5dd42nmhh85ajjlh4ka05ed@4ax.com...
>I am thinking of using a lowcost CPLD as a brain to do various logic > functions in addition to driving 3 separate PWM generators. The PWM > generators will receive their intputs from a state diagram that is > cycled through via a pushbutton. Sounds simple. Does anyone object > to using a very low cost CPLD for this? > > Obviously there are many more details involved, like the battery > powered, low power requirement (Coolrunner II, maybe)...but I just > wanted to have a general discussion at this point. > > thx, > frenchy
On Wed, 14 Sep 2005 11:54:14 +1200, Jim Granville
<no.spam@designtools.co.nz> wrote:

>they call me frenchy wrote: >> I am thinking of using a lowcost CPLD as a brain to do various logic >> functions in addition to driving 3 separate PWM generators. The PWM >> generators will receive their intputs from a state diagram that is >> cycled through via a pushbutton. Sounds simple. Does anyone object >> to using a very low cost CPLD for this? >> >> Obviously there are many more details involved, like the battery >> powered, low power requirement (Coolrunner II, maybe)...but I just >> wanted to have a general discussion at this point. > > The choice will depend on how many macrocells you actually need, >and the cost relative to alternatives. eg there are many small >uC that can handle 3 PWMs, but a CPLD might give speed or resolution or >protection advantages. > Lowest power 5V parts are Atmel ATF150xASL, and lowest power >1.8V parts are Xilinx Coolrunner and Lattice Mach4000Z series. >-jg
Mr. Granville, Thank you very much for your response. Since this is my 1st programmable logic project since college, I really dont know how many macrocells I will need yet. I am in the process of learning VHDL right now and coding the most efficient triple 8-bit PWM imeplementation that I can. It is going well, but it will still be 1-2 days before I can compile it and see how many macrocells are required. (I am using Xilinx's free ISE 7.1 software). When you say there are many small uC that can handle 3 PWMs, can you give me a couple of specific examples so that I can compare their cost/functionality? I admit to you that although I graduated with an EE degree, I have been a musician and running a recording studio for the last several years. I am just now getting back into the EE loop, but I love it and am moving forward quickly. Unfortunately, the fool in me has no idea what you are referring to when you say uC. It probably means microcontroller, but I have never used one and I dont know if they are re-programmable like CPLDs are. The reason that I was looking into the Xilinx Coolrunner II is because I need ultralow power consumption and I found the price on their smallest one (32macrocells) to be $0.85 at quantities of >100k. I hope I can fit it into the smallest one! thx again, frenchy
Based on your experience, do you think that three 8-bit PWMs could fit
inside of a small CPLD (32 or 64 mcarocells)?  The other funcionality
that I plan to have in there is a state machine that drives the PWM
inputs and perhaps some logic that detects the battery voltage level
and chooses states accordingly.  The more room that I have left over,
the more involved I will make the state machine.

The Max II that you used seems very similar to the Coolrunner II that
I have been looking into.  Was your project hi or low quantity?  What
was the cost of your MaxII at your quantity?

thx again!
frenchy

On Wed, 14 Sep 2005 04:11:55 +0100, "Luis Cupido"
<cupidoREMOVE@REMOVEua.pt> wrote:

>I've done that 2 times already ! >First was a dual stepper-motor controller (on a EPM7064), >Second it was a GPS frequency control, dac output was a PWM filtered (on a >EPM3064 >and later on a MAXII) > >These are the kind of things that usually don't take a lot of LE's >and fit well inside small CPLD's >But of course I know little about what else you need besides the >PWM... > >lc. > > >"they call me frenchy" <solarfrenchyNO@SPAMhouseofharmonystudios.com> wrote >in message news:takei1lj59t5dd42nmhh85ajjlh4ka05ed@4ax.com... >>I am thinking of using a lowcost CPLD as a brain to do various logic >> functions in addition to driving 3 separate PWM generators. The PWM >> generators will receive their intputs from a state diagram that is >> cycled through via a pushbutton. Sounds simple. Does anyone object >> to using a very low cost CPLD for this? >> >> Obviously there are many more details involved, like the battery >> powered, low power requirement (Coolrunner II, maybe)...but I just >> wanted to have a general discussion at this point. >> >> thx, >> frenchy >
I have a bonus question for anyone interested in this topic.  Since I
am trying to pack 3 8-bit PWMs into as small a space as I can...also
since I am new to VHDL coding, I have a question.  Which would be
best?

1) Implement a single file called "triple_PWM.vhd" that handles all 3
of the separate PWMs with 3 different sets of variables (ie pwm_in1,
pwm_in2, pwm_in3, etc)

or

2) Implement one generic 8-bit PWM file called "single_PWM.vhd" that
is called upon 3 different times for the 3 independent PWM
applications?  Remember that all 3 PWMs must be functional
simultaneously.

I will go with #1, but I just wanted to throw this question out there
because I thought that it may affect the amount of end logic required.
Sorry for the kindergarten question, I am learning.
thx,
frenchy
they call me frenchy wrote:
> I have a bonus question for anyone interested in this topic. Since I > am trying to pack 3 8-bit PWMs into as small a space as I can...also > since I am new to VHDL coding, I have a question. Which would be > best? > > 1) Implement a single file called "triple_PWM.vhd" that handles all 3 > of the separate PWMs with 3 different sets of variables (ie pwm_in1, > pwm_in2, pwm_in3, etc) > > or > > 2) Implement one generic 8-bit PWM file called "single_PWM.vhd" that > is called upon 3 different times for the 3 independent PWM > applications? Remember that all 3 PWMs must be functional > simultaneously. > > I will go with #1, but I just wanted to throw this question out there > because I thought that it may affect the amount of end logic required. > Sorry for the kindergarten question, I am learning. > thx, > frenchy
Are all three PWM's running at the same frequency? If so you may save a lot of macrocells by combining them. Otherwise, do what's easiest to debug. Just my 2 cents, Gabor
they call me frenchy wrote:

<snip>
> Mr. Granville, > > Thank you very much for your response. Since this is my 1st > programmable logic project since college, I really dont know how many > macrocells I will need yet. I am in the process of learning VHDL > right now and coding the most efficient triple 8-bit PWM > imeplementation that I can. It is going well, but it will still be > 1-2 days before I can compile it and see how many macrocells are > required. (I am using Xilinx's free ISE 7.1 software). > > When you say there are many small uC that can handle 3 PWMs, can you > give me a couple of specific examples so that I can compare their > cost/functionality? I admit to you that although I graduated with an > EE degree, I have been a musician and running a recording studio for > the last several years. I am just now getting back into the EE loop, > but I love it and am moving forward quickly. Unfortunately, the fool > in me has no idea what you are referring to when you say uC. It > probably means microcontroller, but I have never used one and I dont > know if they are re-programmable like CPLDs are. The reason that I > was looking into the Xilinx Coolrunner II is because I need ultralow > power consumption and I found the price on their smallest one > (32macrocells) to be $0.85 at quantities of >100k. I hope I can fit > it into the smallest one!
You will struggle to do this in a Coolrunner, as you need to store 3 x 8 bit Values, plus have a 8 bit counter, plus prescaler?, and then 3 PWM pins, so that's bumped you into 64 MC coolrunner. I have packed 3 x PWM into ATF1502ASL, using their logic doubling. See http://www.atmel.com/dyn/resources/prod_documents/DOC2310.PDF For small uC, do a google on Motor Control and Microcontroller. There are many, the most recent press release was this http://www.st.com/stonline/press/news/year2005/p1672d.htm and there are numerous 80C51 variants with PCA, and also the Atmel AT90PWMxx family.... Really depends what ELSE you need in the system... -jg
Hi,

If all pwm are at same frequency, you need just one
pwm_cycle counter (8 mc) and 3 comparisons with
the desired PWM values (3 registers of 8 bit)
that makes a total of 32 mc just for that.
So... 32mc... forget nearly impossible !
64mc should be ok, (again not knowing what your state machine
will use ;).

About the code... if using one cycle counter, just pack all
the 3 pwm together it will be more straightforward...

if (clock='1' and clock'event) then
    counter := counter +1;
    if (counter>pwm_val_a) then pwm_a <= '1'; else pwm_a <='0'; end if;
    if (counter>pwm_val_b) then pwm_b <= '1'; else pwm_b <='0'; end if;
    if (counter>pwm_val_c) then pwm_c <= '1'; else pwm_c <='0'; end if;
end if;

very simple VHDL code for that, the pwm_* outputs will have the duty
cycle of the registers pwm_val_* / 255

...my view of the thing :)

---
my aplic. it was low QTY, I did not care about price etc.

lc.


"they call me frenchy" <solarfrenchyNO@SPAMhouseofharmonystudios.com> wrote 
in message news:4kjgi15inu96ftvjg8hnl4tnh94q42d6o2@4ax.com...
> Based on your experience, do you think that three 8-bit PWMs could fit > inside of a small CPLD (32 or 64 mcarocells)? The other funcionality > that I plan to have in there is a state machine that drives the PWM > inputs and perhaps some logic that detects the battery voltage level > and chooses states accordingly. The more room that I have left over, > the more involved I will make the state machine. > > The Max II that you used seems very similar to the Coolrunner II that > I have been looking into. Was your project hi or low quantity? What > was the cost of your MaxII at your quantity? > > thx again! > frenchy >
they call me frenchy wrote:
> On Wed, 14 Sep 2005 11:54:14 +1200, Jim Granville > <no.spam@designtools.co.nz> wrote: > > >>they call me frenchy wrote: >> >>>I am thinking of using a lowcost CPLD as a brain to do various logic >>>functions in addition to driving 3 separate PWM generators. The PWM >>>generators will receive their intputs from a state diagram that is >>>cycled through via a pushbutton. Sounds simple. Does anyone object >>>to using a very low cost CPLD for this? >>> >>>Obviously there are many more details involved, like the battery >>>powered, low power requirement (Coolrunner II, maybe)...but I just >>>wanted to have a general discussion at this point. >> >> The choice will depend on how many macrocells you actually need, >>and the cost relative to alternatives. eg there are many small >>uC that can handle 3 PWMs, but a CPLD might give speed or resolution or >>protection advantages. >> Lowest power 5V parts are Atmel ATF150xASL, and lowest power >>1.8V parts are Xilinx Coolrunner and Lattice Mach4000Z series. >>-jg > > > > Mr. Granville, > > Thank you very much for your response. Since this is my 1st > programmable logic project since college, I really dont know how many > macrocells I will need yet. I am in the process of learning VHDL > right now and coding the most efficient triple 8-bit PWM > imeplementation that I can. It is going well, but it will still be > 1-2 days before I can compile it and see how many macrocells are > required. (I am using Xilinx's free ISE 7.1 software). > > When you say there are many small uC that can handle 3 PWMs, can you > give me a couple of specific examples so that I can compare their > cost/functionality? I admit to you that although I graduated with an > EE degree, I have been a musician and running a recording studio for > the last several years. I am just now getting back into the EE loop, > but I love it and am moving forward quickly. Unfortunately, the fool > in me has no idea what you are referring to when you say uC. It > probably means microcontroller, but I have never used one and I dont > know if they are re-programmable like CPLDs are. The reason that I > was looking into the Xilinx Coolrunner II is because I need ultralow > power consumption and I found the price on their smallest one > (32macrocells) to be $0.85 at quantities of >100k. I hope I can fit > it into the smallest one! > > thx again, > frenchy
Unless you have complex timing requirements, a small micro would be the best for making 3 PWMs. Get a small msp430 processor - they are cheap, easy to work with, and have good free tools (the gcc port is excellent, and there are free versions of ImageCraft and IAR tools for limited program sizes).