Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PWM Generator/ Digtal to Analog Chip

Status
Not open for further replies.

xmen_xwk

Full Member level 3
Joined
Sep 12, 2014
Messages
172
Helped
2
Reputation
4
Reaction score
2
Trophy points
18
Activity points
1,373
I want to generate a digital PWM with a changing frequency and period's duration. Following are the ranges.
Frequency : 1Hz to 1000Hz
Period's Duration : 50uS to 10000uS

Now, frequency is not the hard part. Its the duration thats hard to achieve using arduino. So I'm wondering is there any chip I can buy that can do this PWM which can be set by either I2C or SPI ?
 

Hi,

Why do you think it is a problem for the arduino?

Most probably the microcontroller has a PWM periferal hardware built in.
I see no problem. Periods duration should be easily from 1us to 1s. For sure it depends on clock frequency and the pwm setup.

Klaus
 

For example if frequency is 4Hz, which makes PWM Period 250000uS. Now how do I suppose to set duration to 1uS. I couldn't find a way to do that. I'm sure I missed lots of things but could you please try to do that with above specified PWM in Arduino.
 

Hi,

The ratio of the PWM hardware most probably is limited to 1:65536.
But you may extend this with a little aid of software.

1)
50us with 1Hz. Gives a range of 1:20000. No need for additional software. Select the correct PWM setup, maybe you need to select an appropriate clock frequency.

2)
1us with 4Hz. gives a ratio of 1:250000.
It is possible to run a counter three times 0 to 65535, and one time 0 to 53391. Only very little processing time is needed every time the counter overflows.
Every 65.536 ms. set the new top value and disbale/enable the PWM generation.
But this is only necessary for a very high ratio. As soon as the ration is less than 1:65536 i´d go for the solution without software "manipulation".

Klaus
 

yes thats why I'm wondering if i could get an external IC to do that or a better microcontroller that has 32bit ratio.
 

Hi,

your specifiaction of post#1 should be no problem for an aruino.

***
I don´t know if there are dedicated PWM generating ICs. I guess there are.

Another solution could be to use a simple PLD. They are cheap, available and most flexible.

Hope this helps.

Klaus
 

For example if frequency is 4Hz, which makes PWM Period 250000uS. Now how do I suppose to set duration to 1uS. I couldn't find a way to do that. I'm sure I missed lots of things but could you please try to do that with above specified PWM in Arduino.

If I understood, it's not a problem for Arduino. You need two commands:

1) setPwmFrquency(pin, divider)
2) DelayMicroseconds(value_here)

Arduino does it's magic.
 

Hi,

1) setPwmFrquency(pin, divider)
2) DelayMicroseconds(value_here)

DelayMicroseconds sounds like a software delay.

For your specification of post#1 you just need to setup the duty cycle.

After that your microcontroller may go to sleep. No prcessing power required.

Klaus
 

That's right Klaus, this delay will give the "software" the return of processing after the chosen period. You set the frequency using setPwmFrequency, do your stuff and set delayMicroseconds, so the next line after delayMicroseconds will be executed after those microseconds for you to on-off or change the frequency as you wish before the loop return. All Xman has to do is to turn port, frequency and microseconds into variables that may change at runtime. I think.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top