# closed loop in power electronics,selecting best ardunio board

hi all,
thanx for the ardunio first!!

I am a student ,doing research in power electronics. I have made a circuit for which a closed loop has to be designed(i mean to generate a final pulse to trigger a switch by considering the values from the sensors). To do this , I have a big math equation which has differentiation, integration & all , that are done on the outputs of the sensors.
so, I need to dump this equation in the micocontroller to get a final wave, so that I can compare it with a ramp to generate a PWM to trigger my switches.
now I want to do the whole stuff with a ardunio board as a controller and all voltage,current sensors,ADC & DAC etc.

and my Question is which board of ardunio that I need to select and can ardunio work with this?
my requirements:

fast response form the controller.
my switching frequency is 50Khz.
I have done a similar project with a DSP controller, now I was interested in ardunio.

The fastest PWM frequency you can get with the digital output PWM pins is 980 hz (D5 & D6 only)

If you need 50 khz you need to use Timer1.
http://playground.arduino.cc/Code/Timer1
The Timer1 statement takes a PERIOD (uS), (not a FREQUENCY) so the period for 50khz is 20uS.(in the INITIALIZATION statement)
The dutycycle is in the Timer1pwm statement and it is an integer between 0 and 1024 (NOT a %)
See example below:

``````  pinMode(10, OUTPUT);
Timer1.initialize(500000);         // initialize timer1, and set a 1/2 second period
Timer1.pwm(9, 512);                // setup pwm on pin 9, 50% duty cycle
``````

I got working with the timer.I thought of buying ardunio DUE.
can u please say,whether it is capable of doing integration and differentiation of the sensor output .

I can't deem to find any information about your sensors. Did you provide ? Where ?

ARDUINO SIGNAL PROCESSING.pdf (479 KB)

you can always use numerical methods for integration and differentiation.
As far as you question suggests you are trying to make a PID controller out of arduino.
PID - propotional , integral , derivative

please have a glance at the file attached.
what I need to do is

To dump that equation in to a processor/micro controller(the variable are the values that are sensed form voltage and current sensors),all those multiplication and division can be done easily. But I cant understand how to create an equation or code for those integration and differentiation terms present there. =( =(

and thanks to both of you, I got some ideas of combining MATLAB with ARDUINO form your comments itself and I am working on it.

I'm surprised that you don't understand this, since you've already implemented this on a DSP. It is a digital system, so you use standard equations:
(Not Code:)
Difference = (n[k] - n[k-1])/(T)
Integral = SUM(n[0]:n[k])

This is all pretty easy to implement in software.

http://playground.arduino.cc/Code/PIDLibrary

Yes, I know that PID controller design.
got clarified with most of my doubts.
just started the work..I will share it here soon. 8)

one more thing, I am going to order arduino DUE board..the reason is that its 32 bit (all those PWM,adc etc)and has inbuilt DAC(which I need most).
so, any suggestions on that or any improvements and as I am working with AC(230v/50hz) supply and power factor correction stuff ,I need to buy voltage and current sensors, any preferred brand or website for those sensors.

thanks a lot for ur help 8) 8)

Do you know how to calculate how many kVAR you need to correct the power factor ?

plzz could any one tell me how to use arduino to correct the power factor i'n new here and i'm willing to work with aurdino :.

Read the link in Reply#10. You need a watt meter and Ammeter that have some kind of output signal (analog or digital) that can be intefaced with uC. SEE ATTACHED SCREENSHOT.