Is a CPLD appropriate for this triple PWM application?

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

Reply to
they call me frenchy
Loading thread data ...

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

Reply to
Jim Granville

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" wrote in message news: snipped-for-privacy@4ax.com...

Reply to
Luis Cupido

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

Reply to
they call me 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 aga>I've done that 2 times already !

Reply to
they call me 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

Reply to
they call me 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

Reply to
Gabor

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

formatting link

For small uC, do a google on Motor Control and Microcontroller.

There are many, the most recent press release was this

formatting link

and there are numerous 80C51 variants with PCA, and also the Atmel AT90PWMxx family....

Really depends what ELSE you need in the system...

-jg

Reply to
Jim Granville

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 inputs and perhaps some logic that detects the battery voltage level

Reply to
Luis Cupido

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).

Reply to
David Brown

David, Thank you very much for your response. I am new to programmable logic and I really appreciate the suggestion. Just to make sure that I paint the entire picture, here are my full requirements...

1) 3independent PWM generators running at the same frequency. I am starting with 8-bit, but I could justify going down to 7bit and maaaaaaybe 6 or even 5 bit if it will save me much grief. 2) The FSM will probably have 8 states (cylcled through with a simple pushbutton, no reset). State 1 will tell PWM1 to run at 90% and PWM2 and 3 to be off. The rest of the states will turn the PWMs off and on in a variety of ways. The most complex of the states will tell all 3 PWMs to cylce from 10% to 90% out of phase from each other at about 0.5Hz. I do not have complex timing requirements.

3) I would like to detect the battery voltage and when it is running semi low, I would like to scale down the values of ALL PWM signals to extend battery life. For example, full battery = all PWMs @ 100%, battery 1/2 dead = all PWMs @ 50%, battery pretty much dead = sleep mode until the batteries start to receive a recharge, which could be several hours away.

I got a Coolrunner II development kit just to get going with a

256macrocell chip onboard. I will plan on testing my functionality on that even if I fill the whole damn thing and then perhaps migrate to your recommended MSP430 after some research to prove why that would indeed be better than a CPLD.

My application is geared towards a very high quantity consumer part, so I would like to see the chip cost under US$1 at quantity. I know that I have an uphill climb in front of me and my boots are on.

If I indeed switch over to a MSP430, will my VHDL code that I am writing now be able to come with me?

admitted newbie with big goals, frenchy

Reply to
they call me frenchy

Mr. Granville, Thanks again for your input. Please see my response to david regarding additional requirements of my system. In the meantime I will research the above uC info you provided. As I said, I have never used a uC before and I have no idea why it would be better than a CPLD.

Luckily my Coolrunner development kit came with a 256macrocell chip on it! I will start there, get it working and then switch architectures based on price, etc. I had to start somewhere!

thx, frenchy

Reply to
they call me frenchy

Luis, Thanks again for your response. I am new to VHDL coding, so your example helps. I see that you implemented the "counter and compare" method for the PWMs. I have read that the other implementation of PWM is slightly better with regards to required resources. See here...

formatting link

He makes this statement... "The more classical way to create the PWM output would be to use a counter and a comparator. But that requires more logic and it is tougher on the low-pass filter when "PWM_in" is wide. So the accumulator approach is better." Although I will not be using a LPF in my application, I remember his statement about logic.

I think that I will employ the "count&compare" method for now, it seems more straightforward.

thx again, frenchy

Reply to
they call me frenchy

This does not sound like a CPLD problem. A fundamental determinant in cost is pin count, and there are no 8 or 14 pin CPLDs. CPLDs also have narrow Vcc tolerance, and in some cases, need Two supplies. You will also find the 10-20uA the CPLD vendors boast of, is MUCH higher than the Static Icc of Microcontrollers. There are no CPLDs with low power on-chip oscillators...

You have not mentioned the PWM frequency, but the usage and action sounds like a lighting effects one, so you do not need the 300Mhz clock rates of a CPLD.

Do a pin-count budget, and then choose a 8 pin or 14 pin Microcontroller. [I'd start with 14, and then see if it will fit in 8, when you are all done]

For 8 & 14 pin Microcontrollers, look at Atmel, Freescale, Microchip, Philips, ST, TI, Zilog (etc)

This application will move across uC quite easily, so choose the one that looks easiest for you to learn, and get it working on that, then start the bidding process, when it hits real volume :)

NO, but the ideas will.

Reply to
Jim Granville

Hi,

Ha!!! What they do is PDM pulse density modulation not PWM, may work the same for you... don't know, depends on how you use it. The PWM-pulse width modulation with a constant single output frequency with variable duty cycle, must be with a count and compare ;)

So, that is the problem... after a low pass filter both are equal, and PDM is more tolerant on filtering, but for direct use they are different ! think well if PDM does the same for you or not :)

...me, controlling step motors didn't had much luck with it ;)

lc.

"they call me frenchy" wrote in message news: snipped-for-privacy@4ax.com...

Reply to
Luis Cupido

Atmel has an example that fits 4 8-bit PWM controllers in a 32 macrocell CPLD. It is written in CUPL.

You need to download their tools at:

formatting link

The file is PWM8X4.PLD

kevin

Reply to
kevinjwhite

Additionally, if you want to measure battery voltage, you'll need some sort of ADC. There are lots of small micros with an ADC, whereas with a CPLD you'd need an external ADC.

I think Atmel have some new AVR chips aimed specifically at lighting applications, with very flexible PWM outputs. I don't know the details, but they'd be worth a look.

Your software is going to be vastly easier to write and test in C on a microcontroller, rather than VHDL on a CPLD.

Reply to
David Brown

The responses from both David Brown and Jim Granville have been infinitely helpful. What an idiot I am. You both hit the nail on the head...the application is indeed a lighting effects one. Independently controlling 3 LxExDs (or6)(or9)(or12)(or15) only requires a PWM frequency of 100Hz to a couple kHz. I suppose that it is just stupid to be looking @ a CPLD, especially when power consumption and price are very important driving factors. I guess in my mind I knew that the PWM frequency could be low, but that all of the logic required was complex and needed a much faster clock.

As I mentioned previously, I am just getting back into electronic design for the 1st time pretty much since college. I have never used a uC before and I gravitated to Xilinx because I took a introductory FPGA course in college and I knew that it would functionally accomplish most of my requirements (I used one to simulate the insides of a pop machine). The fact that I have never used a uC before really bit me in the a$$. Thank you for your patience!

I am about done with my 1st run of VHDL code and about ready to program my CoolRunnerII 256 for the 1st time (everything is simulating great). I will finish that in order to test my optics & LxExD driving circuits and meanwhile I will indeed look into the uC solutions that both of you presented above.

I appreciate your input. You will probably hear from me again in the coming weeks. BTW, what is the most appropriate newsgroup for my new uC path?

infinite gratitude, frenchy

Reply to
they call me frenchy

Aha, I see. I will be driving normal L..E..D..s and now that I understand the difference between PWM and PDM, I ask the following question...

Since I want to keep system cost to a minimum, I should avoid adding an extra LPF....will PDM work, or should I just stay with PWM? I will research this tomorrow, but feel free to comment if you like.

thanks for your input, Luis! frenchy

Reply to
they call me frenchy

"they call me frenchy" schrieb im Newsbeitrag

For driving LEDs you dont need (and dont should use!) a LPF (low pass filter). The filtering is done by the eyes/brain ot the observer. Just keep the PWM frequency high enough to avoid flickering (100 Hz ++). The only thing you need is the current limiting resistor.

Regards Falk

Reply to
Falk Brunner

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.