0% found this document useful (0 votes)
43 views26 pages

MOSFET Electronic Load Design Guide

Uploaded by

Vibhore Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views26 pages

MOSFET Electronic Load Design Guide

Uploaded by

Vibhore Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

Mini-Project, MOSFET based Electronic Load


Manish Kumar Singh, M. Tech ESE SR No. 23654 , DESE, IISc

A BSTRACT
This report is about designing a MOSFET based Electronic Load to dissipate 10 Watts of power.

I O BJECTIVE
Construction and test of a MOSFET based electronic load to dissipate 10 Watts of power.

II I NTRODUCTION
Electronic loads are crucial in the design process of contemporary electronic systems, energy systems, and power distribution
systems. They have the ability to draw power from the Unit Under Test (UUT) according to a specified load pattern for the
purpose of power testing. The electrical power produced by the UUT can either be returned to the grid or directed to a dissipative
load.
Here we are going to design MOSFET based linear load that can dissipate 10 watts of power.

Figure 1: Linear Electronic Load Block Diagram

In Figure-1, we are driving a load through linear power MOSFET and reading current /voltage from it. These Current and
voltage we are feeding to microcontroller and in turn microcontroller regulates its output to regulate Load Power based on
predetermined values.

III C OMPONENT S ELECTION


For the given task, voltage and current ratings were not described, only power was given. Hence some parameters were assumed
and a Programmable Load is designed to handle maximum of 15 Volts and 2 Amps of Load current. To consider boundary
condition scenario, IRF 3205 Power MOSFET was selected to drive Load. Here are few important parameter of IRF 3205:

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 1/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

Sl. No. Parameter Value


1 VDSS 55V
2 RDS 8 mΩ
3 ID 80 A
4 VGSS ±20 V
5 Operating Temperature 175ºC

Table 1: IRF 3205- Power MOSFET

This Electronic Load can be constructed in analog domain but here it is made as Digitally Controlled Electronic Load. For
this ATmega328P was selected as microcontroller. With this microcontroller, multiple modes have achieved as
1. Constant Current
2. Constant Resistance
3. Constant Power

It is displaying Voltage, Current and Power on LCD. This LCD is connected with I2C module for serial data. Controller is Rotary
Encoder, which is used for rolling down different values and selecting them. Sense Resistance is used for measuring current was
taken as 1Ω/10W resistor,
Here i choose 16 bit ADC to give a resolution of 1mA for current, 1mW for Power and 1 ohm for resistance for given 5 volts
supply.
5
ADCResolution = = 76µV (1)
216
So this can be easily used to set the desired resolution, while with 12 bit ADC i can get minimum resolution of 1.22 mV.
The DAC is 12 bit and it can hold 4096 different values for Power MOSFET. LCD Module is 16x2 characters and it is
connected to microcontroller using I2C piggy module. The complete list of parts is given in next section.

IV PART L IST
1. IRF 3205 Power MOSFET
2. Arduino Uno Board

3. I2C LCD module


4. LCD display 16x2
5. ADS1115 ADC
6. MCP4725 DAC

7. Push Buttons
8. Rotary Encoder
9. 1Ω/10W resistor

10. Banana Panel Socket


11. 20A SWG (or lower) wire
12. Heat Sink

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 2/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

V D ESIGN
All the components were soldered on general purpose PCB as per the schematic shown in figure 2. Here we have avoided using
PWM from Arduino because it is giving output only in 8 bits. It means it can take only 255 values where by using 12 bit DAC,
we can take 4096 points to control. Both current and voltage are recorded with 16 bit ADC. Here i have used voltage divider
circuit for reading voltage value:
10
MaxVoltageReadbyADC = x15 = 1.3636V (2)
10 + 100

MaxCurrentReadbyADC = Rsense MaxCurrent = 2Volts (3)


but these resistance are not exactly 1 ohm, hence during coding, measured value of 10K, 100K and Rsense were used. ADS1115,
uses default multiplier of "0.185mv". In the code, to measure current, we make a differential measurement of the voltage on the
"1ohm" load. Since the load is 1ohm, that will give us DIRECTLY the current value since "I = V/R" and R is 1. But the resistor is
not exactly 1ohm, so in my case I’ve adapted the multiplier to 0.0001750. And the main input I’ve used a 10K and 100K divider
and that will equal to a divider of 0.0909090. So, now the multiplier is 0.000185 / 0.0909090 = 0.002035 Now these resistor
values are not perfect so we don’t have exactly 10K and 100K, that’s why my multiplier for voltage read is 0.0021335.
I have used Rotary encoder for selecting current/resistance/power. A rotary encoder is a type of position sensor which is used
for determining the angular position of a rotating shaft. It generates an electrical signal, either analog or digital, according to the
rotational movement.

Figure 2: Schematic of Electronic Load

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 3/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

MOSFET is soldered with 22 SWG wires to allow more current without fail. I have considered this for maximum current of
2 Amps through it. This MOSFET is mounted on heat sink with thermal paste. For loads taking more than 2 Amps, Fan is must.
Finally all parts are installed in PVC box as shown in figure 3.

Figure 3: Interior of Assembled Electronic Load

and the assembled Electronic load is shown in figure- 4.

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 4/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

Figure 4: Assembled Electronic Load

5.1 Programming
The C code is written in Arduino IDE. Different libraries of ADC, DAC, I2C and LCD was installed. For sounds, open source
library is used. The algorithm is as follows:

Algorithm 1 Electronic Load Algorithm


1. Initialize LCD

2. Initialize ADC
3. Initialize DAC
4. Configure Push Buttons and Buzzer

5. Initialize Rotary Encoder


6. Define minimum resolution
7. Define multiplication factor for voltage and current
8. ADC data dump

9. Menu Selection
10. DAC value based on PI //it was too slow, limited by atmega, so finally moved to manual increment/decrement
11. Rotary Encoder selection for Constant Power/Current/Resistance

The code was compiled and ported into microcontroller. The code is as follows:
/ / Author : Manish Kumar S i n g h
/ / Date : 04 Apr 2024
/ / Department : DESE , I I S c

# i n c l u d e <hd44780 . h>

# i n c l u d e < L i q u i d C r y s t a l . h>

/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / L i b r a r y f o r i 2 c LCD / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 5/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

# i n c l u d e <Wire . h>
# i n c l u d e <L i q u i d C r y s t a l I 2 C . h> //
L i q u i d C r y s t a l I 2 C l c d ( 0 x27 , 1 6 , 2 ) ; / / s l a v e a d d r e s s s o m e t i m e s c a n be 0 x 3 f o r 0 x27 . Try
both !
u i n t 8 t a r r o w [ 8 ] = {0 x0 , 0 x4 , 0 x6 , 0 x3f , 0 x6 , 0 x4 , 0 x0 } ;
u i n t 8 t ohm [ 8 ] = {0xE , 0 x11 , 0 x11 , 0 x11 , 0xA , 0xA , 0x1B } ;
u i n t 8 t up [ 8 ] = {0 x0 , 0 x0 , 0 x4 , 0xE , 0x1F , 0 x4 , 0x1C , 0 x0 } ;

/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / Library f o r ADS1115 ADC


///////////////////////////////// /
# i n c l u d e <A d a f r u i t A D S 1 0 1 5 . h> //
A d a f r u i t A D S 1 1 1 5 a d s ( 0 x48 ) ; / / Define i2c address
# d e f i n e ADS1115 CONVERSIONDELAY ( 1 )
# d e f i n e ADS1015 CONVERSIONDELAY ( 1 )

/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / L i b r a r y f o r MCP4725 DAC
//////////////////////////////////
# i n c l u d e <A d a f r u i t M C P 4 7 2 5 . h> //
/ / You n e e d BusIO l i b r a r y a s w e l l / / i n s t a l l i t w i t h A r d u i n o l i b r a r y manager i f you
don ’ t h a v e i t
Adafruit MCP4725 dac ;
/ / Set t h i s value to 9 , 8 , 7 , 6 or 5 to a d j u s t the r e s o l u t i o n
# d e f i n e DAC RESOLUTION ( 9 ) / / DAC r e s o l u t i o n 12 BIT : 0 t o 4056
//////////////////////////////////////////////////////////////////////////////////////

/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / INPUTS / OUTPUTS
/////////////////////////////////////
i n t SW = 8 ; / / p u s h b u t t o n from e n c o d e r
i n t SW red = 1 1 ; / / ( i n my c a s e ) r e d p u s h b u t t o n f o r s t o p / r e s u m e
i n t SW blue = 1 2 ; / / ( i n my c a s e ) b l u e p u s h b u t t o n f o r menu
i n t Buzzer = 3; / / B u z z e r c o n n e c t e d on p i n D3
//////////////////////////////////////////////////////////////////////////////////////

i n t Delay = 300; / / T h i s i s t h e LCD r e f r e s h r a t e . Each 300ms .


unsigned long p r e v i o u s M i l l i s = 0; / / V a r i a b l e s u s e d f o r LCD r e f r e s h l o o p
unsigned long c u r r e n t M i l l i s = 0; / / V a r i a b l e s u s e d f o r LCD r e f r e s h l o o p
i n t Rotary counter = 0; / / V a r i a b l e used to s t o r e the encoder p o s i t i o n
i n t Rotary counter prev = 0; / / V a r i a b l e used to s t o r e the p r e v i o u s value of
encoder
bool c l k S t a t e ; / / S t a t e o f t h e CLK p i n from e n c o d e r ( HIGH o r LOW)
bool L a s t S t a t e ; / / L a s t s t a t e o f CLK p i n from e n c o d e r ( HIGH o r LOW
)
bool d t S t a t e ; / / S t a t e o f t h e DT p i n from e n c o d e r ( HIGH o r LOW)
i n t Menu level = 1; / / Menu i s s t r u c u r e d by l e v e l s
i n t Menu row = 1 ; / / Each l e v e l c o u l d h a v e d i f f e r e n t rows
i n t push count ON = 0; / / V a r i a b l e s u e d a s c o u n t e r t o d e t e c t when a
b u t t o n i s r e a l l y pushed ( debaunce )
i n t push count OFF = 0; / / V a r i a b l e s u e d a s c o u n t e r t o d e t e c t when a
b u t t o n i s NOT p u s h e d ( d e b a u n c e )
String space string = ” ”; / / u s e d t o p r i n t a l i n e on LCD
String space string mA = ” ”; / / u s e d t o p r i n t a l i n e on LCD

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 6/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

String pause string = ””; / / u s e d t o p r i n t s o m e t h i n g on LCD


b o o l SW STATUS = f a l s e ; / / S t o r e t h e s t a t u s of t h e r o t a r y encoder push
button ( pressed or not )
bool SW red status = f a l s e ; / / S t o r e t h e s t a t u s of t h e pause / resume b u t t o n (
pressed or not )
bool pause = f a l s e ; / / s t o r e the s t a t u s of pasue ( enabeled or d i s a b l e d
)

/ / Variables f o r s t o r i n g e a c h d e c i m a l f o r c u r r e n t , r e s i s t a n c e and power .


b y t e Ohms 0 = 0;
b y t e Ohms 1 = 0;
b y t e Ohms 2 = 0;
b y t e Ohms 3 = 0;
b y t e Ohms 4 = 0;
b y t e Ohms 5 = 0;
b y t e Ohms 6 = 0;
b y t e mA 0 = 0;
b y t e mA 1 = 0;
b y t e mA 2 = 0;
b y t e mA 3 = 0;
b y t e mW 0 = 0;
b y t e mW 1 = 0;
b y t e mW 2 = 0;
b y t e mW 3 = 0;
b y t e mW 4 = 0;

/ / V a r i a b l e s f o r ADC r e a d i n g s
f l o a t ohm setpoint = 0;
f l o a t mA setpoint = 0;
f l o a t mW setpoint = 0;
i n t dac value = 0;

/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / IMPORTANT
//////////////////////////////////////////////////////////////////
/ * T h i s p a r t i s i m p o r t a n t . You s e e , when you u s e t h e ADS1115 , t o p a s s from b i t v a l u e s
( 0 t o 6 5 0 0 0 ) , we u s e a m u l t i p l i e r
By d e f a u l t t h a t i s ” 0 . 1 8 5 mv” o r ” 0 . 0 0 0 1 8 5V ” . I n t h e code , t o m e a s u r e c u r r e n t , we
make a d i f f e r e n t i a l m e a s u r e m e n t o f t h e v o l t a g e
on t h e ”1ohm” l o a d . S i n c e t h e l o a d i s 1ohm , t h a t w i l l g i v e u s DIRECTLY t h e c u r r e n t
v a l u e s i n c e ” I = V / R” and R i s 1 .
BUT ! ! ! The r e s i s t o r i s n o t e x a c t l y 1ohm , s o i n my c a s e I ’ ve a d a p t e d t h e m u l t i p l i e r
to 0.0001750.*/

const f l o a t m u l t i p l i e r = 0.0001750; / / M u l t i p l i e r used f o r ” c u r r e n t ” read between


ADC0 and ADC1 o f t h e ADS1115
/////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////////////

/ * But i n t h i s c a s e , t h e v o l t a g e r e a d i s from a v o l t a g e d i v i d e r . You s e e , t h e ADS1115


c a n o n l y m e a s u r e up t o 5V .
I f t h e i n p u t i s h i g e r i t w i l l g e t damaged . So , f o r t h a t b t w e e n t h e ADS1115 and t h e
main i n p u t I ’ ve u s e d a 10K and 100K d i v i d e r and
t h a t w i l l e q u a l t o a d i v i d e r o f 0 . 0 9 0 9 0 9 0 . So , now t h e m u l t i p l i e r i s 0 . 0 0 0 1 8 5 /
0.0909090 = 0.002035
Now t h e s e r e s i s t o r v a l u e s a r e n o t p e r f e c t n e i g h t e r s o we don ’ t h a v e e x a c t l y 10K and

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 7/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

100K, t h a t ’ s why my m u l t i p l i e r f o r v o l t a g e r e a d
i s 0.0021335. */

const f l o a t multiplier A2 = 0.0021335; / / M u l t i p l i e r f o r v o l t a g e r e a d from t h e 10K


/ 1 0 0K d i v i d e r
/////////////////////////////////////////////////////////////////////////////////////////////

void setup ( ) {
lcd . i n i t () ; / / S t a r t i 2 c c o m m u n i c a t i o n w i t h t h e LCD
lcd . backlight () ; / / Activate backlight

lc d . c r e a t e C h a r (0 , arrow ) ; / / c r e a t e t he arrow c h a r a c t e r
l c d . c r e a t e C h a r ( 1 , ohm ) ; / / c r e a t e t h e ohm c h a r a c t e r
l c d . c r e a t e C h a r ( 2 , up ) ; / / c r e a t e t h e up a r r o w c h a r a c t e r

lcd . clear () ;
lcd . setCursor (0 ,0) ;
l c d . p r i n t ( ” MANISH−DESE ” ) ;
t o n e ( Buzzer , 5 0 0 , 1 0 0 ) ;
delay (100) ;
t o n e ( Buzzer , 7 0 0 , 1 0 0 ) ;
delay (100) ;
t o n e ( Buzzer , 1 2 0 0 , 1 0 0 ) ;
delay (300) ;
lcd . setCursor (0 ,1) ;
l c d . p r i n t ( ” ELECTRONIC LOAD” ) ;
delay (2000) ;

PCICR | = ( 1 << PCIE0 ) ; / / e n a b l e PCMSK0 s c a n


/ / PCMSK0 | = ( 1 << PCINT0 ) ; / / S e t p i n D8 t r i g g e r an i n t e r r u p t on s t a t e c h a n g e .
PCMSK0 | = ( 1 << PCINT1 ) ; / / P i n 9 (DT) i n t e r r u p t . S e t p i n D9 t o t r i g g e r an
i n t e r r u p t on s t a t e c h a n g e .
PCMSK0 | = ( 1 << PCINT2 ) ; / / P i n 10 (CLK) i n t e r r u p t . S e t p i n D10 t o t r i g g e r an
i n t e r r u p t on s t a t e c h a n g e .
DDRB &= B11111001 ; / / P i n s 8 , 9 , 10 a s i n p u t
pinMode ( Buzzer , OUTPUT) ; / / B u z z e r p i n s e t a s OUTPUT
d i g i t a l W r i t e ( Buzzer , LOW) ; / / B u z z e r t u r n e d OFF
pinMode (SW, INPUT PULLUP ) ; / / Encoder b u t t o n s e t as i n p u t with p u l l u p
pinMode ( SW blue , INPUT PULLUP ) ; / / Menu b u t t o n s e t a s i n p u t w i t h p u l l u p
pinMode ( SW red , INPUT PULLUP ) ; / / Stop / resume b u t t o n s e t as i n p u t with p u l l u p
delay (10) ;

ads . begin ( ) ; / / S t a r t i 2 c c o m m u n i c a t i o n w i t h t h e ADC


a d s . s t a r t C o m p a r a t o r S i n g l e E n d e d ( 2 , ADS1015 REG CONFIG MODE CONTIN ) ;
a d s . s t a r t C o m p a r a t o r S i n g l e E n d e d ( 3 , ADS1015 REG CONFIG MODE CONTIN ) ;
delay (10) ;

d a c . b e g i n ( 0 x60 ) ; / / S t a r t i 2 c c o m m u n i c a t i o n w i t h t h e DAC ( s l a v e a d d r e s s s o m e t i m e s
c a n be 0 x60 , 0 x61 o r 0 x62 )
delay (10) ;
d a c . s e t V o l t a g e ( 0 , f a l s e ) ; / / S e t DAC v o l t a g e o u t p u t o t 0V (MOSFET t u r n e d o f f )
delay (10) ;

previousMillis = millis () ;

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 8/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

void loop ( ) {
i f ( ! d i g i t a l R e a d ( SW red ) && ! S W r e d s t a t u s ) {
p u s h c o u n t O F F +=1;
i f ( push count OFF > 10) {
t o n e ( Buzzer , 1 0 0 0 , 3 0 0 ) ;
pause = ! pause ;
SW red status = true ;
push count OFF =0;
}
}
i f ( d i g i t a l R e a d ( SW red ) && S W r e d s t a t u s ) {
SW red status = false ;
}

i f ( M e n u l e v e l == 1 )
{
i f ( ! d i g i t a l R e a d (SW) && ! SW STATUS ) {

Rotary counter = 0;
t o n e ( Buzzer , 5 0 0 , 2 0 ) ;
i f ( Menu row == 1 ) {
Menu level = 2;
Menu row = 1 ;
}
e l s e i f ( Menu row == 2 ) {
Menu level = 3;
Menu row = 1 ;
}
e l s e i f ( Menu row == 3 ) {
Menu level = 4;
Menu row = 1 ;
}

SW STATUS = t r u e ;
}

i f ( d i g i t a l R e a d (SW) && SW STATUS )


{
SW STATUS = f a l s e ;
}

i f ( R o t a r y c o u n t e r <= 4 )
{
Menu row = 1 ;
}
e l s e i f ( R o t a r y c o u n t e r > 4 && R o t a r y c o u n t e r <= 8 )
{
Menu row = 2 ;
}
e l s e i f ( R o t a r y c o u n t e r > 8 && R o t a r y c o u n t e r <= 1 2 )
{
Menu row = 3 ;
}

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 9/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

i f ( Rotary counter < 0)


{
Rotary counter = 0;
}
i f ( R o t a r y c o u n t e r > 12)
{
Rotary counter = 12;
}

currentMillis = millis () ;
i f ( c u r r e n t M i l l i s − p r e v i o u s M i l l i s >= D e l a y ) {
p r e v i o u s M i l l i s += D e l a y ;
i f ( Menu row == 1 )
{
lcd . clear () ;
lcd . setCursor (0 ,0) ;
lcd . write (0) ;
l c d . p r i n t ( ” Cnt Load ” ) ;
lcd . setCursor (0 ,1) ;

lcd . p r i n t (” Cnt C u r r e n t ” ) ;
}

else i f ( Menu row == 2 )


{
lcd . clear () ;
lcd . setCursor (0 ,0) ;
lcd . p r i n t ( ” Cnt Load ” ) ;
lcd . setCursor (0 ,1) ;
lcd . write (0) ;
lcd . p r i n t ( ” Cnt C u r r e n t ” ) ;
}

else i f ( Menu row == 3 )


{
lcd . clear () ;
lcd . setCursor (0 ,0) ;
lcd . write (0) ;
lcd . p r i n t ( ” Cnt Power ” ) ;
}
}
}

i f ( M e n u l e v e l == 2 )
{
i f ( Rotary counter < 0)
{
Rotary counter = 0;
}
i f ( Rotary counter > 9)
{
Rotary counter = 9;
}
i f ( ! d i g i t a l R e a d (SW) && ! SW STATUS )
{

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 10/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

t o n e ( Buzzer , 5 0 0 , 2 0 ) ;
push count ON = push count ON + 1;
push count OFF = 0;
i f ( push count ON > 20)
{
Menu row = Menu row + 1 ;
i f ( Menu row > 7 )
{
Menu level = 5;
pause = f a l s e ;
o h m s e t p o i n t = Ohms 0 * 1000000 + Ohms 1 * 100000 + Ohms 2 * 10000 + Ohms 3 * 1000
+ Ohms 4 * 100 + Ohms 5 * 10 + Ohms 6 ;

}
Rotary counter = 0;
SW STATUS = t r u e ;
space string = space string + ” ”;
push count ON = 0;
}
}

i f ( d i g i t a l R e a d (SW) && SW STATUS )


{
push count ON = 0;
push count OFF = push count OFF + 1;
i f ( push count OFF > 20) {
SW STATUS = f a l s e ;
push count OFF = 0;
}

i f ( Menu row == 1 )
{
Ohms 0 = R o t a r y counter ;
}
i f ( Menu row == 2 )
{
Ohms 1 = R o t a r y counter ;
}
i f ( Menu row == 3 )
{
Ohms 2 = R o t a r y counter ;
}
i f ( Menu row == 4 )
{
Ohms 3 = R o t a r y counter ;
}
i f ( Menu row == 5 )
{
Ohms 4 = R o t a r y counter ;
}
i f ( Menu row == 6 )
{
Ohms 5 = R o t a r y counter ;
}

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 11/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

i f ( Menu row == 7 )
{
Ohms 6 = R o t a r y c o u n t e r ;
}

currentMillis = millis () ;
i f ( c u r r e n t M i l l i s − p r e v i o u s M i l l i s >= D e l a y ) {
p r e v i o u s M i l l i s += D e l a y ;
lcd . clear () ;
lcd . setCursor (0 ,0) ;
l c d . p r i n t ( ” Ohms : ” ) ;
l c d . p r i n t ( Ohms 0 ) ;
l c d . p r i n t ( Ohms 1 ) ;
l c d . p r i n t ( Ohms 2 ) ;
l c d . p r i n t ( Ohms 3 ) ;
l c d . p r i n t ( Ohms 4 ) ;
l c d . p r i n t ( Ohms 5 ) ;
l c d . p r i n t ( Ohms 6 ) ;
lcd . setCursor (0 ,1) ;
lcd . print ( space string ) ;
lcd . write (2) ;
}

i f ( ! d i g i t a l R e a d ( SW blue ) ) {
Menu level = 1;
Menu row = 1 ;
Rotary counter = 0;
Rotary counter prev = 0;
dac . s e t V o l t a g e ( 0 , f a l s e ) ;
previousMillis = millis () ;
SW STATUS = t r u e ;
space string = ” ”;
ohm setpoint = 0;
Ohms 1 = 0 ;
Ohms 2 = 0 ;
Ohms 3 = 0 ;
Ohms 4 = 0 ;
Ohms 5 = 0 ;
Ohms 6 = 0 ;
}
i f ( ! d i g i t a l R e a d ( SW blue ) ) {
Menu level = 1;
Menu row = 1 ;
Rotary counter = 0;
Rotary counter prev = 0;
dac . s e t V o l t a g e ( 0 , f a l s e ) ;
previousMillis = millis () ;
SW STATUS = t r u e ;
space string = ” ”;
ohm setpoint = 0;
Ohms 1 = 0 ;
Ohms 2 = 0 ;
Ohms 3 = 0 ;
Ohms 4 = 0 ;
Ohms 5 = 0 ;
Ohms 6 = 0 ;
}

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 12/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

i f ( M e n u l e v e l == 3 )
{
i f ( Rotary counter < 0)
{
Rotary counter = 0;
}
i f ( Rotary counter > 9)
{
Rotary counter = 9;
}

i f ( ! d i g i t a l R e a d (SW) && ! SW STATUS )


{
t o n e ( Buzzer , 5 0 0 , 2 0 ) ;
push count ON = push count ON + 1;
push count OFF = 0;
i f ( push count ON > 20)
{
Menu row = Menu row + 1 ;
i f ( Menu row > 4 )
{
Menu level = 6;
pause = f a l s e ;
m A s e t p o i n t = mA 0 * 1000 + mA 1 * 100 + mA 2 * 10 + mA 3 ;

}
Rotary counter = 0;
SW STATUS = t r u e ;
space string mA = space string mA + ” ”;
push count ON = 0;
}
}

i f ( d i g i t a l R e a d (SW) && SW STATUS )


{
push count ON = 0;
push count OFF = push count OFF + 1;
i f ( push count OFF > 20) {
SW STATUS = f a l s e ;
push count OFF = 0;
}

i f ( Menu row == 1 )
{
mA 0 = R o t a r y c o u n t e r ;
}
i f ( Menu row == 2 )
{
mA 1 = R o t a r y c o u n t e r ;
}
i f ( Menu row == 3 )

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 13/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

{
mA 2 = R o t a r y c o u n t e r ;
}
i f ( Menu row == 4 )
{
mA 3 = R o t a r y c o u n t e r ;
}

currentMillis = millis () ;
i f ( c u r r e n t M i l l i s − p r e v i o u s M i l l i s >= D e l a y ) {
p r e v i o u s M i l l i s += D e l a y ;
lcd . clear () ;
lcd . setCursor (0 ,0) ;
l c d . p r i n t ( ”mA: ” ) ;
l c d . p r i n t ( mA 0 ) ;
l c d . p r i n t ( mA 1 ) ;
l c d . p r i n t ( mA 2 ) ;
l c d . p r i n t ( mA 3 ) ;
lcd . setCursor (0 ,1) ;
lcd . p r i n t ( space string mA ) ;
lcd . write (2) ;
}
i f ( ! d i g i t a l R e a d ( SW blue ) ) {
Menu level = 1;
Menu row = 1 ;
Rotary counter = 0;
Rotary counter prev = 0;
dac . s e t V o l t a g e ( 0 , f a l s e ) ;
previousMillis = millis () ;
SW STATUS = t r u e ;
space string mA = ” ”;
mA setpoint = 0;
mA 0 = 0 ;
mA 1 = 0 ;
mA 2 = 0 ;
}
}

i f ( M e n u l e v e l == 4 )
{
i f ( Rotary counter < 0)
{
Rotary counter = 0;
}
i f ( Rotary counter > 9)
{
Rotary counter = 9;
}

i f ( ! d i g i t a l R e a d (SW) && ! SW STATUS )


{
t o n e ( Buzzer , 5 0 0 , 2 0 ) ;
push count ON = push count ON + 1;
push count OFF = 0;
i f ( push count ON > 20)

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 14/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

{
Menu row = Menu row + 1 ;
i f ( Menu row > 5 )
{
Menu level = 7;
pause = f a l s e ;
m W s e t p o i n t = mW 0 * 10000 + mW 1 * 1000 + mW 2 * 100 + mW 3 * 10 + mW 4 ;

}
Rotary counter = 0;
SW STATUS = t r u e ;
space string mA = space string mA + ” ”;
push count ON = 0;
}
}

i f ( d i g i t a l R e a d (SW) && SW STATUS )


{
push count ON = 0;
push count OFF = push count OFF + 1;
i f ( push count OFF > 20) {
SW STATUS = f a l s e ;
push count OFF = 0;
}

i f ( Menu row == 1 )
{
mW 0 = R o t a r y c o u n t e r ;
}
i f ( Menu row == 2 )
{
mW 1 = R o t a r y c o u n t e r ;
}
i f ( Menu row == 3 )
{
mW 2 = R o t a r y c o u n t e r ;
}
i f ( Menu row == 4 )
{
mW 3 = R o t a r y c o u n t e r ;
}
i f ( Menu row == 5 )
{
mW 4 = R o t a r y c o u n t e r ;
}

currentMillis = millis () ;
i f ( c u r r e n t M i l l i s − p r e v i o u s M i l l i s >= D e l a y ) {
p r e v i o u s M i l l i s += D e l a y ;
lcd . clear () ;
lcd . setCursor (0 ,0) ;
l c d . p r i n t ( ”mW: ” ) ;
l c d . p r i n t (mW 0) ;
l c d . p r i n t (mW 1) ;
l c d . p r i n t (mW 2) ;

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 15/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

lcd . p r i n t (mW 3) ;
lcd . p r i n t (mW 4) ;
lcd . setCursor (0 ,1) ;
lcd . p r i n t ( space string mA ) ;
lcd . write (2) ;
}
i f ( ! d i g i t a l R e a d ( SW blue ) ) {
Menu level = 1;
Menu row = 1 ;
Rotary counter = 0;
Rotary counter prev = 0;
dac . s e t V o l t a g e ( 0 , f a l s e ) ;
previousMillis = millis () ;
SW STATUS = t r u e ;
space string mA = ” ”;
mW setpoint = 0;
mW 0 = 0 ;
mW 1 = 0 ;
mW 2 = 0 ;
mW 3 = 0 ;
mW 4 = 0 ;
}
}

/ / C o n s t a n t Load Mode
i f ( M e n u l e v e l == 5 )
{
if ( Rotary counter > Rotary counter prev )
{
ohm setpoint = ohm setpoint + 1;
Rotary counter prev = Rotary counter ;

if ( Rotary counter < Rotary counter prev )


{
ohm setpoint = ohm setpoint − 1;
Rotary counter prev = Rotary counter ;

f l o a t voltage on load , sensosed voltage , voltage read , power read ;


v o l t a g e o n l o a d = ads . re a d A D C D i f f e r en t i a l 0 1 ( ) ; / / Read DIFFERENTIAL
v o l t a g e b e t w e e n ADC0 and ADC1 . ( t h e l o a d i s 1ohm , s o t h i s i s e q u a l t o t h e
current )
v o l t a g e o n l o a d = ( v o l t a g e o n l o a d * m u l t i p l i e r ) *1000;

v o l t a g e r e a d = ads . readADC SingleEnded ( 2 ) ;


voltage read = ( voltage read * multiplier A2 ) ;

/ / s e n s o s e d v o l t a g e = ads . readADC SingleEnded ( 3 ) ;


/ / sensosed voltage = ( sensosed voltage * multiplier ) ;

power read = voltage on load * vo lta ge re ad ;

f l o a t s e t p o i n t c u r r e n t = ( v o l t a g e r e a d / ohm setpoint ) * 1000;

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 16/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

f l o a t e r r o r = abs ( s e t p o i n t c u r r e n t − v o l t a g e o n l o a d ) ;

if ( error > ( setpoint current *0.8) )


{
if ( setpoint current > voltage on load ){
dac value = dac value + 300;
}

if ( setpoint current < voltage on load ){


dac value = dac value − 300;
}
}

else if ( error > ( setpoint current *0.6) )


{
if ( setpoint current > voltage on load ){
dac value = dac value + 170;
}

if ( setpoint current < voltage on load ){


dac value = dac value − 170;
}
}

else if ( error > ( setpoint current *0.4) )


{
if ( setpoint current > voltage on load ){
dac value = dac value + 120;
}

if ( setpoint current < voltage on load ){


dac value = dac value − 120;
}
}
else if ( error > ( setpoint current *0.3) )
{
if ( setpoint current > voltage on load ){
dac value = dac value + 60;
}

if ( setpoint current < voltage on load ){


dac value = dac value − 60;
}
}
else if ( error > ( setpoint current *0.2) )
{
if ( setpoint current > voltage on load ){
dac value = dac value + 40;
}

if ( setpoint current < voltage on load ){


dac value = dac value − 40;
}
}
else if ( error > ( setpoint current *0.1) )
{

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 17/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

if ( setpoint current > voltage on load ){


dac value = dac value + 30;
}

if ( setpoint current < voltage on load ){


dac value = dac value − 30;
}
}
else
{
if ( setpoint current > voltage on load ){
dac value = dac value + 1;
}

if ( setpoint current < voltage on load ){


dac value = dac value − 1;
}
}

i f ( d a c v a l u e > 4095)
{
dac value = 4095;
}

i f ( ! pause ) {
dac . s e t V o l t a g e ( d a c v a l u e , f a l s e ) ;
pause string = ””;
}
else{
dac . s e t V o l t a g e ( 0 , f a l s e ) ;
p a u s e s t r i n g = ” PAUSE ” ;
}

currentMillis = millis () ;
i f ( c u r r e n t M i l l i s − p r e v i o u s M i l l i s >= D e l a y ) {
p r e v i o u s M i l l i s += D e l a y ;
lcd . clear () ;
lcd . setCursor (0 ,0) ;
lcd . p r i n t ( ohm setpoint , 0 ) ; lcd . write (1) ; lcd . p r i n t (” ”) ; lcd . p r i n t ( voltage read
, 3 ) ; l c d . p r i n t ( ”V” ) ;
lcd . setCursor (0 ,1) ;
lcd . print ( voltage on load ,0) ; l c d . p r i n t ( ”mA” ) ; l c d . p r i n t ( ” ” ) ; l c d . p r i n t (
power read , 0 ) ; l c d . p r i n t ( ”mW” ) ;
lcd . print ( pause string ) ;
}
i f ( ! d i g i t a l R e a d ( SW blue ) ) {
Menu level = 1;
Menu row = 1 ;
Rotary counter = 0;
Rotary counter prev = 0;
dac . s e t V o l t a g e ( 0 , f a l s e ) ;
previousMillis = millis () ;
SW STATUS = t r u e ;
space string = ” ”;
ohm setpoint = 0;
Ohms 1 = 0 ;
Ohms 2 = 0 ;

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 18/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

Ohms 3 = 0;
Ohms 4 = 0;
Ohms 5 = 0;
Ohms 6 = 0;
}
}

/ / C o n s t a n t C u r r e n t Mode
i f ( M e n u l e v e l == 6 )
{
if ( Rotary counter > Rotary counter prev )
{
mA setpoint = mA setpoint + 1;
Rotary counter prev = Rotary counter ;
}

if ( Rotary counter < Rotary counter prev )


{
mA setpoint = mA setpoint − 1;
Rotary counter prev = Rotary counter ;
}

f l o a t voltage on load , sensosed voltage , voltage read , power read ;

v o l t a g e o n l o a d = ads . re a d A D C D i f f e r en t i a l 0 1 ( ) ; / / Read DIFFERENTIAL


v o l t a g e b e t w e e n ADC0 and ADC1
v o l t a g e o n l o a d = ( v o l t a g e o n l o a d * m u l t i p l i e r ) *1000;

v o l t a g e r e a d = ads . readADC SingleEnded ( 2 ) ;


voltage read = ( voltage read * multiplier A2 ) ;

/ / s e n s o s e d v o l t a g e = ads . readADC SingleEnded ( 3 ) ;


/ / sensosed voltage = ( sensosed voltage * multiplier ) ;

power read = voltage on load * vo lta ge re ad ;

f l o a t e r r o r = abs ( mA setpoint − v o l t a g e o n l o a d ) ;

i f ( e r r o r > ( mA setpoint *0.8) )


{
i f ( mA setpoint > voltage on load ) {
dac value = dac value + 300;
}

i f ( mA setpoint < voltage on load ) {


dac value = dac value − 300;
}
}

else i f ( e r r o r > ( mA setpoint *0.6) )


{
i f ( mA setpoint > voltage on load ) {
dac value = dac value + 170;
}

i f ( mA setpoint < voltage on load ) {

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 19/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

dac value = dac value − 170;


}
}

else i f ( e r r o r > ( mA setpoint *0.4) )


{
i f ( mA setpoint > voltage on load ) {
dac value = dac value + 120;
}

i f ( mA setpoint < voltage on load ) {


dac value = dac value − 120;
}
}
else i f ( e r r o r > ( mA setpoint *0.3) )
{
i f ( mA setpoint > voltage on load ) {
dac value = dac value + 60;
}

i f ( mA setpoint < voltage on load ) {


dac value = dac value − 60;
}
}

else i f ( e r r o r > ( mA setpoint *0.2) )


{
i f ( mA setpoint > voltage on load ) {
dac value = dac value + 40;
}

i f ( mA setpoint < voltage on load ) {


dac value = dac value − 40;
}
}

else i f ( e r r o r > ( mA setpoint *0.1) )


{
i f ( mA setpoint > voltage on load ) {
dac value = dac value + 30;
}

i f ( mA setpoint < voltage on load ) {


dac value = dac value − 30;
}
}
else
{
i f ( mA setpoint > voltage on load ) {
dac value = dac value + 1;
}

i f ( mA setpoint < voltage on load ) {


dac value = dac value − 1;
}
}

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 20/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

i f ( d a c v a l u e > 4095)
{
dac value = 4095;
}

i f ( ! pause ) {
dac . s e t V o l t a g e ( d a c v a l u e , f a l s e ) ;
pause string = ””;
}
else{
dac . s e t V o l t a g e ( 0 , f a l s e ) ;
p a u s e s t r i n g = ” PAUSE ” ;
}

currentMillis = millis () ;
i f ( c u r r e n t M i l l i s − p r e v i o u s M i l l i s >= D e l a y ) {
p r e v i o u s M i l l i s += D e l a y ;
lcd . clear () ;
lcd . setCursor (0 ,0) ;
l c d . p r i n t ( m A s e t p o i n t , 0 ) ; l c d . p r i n t ( ”mA ” ) ; l c d . p r i n t ( v o l t a g e r e a d ) ; l c d . p r i n t
( ”V” ) ;
lcd . setCursor (0 ,1) ;
lcd . print ( voltage on load ,0) ; l c d . p r i n t ( ”mA” ) ; l c d . p r i n t ( ” ” ) ; l c d . p r i n t (
power read , 0 ) ; l c d . p r i n t ( ”mW” ) ;
lcd . print ( pause string ) ;
}
i f ( ! d i g i t a l R e a d ( SW blue ) ) {
Menu level = 1;
Menu row = 1 ;
Rotary counter = 0;
Rotary counter prev = 0;
dac . s e t V o l t a g e ( 0 , f a l s e ) ;
previousMillis = millis () ;
SW STATUS = t r u e ;
space string mA = ” ”;
mA setpoint = 0;
mA 0 = 0 ;
mA 1 = 0 ;
mA 2 = 0 ;
}
}

/ / C o n s t a n t Power Mode
i f ( M e n u l e v e l == 7 )
{
if ( Rotary counter > Rotary counter prev )
{
mW setpoint = mW setpoint + 1;
Rotary counter prev = Rotary counter ;
}

if ( Rotary counter < Rotary counter prev )


{
mW setpoint = mW setpoint − 1;
Rotary counter prev = Rotary counter ;

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 21/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

f l o a t voltage on load , sensosed voltage , voltage read , power read ;

v o l t a g e o n l o a d = ads . re a d A D C D i f f e r en t i a l 0 1 ( ) ; / / Read DIFFERENTIAL


v o l t a g e b e t w e e n ADC0 and ADC1
v o l t a g e o n l o a d = ( v o l t a g e o n l o a d * m u l t i p l i e r ) *1000;

v o l t a g e r e a d = ads . readADC SingleEnded ( 2 ) ;


voltage read = ( voltage read * multiplier A2 ) ;

/ / s e n s o s e d v o l t a g e = ads . readADC SingleEnded ( 3 ) ;


/ / sensosed voltage = ( sensosed voltage * multiplier ) ;

power read = voltage on load * vo lta ge re ad ;

f l o a t e r r o r = abs ( mW setpoint − power read ) ;


i f ( e r r o r > ( mW setpoint * 0 . 8 ) )
{
i f ( mW setpoint > power read ) {
dac value = dac value + 300;
}

i f ( mW setpoint < power read ) {


dac value = dac value − 300;
}
}

e l s e i f ( e r r o r > ( mW setpoint * 0 . 6 ) )
{
i f ( mW setpoint > power read ) {
dac value = dac value + 170;
}

i f ( mW setpoint < power read ) {


dac value = dac value − 170;
}
}

e l s e i f ( e r r o r > ( mW setpoint * 0 . 4 ) )
{
i f ( mW setpoint > power read ) {
dac value = dac value + 120;
}

i f ( mW setpoint < power read ) {


dac value = dac value − 120;
}
}
e l s e i f ( e r r o r > ( mW setpoint * 0 . 3 ) )
{
i f ( mW setpoint > power read ) {
dac value = dac value + 60;
}

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 22/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

i f ( mW setpoint < power read ) {


dac value = dac value − 60;
}
}
e l s e i f ( e r r o r > ( mW setpoint * 0 . 2 ) )
{
i f ( mW setpoint > power read ) {
dac value = dac value + 40;
}

i f ( mW setpoint < power read ) {


dac value = dac value − 40;
}
}
e l s e i f ( e r r o r > ( mW setpoint * 0 . 1 ) )
{
i f ( mW setpoint > power read ) {
dac value = dac value + 30;
}

i f ( mW setpoint < power read ) {


dac value = dac value − 30;
}
}
else
{
i f ( mW setpoint > power read ) {
dac value = dac value + 1;
}

i f ( mW setpoint < power read ) {


dac value = dac value − 1;
}
}

i f ( d a c v a l u e > 4095)
{
dac value = 4095;
}

i f ( ! pause ) {
dac . s e t V o l t a g e ( d a c v a l u e , f a l s e ) ;
pause string = ””;
}
else{
dac . s e t V o l t a g e ( 0 , f a l s e ) ;
p a u s e s t r i n g = ” PAUSE ” ;
}

currentMillis = millis () ;
i f ( c u r r e n t M i l l i s − p r e v i o u s M i l l i s >= D e l a y ) {
p r e v i o u s M i l l i s += D e l a y ;
lcd . clear () ;
lcd . setCursor (0 ,0) ;
l c d . p r i n t ( m W s e t p o i n t , 0 ) ; l c d . p r i n t ( ”mW ” ) ; l c d . p r i n t ( v o l t a g e r e a d ) ; l c d . p r i n t

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 23/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

( ”V” ) ;
lcd . setCursor (0 ,1) ;
lcd . p r i n t ( power read , 0 ) ; l c d . p r i n t ( ”mW” ) ; l c d . p r i n t ( ” ” ) ; l c d . p r i n t (
voltage on load ,0) ; l c d . p r i n t ( ”mA” ) ;
lcd . print ( pause string ) ;
}
i f ( ! d i g i t a l R e a d ( SW blue ) ) {
Menu level = 1;
Menu row = 1 ;
Rotary counter = 0;
Rotary counter prev = 0;
dac . s e t V o l t a g e ( 0 , f a l s e ) ;
previousMillis = millis () ;
SW STATUS = t r u e ;
space string mA = ” ”;
mW setpoint = 0;
mW 0 = 0 ;
mW 1 = 0 ;
mW 2 = 0 ;
mW 3 = 0 ;
mW 4 = 0 ;
}
}

} / / end v o i d l o o p

ISR ( PCINT0 vect ) {


c l i ( ) ; / / s t o p i n t e r r u p t s h a p p e n i n g b e f o r e we r e a d p i n v a l u e s
clk State = ( PINB & B00000100 ) ; / / p i n 10 s t a t e ?
dt State = ( PINB & B00000010 ) ;
i f ( c l k S t a t e != L a s t S t a t e ) {
/ / I f t h e o u t p u t B s t a t e i s d i f f e r e n t t o t h e o u t p u t A s t a t e , t h a t means t h e e n c o d e r
is r o t a t i n g clockwise
i f ( d t S t a t e != c l k S t a t e ) {
R o t a r y c o u n t e r ++;
t o n e ( Buzzer , 7 0 0 , 5 ) ;
L a s t S t a t e = c l k S t a t e ; / / Updates the p r e v i o u s s t a t e of the outputA with the
current state
sei () ; // restart interrupts
}
else {
R o t a r y c o u n t e r − −;
t o n e ( Buzzer , 7 0 0 , 5 ) ;
L a s t S t a t e = c l k S t a t e ; / / Updates the p r e v i o u s s t a t e of the outputA with the
current state
sei () ; // restart interrupts
}
}
}

VI R ESULTS
This Electronic Load is functioning as expected in all three modes. For constant current, output of multi meter and Electronic
Load is shown in figure- 5. For constant power, output of multi meter and Electronic Load is shown in figure-6. This electronic
load is holding constant current/power/resistor values for all valid inputs.

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 24/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

Figure 5: Constant Current

Figure 6: Constant Power

VII C ONCLUSIONS
This Electronic Load is developed for a maximum of 15 Volts Load Voltage and maximum of 2 Amps of Load Current. This
Electronic load is behaving as expected within the prescribed limits. The electronic load can be used to determine capacity of a
battery or power supply. This Electronic Load is designed for DC supplies only.

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 25/26


E SSENTIAL C IRCUITS FOR S YSTEM D ESIGN -04 A PR 2024-2024 I NDIAN I NSTITUTE OF S CIENCE

VIII F UTURE S COPE


• Printed PCB instead of general purpose PCB.
• Temperature sensor on MOSFET
• Addition of Fan, which is controlled by PWM from microcontroller.

• Increasing wattage from 30 to 100 by using higher gauge wires with MOSFET and bigger heat sink with fan.
• Putting sense probes to get correct value of voltage as there is lot of drop in wires with higher current.
• Here ADS1115 ADC is sampling at maximum rate of 860 samples per second and limiting the speed of circuit. Higher
speed ADC can be used, if variation of supply is too high and that needs to be controlled.

IX R EFERENCES
1. Power Electronics: Essentials & Applications, by Prof L. Umanand and class notes.
2. IRF 3205 data sheet: [Link]
3. Arduino docs, [Link]

4. 16 bit ADC ADS1115, [Link]


5. 12 bit DAC, [Link]/en-us/product/mcp4725
6. Homemade Digital Electronic Load, [Link]
7. Linear MOSFET and Its Use in Electronic Load, [Link]

©DESE-D EPT. E LECTRONIC S YSTEMS E NGINEERING , IIS C , BANGALORE 26/26

You might also like