# changing the frequency of a PWM help?

#### fubar

Joined Mar 22, 2006
11
hi. i am a physicist not an engineer so please don't attack me for having no clue.

anyway, i've got a PWM operating at 350hz. i want it to be at 35hz. i want the same duty cycle (averaged!) though.

my idea to do this is the following:
take that signal (which is 14V), run it over a resistor to drop it down to 3 or so.
run that lower voltage signal into a counter
let the counter count to 5 pulses and then turn on a latching switch
the latching switch turns on a FET
let the counter count five more pulses and tell the switch to shut off the FET
repeat.

is this goofy?

also, what happens if i don't get modulable, by five, number of pulses? does this means it stays on...is there a way to assess the signal and shut it off i only get a few pulses? or, should i do something different like measure how long it takes to get five pulses and store that somehow and then when i would normally switch on, just run for that time and then reset the clock?

#### dtiger2k

Joined Mar 29, 2006
10
It really depends on the type of PWM circuit that you have. If your sawtooth is generated using RC time you should be able to change the capacitor (Ct) and or the resistor(Rt) in that circuit to adjust the frequency without changing the duty cycle.

You can use the formulas below to figure out the time constant needed.

t (in seconds) = R (in ohms) X C (in farads)
t (in seconds) = R (in megohms) X C (in microfarads)

#### windoze killa

Joined Feb 23, 2006
605
Originally posted by dtiger2k@Mar 29 2006, 06:30 PM
It really depends on the type of PWM circuit that you have. If your sawtooth is generated using RC time you should be able to change the capacitor (Ct) and or the resistor(Rt) in that circuit to adjust the frequency without changing the duty cycle.

You can use the formulas below to figure out the time constant needed.
t (in seconds) = R (in ohms) X C (in farads)
t (in seconds) = R (in megohms) X C (in microfarads)
[post=15562]Quoted post[/post]​
What sawtooth???? I didn't see him mention one.

I am not quite sure that you will be able to maintain a PWM signal. The counter you mentioned will only count on the rising edge, falling edge or level of the I/P pulse. If the I/P siganl is PWM then this pulse wdith information will be lost.

What you may have to do is get what ever is modulating the original pulse to modulate a new 35hz oscillator.

#### dtiger2k

Joined Mar 29, 2006
10
What sawtooth???? I didn't see him mention one.
Sawtooth waveform from the oscillator that is determined by the RC Time circuit determines the frequency of the PWM. The square wave pulses come later in the circuit.

What you may have to do is get what ever is modulating the original pulse to modulate a new 35hz oscillator.
And that was what I was telling him.

Thanks

#### windoze killa

Joined Feb 23, 2006
605
Originally posted by dtiger2k@Apr 1 2006, 12:01 PM
Sawtooth waveform from the oscillator that is determined by the RC Time circuit determines the frequency of the PWM. The square wave pulses come later in the circuit.
[post=15669]Quoted post[/post]​
I must be missing something. I can't see any circuit and it is a bit presumptuious to think it is an RC PWM cct. This could be an ouput of a micro. Maybe if Fubar could give a bit more info on his cct we could sort out his problem a bit more.

#### fubar

Joined Mar 22, 2006
11
Originally posted by windoze killa@Apr 1 2006, 12:19 AM
I must be missing something. I can't see any circuit and it is a bit presumptuious to think it is an RC PWM cct. This could be an ouput of a micro. Maybe if Fubar could give a bit more info on his cct we could sort out his problem a bit more.
[post=15677]Quoted post[/post]​
so, this is a commerical engine control unit. (a stand alone ECU). it has a few general purpose outputs that run either DC or at 350hz. as far as what, exactly, creates the signal, i've got no idea whatsoever. to me, it's a black box (like an op amp! : ) ) that i put signals in and get them out. i cannot condition anything but the duty cycle; the frequency's fixed. and that's what so lame. i have always assumed that digital guys can take almost anything i can do in math and convert it to a circuit. i still believe it, too. but, yeah, i guess i would concur with your description of it is the "output of a micro."

#### pebe

Joined Oct 11, 2004
626
Originally posted by fubar@Apr 1 2006, 02:52 PM
so, this is a commerical engine control unit. (a stand alone ECU). it has a few general purpose outputs that run either DC or at 350hz. as far as what, exactly, creates the signal, i've got no idea whatsoever. to me, it's a black box (like an op amp! : ) ) that i put signals in and get them out. i cannot condition anything but the duty cycle; the frequency's fixed. and that's what so lame. i have always assumed that digital guys can take almost anything i can do in math and convert it to a circuit. i still believe it, too. but, yeah, i guess i would concur with your description of it is the "output of a micro."
[post=15686]Quoted post[/post]​
The chances are that the 350Hz signals have a variable duty cycle from which the original analogue signal can be derived.

I remember from a posting elsewhere that you wanted to drive a solenoid from them. Can you measure their mean DC level with a voltmeter? If so, at what level would you require the solenoid to operate?

#### windoze killa

Joined Feb 23, 2006
605
Originally posted by fubar@Apr 2 2006, 01:52 AM
so, this is a commerical engine control unit. (a stand alone ECU). it has a few general purpose outputs that run either DC or at 350hz. as far as what, exactly, creates the signal, i've got no idea whatsoever. to me, it's a black box (like an op amp! : ) ) that i put signals in and get them out. i cannot condition anything but the duty cycle; the frequency's fixed. and that's what so lame. i have always assumed that digital guys can take almost anything i can do in math and convert it to a circuit. i still believe it, too. but, yeah, i guess i would concur with your description of it is the "output of a micro."
[post=15686]Quoted post[/post]​
Can you be a little clearer on what you wish to achieve? Do you really need to use the ECU that you have or could you get by with another circuit to do the same job?

#### fubar

Joined Mar 22, 2006
11
Originally posted by windoze killa@Apr 2 2006, 06:28 AM
Can you be a little clearer on what you wish to achieve? Do you really need to use the ECU that you have or could you get by with another circuit to do the same job?
[post=15722]Quoted post[/post]​
i need to modulate the PWM signal at 14V to a solenoid valve. the max frequency must be less than 50hz. i could use another ecu and spend mucho bucks but i don't want to. i need to be able to change the PW as a function of engine RPM, throttle position (a 0-5V signal) and boost pressure which i think is also 0-5V. thanks.

#### pebe

Joined Oct 11, 2004
626
Originally posted by fubar@Apr 3 2006, 04:19 PM
i need to modulate the PWM signal at 14V to a solenoid valve. the max frequency must be less than 50hz. i could use another ecu and spend mucho bucks but i don't want to. i need to be able to change the PW as a function of engine RPM, throttle position (a 0-5V signal) and boost pressure which i think is also 0-5V. thanks.
[post=15756]Quoted post[/post]​
I'm confused about how the solenoid works. If you feed it with 50Hz it will rattle. So how does altering the duty cycle affect its action? What does the solenoid actually do?

#### fubar

Joined Mar 22, 2006
11
Originally posted by pebe@Apr 3 2006, 11:56 AM
I'm confused about how the solenoid works. If you feed it with 50Hz it will rattle. So how does altering the duty cycle affect its action? What does the solenoid actually do?
[post=15758]Quoted post[/post]​
if it's fed 50hz, it will open and close. if it's fed 350hz, it'll vibrate at that frequency but the core itself has too much inertia actually get to either end point, meaning that it is not fully opened or closed, it just makes noise. the solenoid moves a valve seal against an orifice.

#### dtiger2k

Joined Mar 29, 2006
10
Quick request, can you take a picture of the circuit and post it? Preferably close up so that parts can be read. A schematic would help also if you have it. Also is there a name and model of the ECU? I'm pretty sure someone here can help with enough info. Personally, I work on valves and valve driver cards all the time, same concept. Modifying a circuit without pertinent information is impossible.

i have always assumed that digital guys can take almost anything i can do in math and convert it to a circuit. i still believe it, too.
It's hard to do a math problem without the correct variables.

#### fubar

Joined Mar 22, 2006
11
Originally posted by dtiger2k@Apr 3 2006, 12:48 PM
Quick request, can you take a picture of the circuit and post it? Preferably close up so that parts can be read. A schematic would help also if you have it. Also is there a name and model of the ECU? I'm pretty sure someone here can help with enough info. Personally, I work on valves and valve driver cards all the time, same concept. Modifying a circuit without pertinent information is impossible.
It's hard to do a math problem without the correct variables.
[post=15761]Quoted post[/post]​
ok, this is getting silly:
the boundary condition is a waveform. period. we're not changing the driving circuit because it's propietary and it isn't propietary to me. it's not mine. so. we have a waveform. that's VERY well defined as a PWM signal with amplitude of 14V and modulation frequency of 350HZ. those are the givens. i don't see what's so hard about the conceptualization. i want to take the output of the ECU (solenoid driver, whatever) and make the solenoid open and close reliably. with the info i've provided, i can easily write a routine in mathCAD or labview or whatever that can do this. no extra,hidden variables. i can do it symbolically or numerically. so, a PWM signal is a top hat function with uneven off/on times. variable one. it has a fixed amplitude. variable two. it has a frequency that is known. variable three. what else could possibly be known about the waveform???? i am sorry if i sound irritated; but, come on, i am not redoing the source. i asked for a converter. if it's not possible then forget it. i don't believe it's not possible and i am absolutely sure that i (the newbie who knows virtually nothing about electronics) can do it with two or three 555s and a some other secondary stuff like resistors and caps.

#### pebe

Joined Oct 11, 2004
626
Originally posted by fubar@Apr 3 2006, 07:22 PM
ok, this is getting silly:
the boundary condition is a waveform. period. we're not changing the driving circuit because it's propietary and it isn't propietary to me. it's not mine. so. we have a waveform. that's VERY well defined as a PWM signal with amplitude of 14V and modulation frequency of 350HZ. those are the givens. i don't see what's so hard about the conceptualization. i want to take the output of the ECU (solenoid driver, whatever) and make the solenoid open and close reliably. with the info i've provided, i can easily write a routine in mathCAD or labview or whatever that can do this. no extra,hidden variables. i can do it symbolically or numerically. so, a PWM signal is a top hat function with uneven off/on times. variable one. it has a fixed amplitude. variable two. it has a frequency that is known. variable three. what else could possibly be known about the waveform???? i am sorry if i sound irritated; but, come on, i am not redoing the source. i asked for a converter. if it's not possible then forget it. i don't believe it's not possible and i am absolutely sure that i (the newbie who knows virtually nothing about electronics) can do it with two or three 555s and a some other secondary stuff like resistors and caps.
[post=15765]Quoted post[/post]​
I think the neatest solution would be to pad down the input and feed it into a microcontroller, and measure on and off times to establish the duty cycle. Then generate a 35Hz (50Hz?) signal with the same duty cycle.

An alternative would be to get the mean DC value of incoming 350Hz waveform to establish the duty cycle and use that to control a 555 to generate the new signal. I doubt whether you would be able to reproduce the full limits of mark and space, though.

#### dtiger2k

Joined Mar 29, 2006
10
I'm not sure that you can do it from the output without losing your duty cycle which would defeat the purpose. That is why I have been trying to figure out a way from the circuit that you have. I didn't realize that you could not modify that circuit. Maybe someone else knows of a way to do it with the output. And I'll quit wasting your time with posts. (No sarcasm intended).

Daniel

#### fubar

Joined Mar 22, 2006
11
Originally posted by dtiger2k@Apr 3 2006, 04:04 PM
I'm not sure that you can do it from the output without losing your duty cycle which would defeat the purpose. That is why I have been trying to figure out a way from the circuit that you have. I didn't realize that you could not modify that circuit. Maybe someone else knows of a way to do it with the output. And I'll quit wasting your time with posts. (No sarcasm intended).
Daniel
[post=15767]Quoted post[/post]​
i didn't mean to diss (is that how it's spelled?) you. i am just saying that i can't believe that you guys can't do this really easily. but, yeah, i sure as heck don't want to lose the duty cycle! if it can't be easily done, it's not a huge deal. i threw a pc on the dyno already as an interceptor running mathcad and it worked but why have so much electronics to do something that i can imagine in my tiny little head???

#### n9352527

Joined Oct 14, 2005
1,198
Further on pebe idea, you could filter the 350Hz PWM signal to a mean DC value and build a 35Hz sawtooth oscillator. Fed both signals to a comparator and adjust the level and amplitude of the sawtooth so that the output would represent the original PWM signal duty cycle. This is usually how a PWM is generated, the difference is the control voltage in this case is proportional to the original signal duty cycle.

Btw, you've surely realised by now that simply dividing the signal freq. by 5 would not preserve the duty cycle.

#### pebe

Joined Oct 11, 2004
626
Originally posted by n9352527@Apr 3 2006, 10:05 PM
Further on pebe idea, you could filter the 350Hz PWM signal to a mean DC value and build a 35Hz sawtooth oscillator. Fed both signals to a comparator and adjust the level and amplitude of the sawtooth so that the output would represent the original PWM signal duty cycle. This is usually how a PWM is generated, the difference is the control voltage in this case is proportional to the original signal duty cycle.

Btw, you've surely realised by now that simply dividing the signal freq. by 5 would not preserve the duty cycle.
[post=15770]Quoted post[/post]​
Hi Furbar,

Here is a circuit that should do what you require and requires no adjustment. This is how it works. To keep figures simple, assume for the moment that the supply voltage is 9V, rather than 14V.

The amplifier IC1 is fed with a 0 to 9V signal through the potential divider R1,R2. The ve amp input sees that signal as being 0 to 3V signal from a source of 10K. The 10K feedback gives a unity gain, with inversion. The 3V offset at the +ve input means that the applied signal going from 0 to 9V would appear at the output as going from 6V to 3V. C1 integrates so the output is the mean DC level of the pulses.

The 555 timer runs as an astable at approx 40Hz and the waveform at pin2 is triangular going between 3V and 6V (f=0.72/C*R).

IC2 is used as a comparator. The 3V to 6V waveform applied to the +ve input, and the mean DC level at which the waveform will be sliced is fed to the ve input.

The result from IC2 output is a 40Hz square wave with a mark/space ratio in phase with the original signal. It will need a driver for your solenoid.