CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Frequency Modulation

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
bschriek



Joined: 18 Dec 2007
Posts: 80

View user's profile Send private message Send e-mail

Frequency Modulation
PostPosted: Wed Dec 04, 2019 10:01 am     Reply with quote

Hello,

I want to synchronize 2 switched-mode pwm controllers and therefore i need a 45kHz pulse signal. The duty cycle is not important but must be quite low (5% max). So far so good.... This simple pulse can be realized with a PWM or NCO module.

But now I want to apply Frequency Modulation to the pulse signal.
The frequency must increase linear from 40kHz to 50kHz and linear back again to 40kHz.
This (frequency jitter) will spread the switching noise of the switched-mode power supply and so the result is reduced EMC noise.

The ideal modulation frequency is 250Hz.
Does anybody have an idea how to accomplish this as simple as possible.

I can use different 16F15xxx µcontrollers with PWM, NCO, Comparator or CLC module.

I need a hint.
Best regards,
Bas


Last edited by bschriek on Thu Dec 05, 2019 1:54 am; edited 1 time in total
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Dec 04, 2019 10:11 am     Reply with quote

There are PICs that have that 'FM' peripheral ...though off the top of my head I don't know a number and can't remember what 3 letter 'device' it's called..
DSM ?? maybe... Data Signal Modulator
PIC16F1847, chapter 23....

it's designed to modulate one signal with another, had a whack of 'options'...just never used it...

Jay
diode_blade



Joined: 18 Aug 2014
Posts: 55
Location: Sheffield, South Yorkshire

View user's profile Send private message Send e-mail

PostPosted: Wed Dec 04, 2019 1:15 pm     Reply with quote

Could go down the hardware route using a varactor diode fm modulator and mixer circuit. More components I know. Just a thought.
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Dec 04, 2019 1:52 pm     Reply with quote

Really ? Discrete parts ?? and here I was led to believe PICs can do EVERYTHING ! Smile

Sad thing is I have varactors in a bin here next to some NUMITRONs...
bschriek



Joined: 18 Dec 2007
Posts: 80

View user's profile Send private message Send e-mail

PostPosted: Thu Dec 05, 2019 2:00 am     Reply with quote

The Data Signal Modulator....... I will check this immediately.

I'm even able to add a small µcontroller for the synchronize job only.
So now I can use a very fast interrupt or just a fast program loop because all other household routines are performed by the original µcontroller.

But I like the idea to combine all kind of hardware modules so the synchronization runs autonomous. I'm inspired by AN1890 where WS2812B leds are used.
Ttelmah



Joined: 11 Mar 2010
Posts: 19510

View user's profile Send private message

PostPosted: Thu Dec 05, 2019 4:03 am     Reply with quote

What is changing the duty cycle?.
What you describe, seems to be a fixed possibly 5% signal, not a PWM, whose
frequency is being dynamically changed?.
If so, then the way to do this is a simple table of time values, then have
an interrupt on Timer2 (assuming this controls the PWM), and have this
load a new limit time from the table each time the interrupt occurs.

What else does he PIC have to do?.
If there is actual control of the PWM, this will get much more complex, since
the effective duty cycle will change as you change period.
bschriek



Joined: 18 Dec 2007
Posts: 80

View user's profile Send private message Send e-mail

PostPosted: Thu Dec 05, 2019 4:28 am     Reply with quote

Hello mr Ttelmah,

I use normal analog pwm controller IC's with an internal oscillator for our switched-mode power supply. Analog pwm controller IC's because of the simplicity, speed and cost. Both pwm controller IC's can be synchronized by a digital pulse.

https://www.ti.com/lit/an/slua110/slua110.pdf
At page 3-112 (fig 16, 17 and 18) you will find the "spike" I need to synchronize the analog pwm controller.
So the duty cycle of the synchonisation pulse is not important.

The PIC normally controls all protections of the psu and this is not very critical therefore I think a short interrupt with high repetition frequency is possible.
But I also use a 3rd analog pwm controller IC and this one has also digital parts inside. For example this IC doesn't allow synchronization pulses with a large frequency change. So the frequency must change linear from 40kHz to 50kHz and back in steps of 100Hz max.

There are a lot of other time critical requirements to fulfill but let's start with a simple synchronization pulse.

PS. welcome to the analog world!
Ttelmah



Joined: 11 Mar 2010
Posts: 19510

View user's profile Send private message

PostPosted: Thu Dec 05, 2019 5:36 am     Reply with quote

In which case the lookup table approach is the way to go.

Timer2 has the option to interrupt every pulse or every second, third etc..

Now if you set it to interrupt every eighth pulse, this will give an interrupt at
1/6250 second when the pulse is at 50KHz, and 1/5000th second when at
40KHz.
All the interrupt need to do is change the PR2 value in Timer2 (suggest
writing this directly). Since the interrupt should occur immediately after
the timer reset, the internal counter will be well short of reaching this
so the time should just change smoothly.
All you need is an array of 22 PR2 values, single byte for each, and the
interrupt just increments a counter, if it == 22 sets it back to zero, then
loads the value from this index and write it to the PR2 register. Then exit.
Will give you 11 frequencies changing every 8 cycles of the clock.
Now the value used will need to be not quite linear, since the time interval
will change with the frequency. So if (for instance), your master clock
was 32MHz, and your PWM setup with:

setup_timer2(T2_DIV_BY_1,160,8); //50000 Hz

Now the PR2 intervals would want to ramp from 159 to 199 for periods
of 160 to 200 counts. However because this first time is at the faster
50000Hz rate, we are only about 8% through the total 'time', so the value
in the table would have to be adjusted to give a straight result.
bschriek



Joined: 18 Dec 2007
Posts: 80

View user's profile Send private message Send e-mail

PostPosted: Thu Dec 05, 2019 6:35 am     Reply with quote

Ok, I will give it a try but I hoped for an integrated solution without interrupts or even code changing. I will post the results when ready.
Thanks!
Ttelmah



Joined: 11 Mar 2010
Posts: 19510

View user's profile Send private message

PostPosted: Thu Dec 05, 2019 7:41 am     Reply with quote

There is going to be code whatever you do.
The PIC16F18424, might be what you need. This has the DSM peripheral,
which allows you to modulate one signal with another. You could use the
PWM, and modulate this with the NCO (which this also has). However
setting this all up is going to involve more code than the simple adjust
the PWM approach....
bschriek



Joined: 18 Dec 2007
Posts: 80

View user's profile Send private message Send e-mail

PostPosted: Fri Dec 06, 2019 8:43 am     Reply with quote

Here is my Low-tech interrupt routine solution for my problem.
But I always run my µcontrollers at 8MHz clock frequency maximum (never had a fail in noisy surroundings) and now I need to run at 32MHz. Does this mean a higher risk for the controller to get stuck? Is running at a lower frequency more safe?


Code:

///////////////////////////////////////////////////////////////////////////////
//  Frequency changes linear from 80kHz to 90kHz and back again in steps of 62Hz and cyle time is 3.8mSec
#INT_NCO
// SETUP_NCO(NCO_ENABLED|NCO_PULSE_FREQ_MODE|NCO_PULSE_WIDTH_8|NCO_CLOCK_HFINTOSC, 2621);  // 32.000.000 / 4 / (1048576/ 2621)= 80 kHz,  about 2.3% duty cycle.
// NCO  0A3D = 80kHz,    0AE1 = 85kHz,    0B85 = 90kHz
// NCO 2621d = 80kHz,   2785d = 85kHz,   2949d = 90kHz
void isr()
     {
     i = i + 1;
     if  (i < 161)                                 // 1 to 161 = 160 steps
         {
         NCO_setting = NCO_setting + 2;            // starts at 0x0A3D (2621d)
//       NCO1INCU = 0;
         NCO1INCH=make8(NCO_setting,1);            // MSB
         NCO1INCL=make8(NCO_setting,0);            // LSB
         output_high (Pin_C1);                     // Indicates frequency increases
         }
     if  (i >= 161)                                // 161 to 321= 160 steps
         {
         NCO_setting = NCO_setting - 2;            // returns to 0x0A3D (2621d)
//       NCO1INCU = 0;
         NCO1INCH=make8(NCO_setting,1);            // MSB
         NCO1INCL=make8(NCO_setting,0);            // LSB
         output_low (Pin_C1);                      // Indicates frequency decreases
         }
     if  (i >= 321)                   
         {
         i = 0;
         NCO_setting = 2621;                       // reset value, 0x0A3D (2621d) = 80kHz
         }
     NCO1IF = 0;                                   // Required otherwise does not leave interrupt routine
     }
///////////////////////////////////////////////////////////////////////////////
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Dec 06, 2019 10:08 am     Reply with quote

Going from 8 to 32 megs shouldn't increase the possibilty of the controller 'getting stuck' provided resonable care has been taken in the PCB design (layout, bypass caps, traces,etc.).
You will have a slight increase in power comsumption though as CMOS draws power changing states, so more changes = more power. Not a big deal unless running off an itty, bitty battery.

Jay
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Sat Dec 07, 2019 2:58 pm     Reply with quote

temtronic wrote:
Really ? Discrete parts ?? and here I was led to believe PICs can do EVERYTHING ! Smile

Sad thing is I have varactors in a bin here next to some NUMITRONs...


HAHAHAHA......

I have a TVB-2 Tube Tester on my shelf. (And I used it a couple years ago to restore someone's Westinghouse H-169 Console Radio)

Ahhh, the things gathering dust on our shelves. :P
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group