ultra high speed process control

Go To Last Post
65 posts / 0 new

Pages

Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Dear all,

 

I am currently working on controlling dc-dc converter using arduino. I am working with arduino atmega 2560 (fosc=16MHz) but I am facing a problem. The system (dc-dc converter) is very fast and it needs a sampling time of 13 usec (so small) apparently I had to go to the register level to sample every 13 usec this was not available in the built in function. but the arduino takes 8 msec to execute the main loop ..Do you feel the problem?? I need to sample, execute the control code  and output  a control action in a time less than 13 usec so that I can capture the next sample in the correct timing.

Last Edited: Wed. Oct 25, 2017 - 10:59 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Where are these samples coming from?

 

An interesting app where you need to close the loop every 13us.  That's about 80000/second, right?

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Clearly the samples are not analog as the ADC needs ~100usec to do a conversion @10bit resolution.

What kind of samples are these?

 

Jim

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Sounds like the AVR is the wrong choice for your application. You probably need something like a dspic or other dsp specific processor.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

    An XMEGA in 8 bit mode would do the trick. Use interrupts. Then based on data from ADC you use a lookup table to get your next PWM value that turns on the switching device. This only gives you the proportional part of your PID. You most likely need a full PID. I think a clever asm routine would do it, but then not much left for something else to be done by the micro which rises the question, it is worth to spend a micro and firmware development when there are tons of controllers smaller, cheaper for this task ?

 

    There is an application note that uses DMA and the Even System so the CPU is not involved at all. I did not look at it in detail.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Welcome to the Forum.

 

So, how complex is the control algorithm?

 

Perhaps, if such tight closed loop control is required, one could do the project entirely in analog hardware, and just use the micro to control the start-up, shut-down, and safety control aspects of the control?

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:
Perhaps, if such tight closed loop control is required, one could do the project entirely in analog hardware, and just use the micro to control the start-up, shut-down, and safety control aspects of the control?
Yes

There's mixed signal programmable logic to implement that.

Silego GreenPAK 4 has an ADC that's somewhat faster than a mega2560's ADC and the GreenPAK's ADC data can flow to a PWM block.

 

http://www.silego.com/products/585/312/A-High-Voltage-DC-DC-%D0%A1onverter.html

via http://www.silego.com/products/336/434/SLG46620V.html

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Miramiro wrote:

I am currently working on controlling dc-dc converter using arduino. 

What exactly are the aspects you are wanting to control ?

Do you just want to adjust the output voltage (set point), which is easy, or do you want to try to manage load or line regulation, with PWM variation every switching cycle, which is much harder ? (likely beyond Ardunio)

 

ISTR Microchip has some MCUs with Regulators, but they do not try to modulate the PWM, instead they have a SMPS Controller (analog PWM) and they adjust the set point via MCU.

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
Sounds like the AVR is the wrong choice for your application.
IIRC, AtomicZombie's XMEGA384C3 application has interrupts at the VGA horizontal frequency.

Lots of assembly language; don't recall it using XMEGA's DMAC.

Kartman wrote:
You probably need something like a dspic or other dsp specific processor.
... or PIC and its Programmable Switch Mode Controller (PSMC)

 


http://www.avrfreaks.net/forum/xmega-cranks-out-ntsc-color-and-digital-stereo-sound

Microchip

AN1468

Peripheral Brief: Programmable Switch Mode Controller (PSMC)

http://ww1.microchip.com/downloads/en/AppNotes/01468A.pdf

...

 

WHAT IS THE PSMC?

...

It was designed to meet a need to intelligently and efficiently drive the MOSFET switching of various Switch Mode Power Supplies, lighting, and motor drive applications.

...

via http://www.microchip.com/wwwAppNotes/AppNotes.aspx?appnote=en560057

and http://www.microchip.com/wwwproducts/en/PIC16F1789

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I wonder about the statement that the Arduino code takes 8ms  to "execute the main loop" (eg, 125Hz repetition rate). That is nearly forever for a micro running at 8MHz. I would bet that there are some major improvements that could be gotten right there. 

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That is nearly forever for a micro running at 8MHz.

And two forevers at 16 MHz :)

 

Indeed, it's 128,000 cycles.  What the heck does this thing have to do?  If you really need to close the control loop every 208 cycles (16 x 13), you'll almost certainly need to do this in pure assembler.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Typically a dc-dc converter contain some storage devices (inductor, capacitor), which allow no fast current and voltage changing, so no very fast reaction was needed.

E.g. I use an ATtiny24 as preregulator for a high precision constant current source. The preregulator adjust the voltage over the following linear stage to about 3V. At first the AVR works too fast, so the preregulator was oscillating. Thus I have inserted additional delays to achieve stable working.

Last Edited: Thu. Oct 26, 2017 - 08:26 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

ki0bk wrote:
Clearly the samples are not analog as the ADC needs ~100usec to do a conversion @10bit resolution.

One could certainly have an external ADC with the needed 70ksps.  But then you still have to get it into the microcontroller, and do something with it.

 

My curiosity is about a DC-DC converter that needs to close its loop every sample.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am doing a voltage control loop for a dc-dc converter. (I want to regulate the output voltage at 5 v regardless of the variation in the input voltage) so I read the output voltage of the converter using an adc in the arduino.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am doing a voltage control loop for a buck converter (my target is to regulate the output voltage at 5 volts regardless of the input voltage variation). The samples here are the readings of my output voltage.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

these are samples from the output voltage of my buck converter (my target is to regulate the voltage at 5 volts regardless of the variation in input voltage) so I take samples from the output voltage every 13 usec and calculate a control action (duty) and update the duty of the MOSFET and repeat the loop

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is interesting . what do you mean by DMA .I didnt come across this before. My target is to regulate the ouput a buck converter at 5 volts regardless of the value of the input (vinput varies from 6 volts to 10volts). Is there a digitak controller for this without using a micro or arduino?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I got the time of the loop by calling the function micros at the beginning and the end of the loop and subtracts each 2 successive times 

the loop is not a big deal just these lines

 

void loop() {

feedback_volt=read_adc();

current_error=1023-feedback_volt;

if(current_error==0)
{
  duty=160;
}

current_Vc=(M*current_error)-(N*previous_error)+(L*previous_Vc);

duty=current_Vc*(160);

if(duty>=160)
{

  duty=160;
}

custom_Awrite(duty);

previous_error=current_error;

previous_Vc=current_Vc;

}

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I used micros again now and the times taken was 400 usec not 8 msec like yesterday. but yet 400 usec is larger than the execution time I need

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well my target is to regulate the output voltage  from the buck at 5 volts regardless the change of the supply voltage, the supply voltage changes from 6 volts to 10 volts and I have to get 5 volts from the buck 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have used the function micros() , I called it at the beginning of the loop and at the end of the loop and subtracted the two successive value.

I tired this function way now and it gave me just 400 usec. I didnt change anything in the code . is this way messy

this is the main loop. not a big deal

 

void loop() {

feedback_volt=read_adc();

current_error=1023-feedback_volt;

if(current_error==0)
{
  duty=160;
}

current_Vc=(M*current_error)-(N*previous_error)+(L*previous_Vc);

duty=current_Vc*(160);

if(duty>=160)
{

  duty=160;
}

custom_Awrite(duty);

previous_error=current_error;

previous_Vc=current_Vc;

}

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not enough info to even guess at you problem, can you post your complete sketch?  (Please use the code tag "<>" in the edit window.)

What you have shown should not take 8ms to complete unless there is something in one of the functions that is causing the delay.

Thus the need to see the whole sketch.

 

Jim

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

how do you calculate the speed of any microcontroller. I wanna know this please

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Its is a buck converter . My target is to regulate the voltage at 5 volts regardless of the value of supply voltage. The supply should vary from 6 v to 10 v

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Miramiro wrote:

how do you calculate the speed of any microcontroller. I wanna know this please

That depends on the speed of its cpu clock and it's architecture, so is not an easy question to answer.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Miramiro wrote:
I read the output voltage of the converter using an adc in the arduino.

But an AVR8 will only get a new reading about every 100us.  [I don't know max sampling in Arduino environment]

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
byte duty=0;
float current_Vc=0.0;
float current_error=0.0;
float previous_Vc=0.0;
float previous_error=0.0;
float M=1.071;
float N=0.92;
float L=0.987;
uint16_t feedback_volt;


void setup()
{
  //Serial.begin(9600);
TCCR1A=(1<<COM1A1) | (0<<COM1A0) | (1<<COM1B1) | (1<<COM1B0) | (0<<COM1C1) | (0<<COM1C0) | (0<<WGM11) | (0<<WGM10); // WGbits determine the mode
                                                                                                                   // COM bits determine inverted or not                                                                                                                   //  1 1= inverting but 1 0= non inverting
TCCR1B=(0<<ICNC1) | (0<<ICES1) | (1<<WGM13) | (0<<WGM12) | (0<<CS12) | (0<<CS11) | (1<<CS10);   //CS=clock source 16 mhz //ICN=input canceller noise :off

TCNT1H=0x00; // timer 1

TCNT1L=0x00; //timer 1 

ICR1H=0x00;
ICR1L=0xA0; //top=160 decimal 

pinMode(11,OUTPUT);

 }                                                                                               
                                                                                                

void custom_Awrite(byte duty) 
{

 OCR1AH=0x00;
 OCR1AL=duty;
 

}

uint16_t read_adc()
{  
   ADMUX = 0b01000000;           //Internal 5V Voltage Reference with external capacitor at AREF pin 
                                 // and channel 0 selection
   
   ADCSRB |= (0<<MUX5);   
   ADCSRA |=(0<<ADPS0)|(0<<ADPS1)| (1<<ADPS2);  

   
   ADCSRA |= (1<<ADSC);      //Starts a new conversion
 
   while(ADCSRA & (1<<ADSC));  //Wait until the conversion is done
   
   return ADCW;
 
 }         //Returns the ADC value of the chosen channel
                                                                                                                         




void loop() {

feedback_volt=read_adc();


current_error=1023-feedback_volt;

if(current_error==0)
{
  duty=160;
}


current_Vc=(M*current_error)-(N*previous_error)+(L*previous_Vc);


duty=current_Vc*(160);

if(duty>=160)
{

  duty=160;
}


custom_Awrite(duty);

previous_error=current_error;

previous_Vc=current_Vc;


}







 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What does posting the code have to do with your 13us requirement, when you stated you are using the AVR's ADC which gives a new reading about every 100us?

 

On top of that, it appears that you are using a polling ADC.

 

Using floats, especially, your loop() is going to be quite slow.  ADC results are 10 bits.  "duty" is also a small integer.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am now searching on writing an interrupt service routine but I wanna know what should the speed of the arduino be in this case. I wanna know if the problem could be fixed that way or should i look fo another controller

How can I know the speed of the arduino (f=16 Mhz)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Miramiro wrote:
but I wanna know what should the speed of the arduino be in this case.

Your mentioned 13us requirement between samples, and use of the AVR8 ADC for that sampling, simply makes no sense to ask about Arduino speed as

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
ADCSRB |= (0 << MUX5);
ADCSRA |= (0 << ADPS0) | (0 << ADPS1) | (1 << ADPS2); // clk/16=1mhz

This clock is too fast for 10 bit resolution, and the use of "|=" is questionable, you should just "=" to be sure all bits are set as you expect.

 

Jim

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Miramiro wrote:
... or should i look fo another controller
tinyAVR 1-series ADC have a 16-bit result register with an accumulator of up to 64 8b or 10b samples.

Max sample rate is 150Ksps for 8b and 115Ksps for 10b (reference voltage >= 1.1V for both rates)

 

http://www.microchip.com/wwwproducts/en/attiny1617

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

... or PIC and its Programmable Switch Mode Controller (PSMC)

The megaAVR equivalent is Power Stage Controller (PSC)

"power stage control" is stated for XMEGA E WeX; WeX or AWeX is a part of all XMEGA.

 

Microchip Technology Inc

Microchip

AVR434: PSC Cookbook for AT90PWM devices

http://www.microchip.com//wwwAppNotes/AppNotes.aspx?appnote=en591265

http://www.microchip.com/wwwproducts/en/AT90PWM316 (3 PSC, 16KB flash)

http://www.microchip.com/wwwproducts/en/ATMEGA64M1 (1 PSC, 64KB)

http://www.microchip.com/wwwproducts/en/AT90PWM81 (1 PSC, 8KB)

 

Edit: XMEGA

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Sat. Oct 28, 2017 - 06:36 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Now, I don't know how people tackle this from within the Arduino environment.

 

But just doing it with an AVR8?  I still don't understand this need for speed.  OP's posted code shows only an 8-bit OCR1AL, so only at most 256 steps.  If we say e.g. 0-10V output that is 25 steps/volt, or 40mV resolution.

 

Let's look at the timer now.  Applying "duty" as an OCR value implies PWM to me.  Looks like Mode 14 with ICR1 as TOP, and the comments indicate 160 as TOP -- so that is where the 13us comes from.

 

Is there a real need to update "duty" every PWM pass?  I'd think not.  There is going to be a lag in the "plant" before a read-back value is pertinent.

 

[OK, now we are down to 160 steps, or 16 steps/volt, 60mV resolution.]

 

Still no need for float with those small numbers, IMO.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Getting rid of the FP would help alot, instead of thinking in Volts, think in millivolts.  After all with VREF = 5volts, 10 bit ADC will yield ~5mv lsb.

if you take adc count * 5 ~= millivolts, 0-5000 mV = 0-5volts     All integer math, much faster!

If you want to be more accurate, use 4.88mV instead of 5mV, just scale your values and watch out for overflows when you multiply.  Use 32 bit Long's for that.

 

 

Jim

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Miramiro wrote:

 My target is to regulate the ouput a buck converter at 5 volts regardless of the value of the input (vinput varies from 6 volts to 10volts). 

 

So why do you need software for this ?

 

Miramiro wrote:

 Is there a digitak controller for this without using a micro or arduino?

 

There are shiploads of SMPS controllers out there, that can output at 5 volts regardless of the value of the input (vinput varies from 6 volts to 10volts)

Why not just use one of those ?  They give both line and load regulation, and are designed to do this.

 

To hope to use a software loop here, you need a fast ADC & the simplest control loop is an INC/DEC convergence tracker. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Miramiro wrote:

Its is a buck converter . My target is to regulate the voltage at 5 volts regardless of the value of supply voltage. The supply should vary from 6 v to 10 v


Why not just use SMPS IC's like TL494 or LM3254/3257?
Or for more simple use MC34063A?
.
MG

I don't know why I'm still doing this hobby

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As mentioned by others - it is no use sampling the output of your buck converter on a cycle by cycle basis. Why? The buck converter consists of a switch (mosfet etc), a catch diode, inductor and output capacitor. The output voltage cannot change instantaneously due to the output capacitor - if it could, no current would flow through the inductor as the output would move in concert with the inductor. Thus the inductor/output capacitor form a low pass filter. Your control loop only has to sample at a much lower frequency than the pwm frequency. You can sample as fast as you like, but that won't change how fast the output can actually change. If you sample too fast, then your control code has to integrate a large number of samples otherwise it will overshoot. A sample time of 1ms should be adequate for your application.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In case it's not obvious this thread actually started here:

 

http://www.avrfreaks.net/forum/a...

 

Seems like OP is obsessed about processing speed without having expended much thought about the speed that is actually required or the limitations of the hardware such as the minimum 65us ADC sampling speed that has been mentioned and apparently completely ignored. 

 

I just wonder where the original 13us figure comes from. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
I just wonder where the original 13us figure comes from.

http://www.avrfreaks.net/comment...

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
In case it's not obvious this thread actually started here

No: that thread was actually started when this one had already been running for a while - some time around #36

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Seems like OP is obsessed about processing speed without having expended much thought about the speed that is actually required or the limitations of the hardware

 

Yep, premature optimization is a common problem.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think that the original "concept" was to sample at a high rate and determine each switching point in near-real time. This now seems to have morphed into a timer based PWM that works in an "averaged" mode and at a much lower sample rate, though the OP appears not to have explicitly acknowledged this shift.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Sat. Oct 28, 2017 - 08:07 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

datasheet atmega  2560I got this sampling time from the datasheet of the atmega 2560.. 

I choosed the prescaling of 16 and then the input frequency to the adc is 1MHZ (I need only 8 bit resolution) 

The ADC conversion takes 13 cycles so 1MHZ/13=76.9Khz (sampling rate) which corresponds to 13 usec (This is how I got the 13 usec)

check teh attached screenshot, its from the datasheet of atmega 2560

Last Edited: Sun. Oct 29, 2017 - 06:48 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

before doing the hardware stuff , I simulated the system by Simulink and (the system settles after 100 usec) so I choose sampling time that is nearly 1/10 from the settling time of the system.

Why do people say I should sampel at a much lower frequency if the system is very fast and the supply voltage varies from 6 volts to 10 volts and the ouput should be regulated at 5 volts , so i have many operating points

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I got this sampling time from the datasheet of the atmega 2560.. 

I choosed the prescaling of 16 and then the input frequency to the adc is 1MHZ (I need only 8 bit resolution) 

The ADC conversion takes 13 cycles so 1MHZ/13=76.9Khz (sampling rate) which corresponds to 13 usec (This is how I got the 13 usec)

please check the attached screenshot, its from the datasheet of atmega 2560.

Why did I chose a sampling of 13 usec  because the system is very fast (settles at 100 usec) and I have wide range of operating points so I choose a sampling time that is nearly1/10 from the settling time (13usec)

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

How are you going to synchronise the sampling with the pwm? Why do we suggest you sample at a lower frequency? Either we have more experience or there’s something you’re not telling us. Realistically, why are you getting a micro to do this job? It’s much better and simpler in the analog domain.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

How are you going to synchronise the sampling with the pwm? Why do we suggest you sample at a lower frequency? Either we have more experience or there’s something you’re not telling us. Realistically, why are you getting a micro to do this job? It’s much better and simpler in the analog domain.

 

Well the system has a wide range of operating points and it actually has two operating modes (it works as buck when Vin > 5 volts and works as boost when the Vin < 5 volt);which mean its not a simple buck but an non inverting buck boost. in the boost mode .there are different controller gains according to the operating point. That is why I wanna implement it by a digital controller .The idea is that I am gonna detect the voltage at the input and determine the opertaing mode if (buck) then I control through lag compensator .If the vi<5 v the  its in the boost mode and I choose the controller gains according to the operating point in the boost mode.

 

The IC's that some people suggested are very amazing but this task that I am doing is part of my graduation project so we should do the control not buy an IC that does the control.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Seeing the last few posts, I think that you (the  OP = Original Poster) are still quite confused. If you set a counter-based PWM signal to a particular duty cycle, it will continue at that duty cycle until the compare value is changed. If you measure the output and change the duty cycle, the output will change, accordingly. If you do it this way, the system is operating in a average mode. If your software/hardware tests for every individual switching point, and chooses to change, or not change, the state of the FET switch(es) in real time, then it is real-time mode. 

 

What everyone is suggesting is that you operate in averaged mode because an AVR cannot keep up with your system in real-time mode. It cannot even make analog conversions fast enough to do it. Mind you, there are OTHER real-time methods (not using ADC) that can avoid this bottleneck, but I am NOT going to muddy the water with them or even suggest how it might work. 

 

You say that there are many operating points. So what. The operating point will be functions of the input voltage and the load current. So what. You have a feedback system and you are observing only one behavior metric: the output voltage. So long as you compare that output voltage to a reference and use that comparison to determine whether or not the duty cycle needs to be increased or decreased, it is not important what the origin of that change might be. If the input voltage is increased, the duty cycle needs to decrease to maintain the same output because the average output will start to increase. Likewise, if the load current decreases, the average output will start to increase and the duty cycle needs to decrease. You have ONLY one system metric and you have only one degree of control freedom. That is all you have and your system will work fine with that. In reality, you have only ONE operating point: the output voltage. You have only one control mechanism: PWM duty cycle. That is it. So, I argue that there is NOT "a wide range of operating points".

 

You MAY need to average the output voltage with an additional low pass filter. The output capacitor has ripple and you WILL get inappropriate ADC readings since the ADC sample/hold circuit will have the voltage at the instant when the sample switch opens. If it opens at the top of the ripple waveform or at the bottom of the ripple waveform, the returned value will be somewhat different from the average. As a result, you should probably add some additional smoothing (e.g. averaging) to reduce the ripple amplitude at the ADC input. This WILL have some effect on the loop phase shift and resulting stability. You should have the capability to deal with that if you know that it is going to happen.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Sun. Oct 29, 2017 - 10:19 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Miramiro wrote:

....but this task that I am doing is part of my graduation project so we should do the control not buy an IC that does the control.

If you have the ADC managing 13us, the next challenge is to get the MCU to do the control calcs inside that time.

 

You will likely need some careful sync of ADC to PWM and some careful analog-in filtering, as you do not want the PWM frequency & ripple to affect the ADC result.

You do not was a massive analog-in filter, as that adds phase lag.

 

The very simplest control loop is an INC/DEC tracking one, which may be enough if you have a high sampling rate.

This has no math-ops, just a simple compare.

In pseudo code 

IF Vout > Vset THEN 

  DEC(PWM)

ELSIF Vout < Vset THEN

  INC(PWM)

END

 

I'd start with that, and improve it as you take measurements.

 

You might decide to nudge the ADC rate from 13 to 16 cycles, as that gives 256 step PWM at 16MHz

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk wrote:

Seeing the last few posts, I think that you (the  OP = Original Poster) are still quite confused. If you set a counter-based PWM signal to a particular duty cycle, it will continue at that duty cycle until the compare value is changed. If you measure the output and change the duty cycle, the output will change, accordingly. If you do it this way, the system is operating in a average mode. If your software/hardware tests for every individual switching point, and chooses to change, or not change, the state of the FET switch(es) in real time, then it is real-time mode. 

 

What everyone is suggesting is that you operate in averaged mode because an AVR cannot keep up with your system in real-time mode. It cannot even make analog conversions fast enough to do it. Mind you, there are OTHER real-time methods (not using ADC) that can avoid this bottleneck, but I am NOT going to muddy the water with them or even suggest how it might work. 

 

You say that there are many operating points. So what. The operating point will be functions of the input voltage and the load current. So what. You have a feedback system and you are observing only one behavior metric: the output voltage. So long as you compare that output voltage to a reference and use that comparison to determine whether or not the duty cycle needs to be increased or decreased, it is not important what the origin of that change might be. If the input voltage is increased, the duty cycle needs to decrease to maintain the same output because the average output will start to increase. Likewise, if the load current decreases, the average output will start to increase and the duty cycle needs to decrease. You have ONLY one system metric and you have only one degree of control freedom. That is all you have and your system will work fine with that. In reality, you have only ONE operating point: the output voltage. You have only one control mechanism: PWM duty cycle. That is it. So, I argue that there is NOT "a wide range of operating points".

 

 

Jim

Do you mean by real time control ,changing the controller according to the operating point? and If I try implementing this with AVR , things will not work because its over the capabilities of the AVR

Pages