Fish4Fun
So long, and Thanks for all the Fish!
I have bins full of projects in various states of completion because some number of hours/days/weeks/months into the project I "discovered" there was a better solution ready-made for some relatively trivial price or some Open Source project easily modified to suit my needs..... Yesterday I wanted to test a bread-boarded output stage and simply needed a PWM pulse train ~50kHz with fairly flexible duty cycles.....Not a mind boggling task on an Arduino, but it is a recurring obstacle that consumes several hours each time I encounter it; so, because the project on my desk is NOT time sensitive I thought to myself: "I am going to write some code and remove this obstacle once and for all" and down the rabbit hole I went.....
Of course removing the a fore mentioned obstacle on a permanent basis requires a priori knowledge about future requirements and some type of user interface.....Rutabagas! The more you chew them, the bigger they get, and pretty soon the project was spiraling out of control. I started by working with the built-in PWM features in the AVR ATMega2560, but the flexibility I want eluded me.... I can Brute-Force a 50kHz Pulse Train with ~300 duty cycle increments, but that doesn't leave much processor time for anything else, and certainly doesn't require an ATMEGA2560.....So then I thought about porting the code to ATTINY2313A's, but this solution has its own problems ... Next I considered a Spartan-6 FPGA prototype board collecting dust on my shelf (collecting dust because I haven't dedicated time to lean an HDL.....while the project on my desk isn't time sensitive, learning an HDL in an effort to build a general solution to flexible Pulse trains for testing a prototype of one segment of an output stage is pretty far off the beaten path).....But I turned right at the Y between a firmware solution and a hardware solution, tripped over a root and tumbled further down the rabbit-hole....
What is my question? Is there a readily available addressable/OR/programmable IC designed to output a wide range of PWM signals? Ideally, I would like to control Base Frequency, On-Time and Off-Time in ~100nS intervals with 8-bit accuracy in "On Time" / "Off Time" and a 4-bit selection in Time-Base (Ultimately Frequency) . For example, if the IC had an input clock of 10Mhz the interval selection would be: 100nS, 200nS, 500nS, 1uS, 2uS, 5uS, 10uS, 20uS, 50uS, 100uS, 500uS, 1mS 2mS, 5mS, 10mS and 50mS.....Again, Ideally, "On Time" would be 8-bits (0 to 255 intervals) and "Off Time" would be 8-Bits (0 to 255 intervals); however, 4-bit On/Off intervals would likely be sufficient for most applications, and a simple clock divider on the input side of the device could handle the interval period selection.....
Building the described device from discreet logic ICs is certainly possible.....Programming a PAL/CPLD/FPGA is also certainly possible, (but for me would still require learning some type of HDL), A combination of Logic and a uC might be easier to design, but would also include some limitations imposed by the uC to Logic interface......so if there is already an IC designed for the task, and it's cost is reasonable (What is "Reasonable"? .... hard to say, building a "one-off" from discreet logic might take 20 to 200 hours by the time Design/Prototyping/Debugging/PCB Layout/Fabrication/Population is complete, writing the code for a PAL/CPLD/FPGA might take days/weeks/months of learning before a working version emerged, but would be cheap/easy to integrate into projects.....So "Reasonable" is a moving target; certainly anything < 100wouldbea"deal"foraone−off.....butifsuchanICexistsIwouldhopeitwouldbeinthe1-10 price range so I could afford to keep a stock-pile on hand ;-) )
Thanks!
Fish
Of course removing the a fore mentioned obstacle on a permanent basis requires a priori knowledge about future requirements and some type of user interface.....Rutabagas! The more you chew them, the bigger they get, and pretty soon the project was spiraling out of control. I started by working with the built-in PWM features in the AVR ATMega2560, but the flexibility I want eluded me.... I can Brute-Force a 50kHz Pulse Train with ~300 duty cycle increments, but that doesn't leave much processor time for anything else, and certainly doesn't require an ATMEGA2560.....So then I thought about porting the code to ATTINY2313A's, but this solution has its own problems ... Next I considered a Spartan-6 FPGA prototype board collecting dust on my shelf (collecting dust because I haven't dedicated time to lean an HDL.....while the project on my desk isn't time sensitive, learning an HDL in an effort to build a general solution to flexible Pulse trains for testing a prototype of one segment of an output stage is pretty far off the beaten path).....But I turned right at the Y between a firmware solution and a hardware solution, tripped over a root and tumbled further down the rabbit-hole....
What is my question? Is there a readily available addressable/OR/programmable IC designed to output a wide range of PWM signals? Ideally, I would like to control Base Frequency, On-Time and Off-Time in ~100nS intervals with 8-bit accuracy in "On Time" / "Off Time" and a 4-bit selection in Time-Base (Ultimately Frequency) . For example, if the IC had an input clock of 10Mhz the interval selection would be: 100nS, 200nS, 500nS, 1uS, 2uS, 5uS, 10uS, 20uS, 50uS, 100uS, 500uS, 1mS 2mS, 5mS, 10mS and 50mS.....Again, Ideally, "On Time" would be 8-bits (0 to 255 intervals) and "Off Time" would be 8-Bits (0 to 255 intervals); however, 4-bit On/Off intervals would likely be sufficient for most applications, and a simple clock divider on the input side of the device could handle the interval period selection.....
Code:
Example:
Input Frequency = 10Mhz
PWM Target Frequency = 50kHz
Duty = 10% - 90%
Select Interval Period = 100nS (100nS * 200 = 20uS ---> 1/20uS = 50Khz)
Intervals Per Cycle = 200
10% Duty Cycle = 20 "On" Intervals & 180 "Off" Intervals
20% Duty Cycle = 40 "On" Intervals & 160 "Off" Intervals
30% Duty Cycle = 60 "On" Intervals & 140 "Off" Intervals
40% Duty Cycle = 80 "On" Intervals & 120 "Off" Intervals
50% Duty Cycle = 100 "On" Intervals & 100 "Off" Intervals
60% Duty Cycle = 120 "On" Intervals & 80 "Off" Intervals
.
.
.
90% Duty Cycle = 180 "On" Intervals & 20 "Off" Intervals
Building the described device from discreet logic ICs is certainly possible.....Programming a PAL/CPLD/FPGA is also certainly possible, (but for me would still require learning some type of HDL), A combination of Logic and a uC might be easier to design, but would also include some limitations imposed by the uC to Logic interface......so if there is already an IC designed for the task, and it's cost is reasonable (What is "Reasonable"? .... hard to say, building a "one-off" from discreet logic might take 20 to 200 hours by the time Design/Prototyping/Debugging/PCB Layout/Fabrication/Population is complete, writing the code for a PAL/CPLD/FPGA might take days/weeks/months of learning before a working version emerged, but would be cheap/easy to integrate into projects.....So "Reasonable" is a moving target; certainly anything < 100wouldbea"deal"foraone−off.....butifsuchanICexistsIwouldhopeitwouldbeinthe1-10 price range so I could afford to keep a stock-pile on hand ;-) )
Thanks!
Fish