Searching \ for '[PIC]:Externally synced PWM Help.' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=pwm
Search entire site for: 'Externally synced PWM Help.'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]:Externally synced PWM Help.'
2000\10\03@192025 by Michael W. Bogucki

flavicon
face
Hello All,
       I'm working on a small project, and I have encountered a problem
that I am not sure how to tackle. I have already looked at the piclist faq
and could not find the answer there. I've also looked at 3 of the 4 "pic'n
books."
       Essentially I need to take an incoming squarewave, do PWM on the
signal, then output it on another pin. The squarewave would be in the
frequency range of 30-120Hz. I need to be able to vary the duty-cycle of
this signal from 0-100% using 8bits (though 10-90% would be okay.) I
though about using a monostable multivibrator to do this, but it would be
difficult to control with a PC and since the frequency varies, it would be
difficult to say "I need 60% duty cycle", without having to resort to a
scope or other methods to calibrate the RC circuit.
       Has anyone done something like this...or would know where I could
get more info and/or code snippets??
Thanks for your time and help!!

--|\/| | |< E

-------------------------------------------------
| Windows:  Where do you want to go today?        |
|                                                 |
| MacOS:  Where do you want to go tomorrow?       |
|                                                 |
| Linux:  Are you coming, or what!?               |
|                                                 |
| --Wes Yates                                     |
-------------------------------------------------

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2000\10\03@193937 by David Huisman

flavicon
face
I don't understand what you mean by do PWM on incoming signal ?
Do you want to simply synchronize an internally generated PWM with the
incoming waveform ? or are you wanting to measure the duty cycle of the
incoming waveform and use the result to modify the output waveform ?

What micro are you using ? Several already have a couple of PWM outputs
built in, otherwise you can use a timer.

Regards
David Huisman

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu


2000\10\03@222930 by Michael W. Bogucki

flavicon
face
Hi David,
       Sorry for being unclear.

Essentially there would be a squarewave at a 50% duty cycle with a
frequency range between 30 and 120 Hz going into one pin of the pic.
The dutycycle on this incoming signal will always be 50%.
While the pic is running, the incoming frequency would stay constant.
It would not vary from 30 to 120Hz. Rather...one application might output
30Hz...another application 60Hz and so on.

I need the pic to output a squarewave, of the same frequency, that is
synced with the input's rising edge.
       So if you were to look at the input squarewave on channel one of a scope
and the output squarewave on channel two on the same scope, you would see
an identical signal in frequency, syncing at the same time. (in lockstep.)
       The pic's job is to be able to vary the dutycycle on the outputted
signal.

Maybe these examples will clarify what I'm try to do.

=)

----------------------------------------------------------------
Example 1

Scope
Channel 1
        ___     ___     ___     ___
       |   |   |   |   |   |   |   |  Incoming Signal 60Hz
       |   |___|   |___|   |___|   |

                     |
                     v
               Pic is set to 50%
               dutycycle.
                     |
                     v
Scope
Channel 2
        ___     ___     ___     ___
       |   |   |   |   |   |   |   |  Outgoing Signal 60Hz
       |   |___|   |___|   |___|   |  50% duty cycle.

--------------------------------------------------------------------
Example 2
---------

Scope
Channel 1
        ___     ___     ___     ___
       |   |   |   |   |   |   |   |  Incoming Signal e.g. 60Hz
       |   |___|   |___|   |___|   |  50% duty cycle

                     |
                     v
               Pic is set to 20%
               dutycycle.
                     |
                     v

Scope
Channel 2
        _       _       _       _
       | |     | |     | |     | |  Outgoing Signal  60Hz
       | |_____| |_____| |_____| |   20% duty cycle.


--Mike




On Wed, 4 Oct 2000, David Huisman wrote:

{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam.....mitvma.mit.edu


2000\10\03@224009 by Bob Ammerman

picon face
Michael:

Ok,

This is starting to look like a 'well specified' problem. A few questions:

The rising edge of the incoming and outgoing square waves must be in 'sync'.

To what precision? Nanoseconds, microseconds....

How does the PIC know the the correct duty cycle for the output?

How often does the desired duty cycle change?

What is the desired precision on the duty cycle?

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

{Original Message removed}

2000\10\03@224646 by staff

flavicon
face
Michael W. Bogucki wrote:
>
> Hi David,
>         Sorry for being unclear.
>
> Essentially there would be a squarewave at a 50% duty cycle with a
> frequency range between 30 and 120 Hz going into one pin of the pic.
> The dutycycle on this incoming signal will always be 50%.
> While the pic is running, the incoming frequency would stay constant.
> It would not vary from 30 to 120Hz. Rather...one application might output
> 30Hz...another application 60Hz and so on.
>
> I need the pic to output a squarewave, of the same frequency, that is
> synced with the input's rising edge.
>         So if you were to look at the input squarewave on channel one of a scope
> and the output squarewave on channel two on the same scope, you would see
> an identical signal in frequency, syncing at the same time. (in lockstep.)
>         The pic's job is to be able to vary the dutycycle on the outputted
> signal.


I hope you don't mind my nosy-ness, but this sounds like
quite an unsual application... I'm curious! :o)
-Roman

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspam_OUTspamTakeThisOuTmitvma.mit.edu


2000\10\03@225505 by David Huisman

flavicon
face
If you want the application to automatically synch to the incoming signal
and not have to change code for each new frequency. You could measure the
incoming waveform period and the apply an appropriate duty cycle as follows.
(results in 8 bit resolution for 130Hz and 10bit for 30Hz)

Your frequency range is 30Hz to 120Hz (8.3ms to 33.3ms)
1) Set up a timer to 32.5us
2) Count how times the timer times out between 2 leading edges
3) Set the timer to n x 32.5 us to suit duty cycle.
4) Set output port pin High
5) On timeout set port pin low.

Step 1 and 2 only need to be done on initial setup or periodically as
required.

Example: Let incoming signal = 50Hz
Period = 20ms
1) micro counts 615 x 32.5us timeout periods
2) Required duty cycle = 20% so let timer = 2 x 615 / 10 = 123
  (123 * 32.5us = 4ms = 20% of 20ms)
3) Output pin = High, Start timer
4) On timeout, output pin = low

There will no doubt be many ways to accomplish this and above is but one
example of how it could be done. This approach will result in output signal
be synchronised with the input and at same frequency but the duty cycle can
be varied.

You can increase the accuracy by using a smaller timeout period.

Regards

David Huisman

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamspam_OUTmitvma.mit.edu


2000\10\04@045639 by Alan B. Pearce

face picon face
>I hope you don't mind my nosy-ness, but this sounds like
>quite an unsual application... I'm curious! :o)

Sounds to me like a light dimmer or motor speed controller synced to mains frequency.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
"[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's


2000\10\04@163205 by Michael W. Bogucki

flavicon
face
Hi Guys,
       Actually it's for a type of stereoscopic shutter glasses driver
that I am working on. This problem is only a small part of the design...

--|\/| | |< E

-------------------------------------------------
| Windows:  Where do you want to go today?        |
|                                                 |
| MacOS:  Where do you want to go tomorrow?       |
|                                                 |
| Linux:  Are you coming, or what!?               |
|                                                 |
| --Wes Yates                                     |
-------------------------------------------------


On Wed, 4 Oct 2000, Alan B. Pearce wrote:

{Quote hidden}

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
"[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's


2000\10\04@171932 by Michael W. Bogucki
flavicon
face
Hi David,
       You also asked what type of pic am I using, I have been playing
around with the 16F84, the 16F84A and considering the 16C711 for this
project.

--|\/| | |< E

-------------------------------------------------
| Windows:  Where do you want to go today?        |
|                                                 |
| MacOS:  Where do you want to go tomorrow?       |
|                                                 |
| Linux:  Are you coming, or what!?               |
|                                                 |
| --Wes Yates                                     |
-------------------------------------------------

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
"[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's


More... (looser matching)
- Last day of these posts
- In 2000 , 2001 only
- Today
- New search...