DIY Adjustable Constant Load (Current & Power)

52,977

220

70

Introduction: DIY Adjustable Constant Load (Current & Power)

About: Awesome Electronics Tutorials, Projects and How To´s

In this project I will show you how I combined an Arduino Nano, a current sensor, an LCD, a rotary encoder and a couple of other complementary components in order to create an adjustable constant load. It features a constant current and power mode and can handle a maximum of 30V and 20A if your heatsink design can handle it. Let's get started!

Step 1: Watch the Video!

The video gives you all the information you need to make your own adjustable constant load. During the next steps though, I will present you some additional information.

Step 2: Order the Components!

Here you can find a parts list with example seller (affiliate links):

Aliexpress:

1x Arduino Nano: https://s.click.aliexpress.com/e/_dULoNXh

1x 16x2 I2C LCD: https://s.click.aliexpress.com/e/_dSjOzdW

1x Rotary Encoder: https://s.click.aliexpress.com/e/_dZs9jUb

1x TC4420 MOSFET Driver: https://s.click.aliexpress.com/e/_d9epnMB

1x IRFZ44N MOSFET: https://s.click.aliexpress.com/e/_dUJRtAg

1x ACS712 Current Sensor: https://s.click.aliexpress.com/e/_dSKBwNK

1x Fuse Holder: https://s.click.aliexpress.com/e/_dU3K3jS

1x 20A Fuse: https://s.click.aliexpress.com/e/_dTjqvC4

2x Binding Post: https://s.click.aliexpress.com/e/_d9ke5na

Ebay:

1x Arduino Nano: http://rover.ebay.com/rover/1/711-53200-19255-0/1?...

1x 16x2 I2C LCD: http://rover.ebay.com/rover/1/711-53200-19255-0/1?...

1x Rotary Encoder: http://rover.ebay.com/rover/1/711-53200-19255-0/1?...

1x TC4420 MOSFET Driver: http://rover.ebay.com/rover/1/711-53200-19255-0/1?...

1x IRFZ44N MOSFET: http://rover.ebay.com/rover/1/711-53200-19255-0/1?...

1x ACS712 Current Sensor: http://rover.ebay.com/rover/1/711-53200-19255-0/1?...

1x Fuse Holder: http://rover.ebay.com/rover/1/711-53200-19255-0/1?...

1x 20A Fuse: http://rover.ebay.com/rover/1/711-53200-19255-0/1?...

2x Binding Post: http://rover.ebay.com/rover/1/711-53200-19255-0/1?...

Amazon.de:

1x Arduino Nano: https://amzn.to/2BLw2Ml

1x 16x2 I2C LCD: https://amzn.to/2BJ8tnx

1x Rotary Encoder: https://amzn.to/2Lmt5S0

1x TC4420 MOSFET Driver: https://amzn.to/2PBVQ0g

1x IRFZ44N MOSFET: https://amzn.to/2PxQd38

1x ACS712 Current Sensor: https://amzn.to/2NijkGn

1x Fuse Holder: https://amzn.to/2NkffkK

1x 20A Fuse: https://amzn.to/2PCLm0A

2x Binding Post: https://amzn.to/2BP0eGq

Step 3: Create the Circuit!

Here you can find the schematic as well as pictures of my finished circuit. Feel free to use it as a reference for your own circuit.

Step 4: Upload the Code!

Here you can download the code for the project. Upload it to the Arduino Nano through the Arduino IDE

Also make sure to download/include this library:

https://github.com/fdebrabander/Arduino-LiquidCrys...

Step 5: Finish the Project!

All that is left to do is mounting all the components inside your enclosure.

Step 6: Success!

You did it! You just created your own adjustable constant load!

Feel free to check out my YouTube channel for more awesome projects: http://www.youtube.com/user/greatscottlab

You can also follow me on Facebook, Twitter and Google+ for news about upcoming projects and behind the scenes information:

https://twitter.com/GreatScottLab

https://www.facebook.com/greatscottlab

4 People Made This Project!

Recommendations

  • Battery Powered Contest

    Battery Powered Contest
  • Plywood Challenge

    Plywood Challenge
  • Plastic Contest

    Plastic Contest

70 Discussions

0
YasienD
YasienD

10 days ago

Hi, I'm nearly finished building this project and the output voltage (measured with a multimeter) of my setup doesn't change when I set an output via the interface. I'm using Scott's code and the same components that were recommended. The only difference is that I'm using an Arduino pro mini.

I'm using a 20V 6A power supply to supply any load and a buck converter to supply power to the equipment. I lost my 5 volt regulators and I had a spare buck converter.

Regardless of the value I change the either the current or load values to, I always get a 2.4V output. The voltage drops to 0 when I 'stop' the output but it seems as though the duty cycle of the PWM signal doesn't change. I tied pin 9 directly the gate of the mosfet and the my output voltage was 2.1V and didn't change when I varied any values in settings.

My mosfet is fine, I tried 2 of them, and bot were adjustable with a 50k pot.

Can anyone help me here?

Puh-leeese
0
lziot
lziot

2 months ago

Hello.

The TC4420MJA driver is not available on any shops and it is quite expensive. Is there any replacement ?

1
hoj_dk
hoj_dk

11 months ago

Hi
Cool project. I'm deffinately going to build this. Did anyone make a PCB for this? and are willing to share the gerber files for it?
Best regards,
Christian

0
bencapobianco1
bencapobianco1

Reply 3 months ago

Hi, I’m also interested in a pcb Gerber file if anyone has one?
Thanks, Ben

2
kiwidave72
kiwidave72

Question 1 year ago

When looking at the code, i can’t see how you are setting the PWM out? You set it to an output on pin 9 and set it to low, but I can see anything else.

0
maliŽ1
maliŽ1

Reply 1 year ago

Think the code for PWM iz wrong. On my Arduino Nano V3 I've tryed the code (modiffied for Nokia 5110 LCD) for now without load and MOSFET, just the code and Current sensor, and OCR1A register goes Skyhigh (to 65534) and counts in a loop. I.e. when register reaches 65534, it starts from beginning (0). I simulated Current flow with a small magnet near current sensor.

For 100% DutyCycle the Value of register is 2047.
I modified the Code for current- and power mode ,

if (curcurrent < current) {
OCR1A++; // increase value of register OCR1A
} else {
if(OCR1A>0){ // If value of register greater than 1
OCR1A = OCR1A - 1; // decrease it
} else { // and if value is smaller than 1
OCR1A=0; // hold it on 0, or it will go around to the max
} // value and count down
}
OCR1A=constrain(OCR1A,0,2047);// hold value of register between 0 and 2047
counter++;
IMG_20191011_002008.jpgIMG_20191011_002025.jpg
0
bridystone
bridystone

Reply 6 months ago

Hi Maliz!

I hope you still read this.
Can you explain the magic number 2047 (2048 counts)?
I currently try to implement it for the Nano Every (which has a different IRQ Handling)

As i understand this is the number that defines the frequence of the pwm.
The OCR1 value than defines how long the duty cycle is.
As you wrote 2047 = 100% duty cycle.

But WHY 2047?!?!
so every 125 ns there is a pwn signal of OCR1 length.
Is this connected to the mosfet driver or the mosfet?

Any idea would be appreciated!

0
maliŽ1
maliŽ1

Reply 6 months ago

Hi, bridystone.
i'm new to the MCU and Arduino, perhaps i may not explain correctly.
ICR1 defines the PWM frequency
(timer speed (Hz)) = (Arduino clock speed (16MHz)) / prescaler
I this case, ICR1 = 2047, ie 16MHz / 2047 = 7816 Hz and that is PWM frequency, which was also measured with an oscilloscope.
OCR1 defines PWM Duty Cycle, and can be set to any value between 0-65534. In my case, PWM Duty 0-100% are the OCR1 values 0-2047. How Current on Sensor drops, OCR1 rises and and increases Duty Cycle, but does not stop at 100%. OCR1 goes higher, and PWM Duty Cycle stays on 100%, which means that the MOSFET no longer regulates current.
If, for example, OCR1 reaches, we say, 20000 (Current through the sensor
has started to rise), OCR1 starts to decrease, but the Duty cycle
remains at 100% until OCR1 falls below 2047. All this time, which takes
two -three seconds, the MOSFET does not regulate the current, and it is possible to burn out.
That's why I added the OCR1 registry value limit to the code, and then the PWM works properly. I measured all this with an oscilloscope, and monitored the values on the Arduino IDE serial monitor, and so I realized that OCR1 should be stopped at 2047
Why 2047? I'm not sure (as I said, I'm new to Arduino and I'm not very familiar with its registers), but I think it's related to the ICR1 value (2047 - PWM frequency 7816 Hz)
PWM Pin (D9) is connected to mosfet driver (as in the Great Scott's diagram)



0
bridystone
bridystone

Reply 6 months ago

Hi Maliz,

Thanks for your fast reply!
I think i figured out why the number 2047 was chosen by GreatScott:

you are right: the 2047 defines the PWM frequency. it defines the maximum value for 10 bits.
in the ATMega documentation the following is stated:

"The PWM resolution for fast PWM can be fixed to 8-, 9-, or 10-bit, or defined by either ICR1 or OCR1A. The
minimum resolution allowed is 2-bit (ICR1 or OCR1A set to 0x0003), and the maximum resolution is 16-bit
(ICR1 or OCR1A set to MAX). " (p. 133)

So i guess GreatScott assumed somehow (wrongly(?!)) that 10bit is the maximum level of the frequency. Which is not correct - as far as i read it. you can even set the number to 65535 (16bit) to get a higher resolution. This way the dutycycle could be adjusted more smoothly. I have no MegaAVR Chip available to test it, but it should work, since WG Mode 14 is used and not the predefined 5(8bit),6 (9bit), 7(10bit). (according to the data sheet)

I have no Nano lying around - only Nano Every's with MegaAVR Chip.
I guess I now at least understood the programming of the Timers and their usage with PWM.

Maybe you can adjust the TOP value to 1st 4095(11bit) and check if it still works - now with higher duty cycle steps (4095 as well).

Thanks again for your additional work and your reply.
It's a great project for me to understand the PWM usage and with your addition help (of code and clarifications) i understood quite a lot! :)
0
waileun
waileun

Answer 1 year ago

yes, I too cannot see the code that made adjustment to current, other than to the screen

3
maliŽ1
maliŽ1

8 months ago

Code adapted for Nokia 5110 LCD.
Note: If a strong power source is connected (eg a UPS battery), the regulation of the current is too slow and there is a possibility of MOSFET burnout (even 55A IRFZ44, I burned two until I realized the problem). Use a quick fuse

pcb.pngschema.pngIMG_20191114_231716.jpgmosfet.png
0
janecekpavel9
janecekpavel9

Reply 6 months ago

The 150k resistor in IRFZ gate control is for the MOSFET protection during the startup?

0
maliŽ1
maliŽ1

Reply 6 months ago

yep

0
bridystone
bridystone

Question 6 months ago

Hi GreatScott,

Thanks VERY much for the instruction!
I really like it and currently try to translate it to the Nano every (different IRQ handling/MegaAVR)

I now stumbled accross a thing i don't understand.
Can you explain the frequence number 2047/2048counts?
As i understand the pwm signal is every 128ns = 7,8125kHz.
But WHY?

OCRx defines the duty cycle - but why this freqence?
is this dependent on the mosfet or it's driver?

A short hint would be helpful to understand the topic a little better...

0
Arisma
Arisma

1 year ago

Excellent instructable my friend!!! I built it and it is working excellent! I have also designed and 3D printed a case for it. If you or anyone else is interested, I can sent you the stl. It is a huge tool for me that helps to discharge my LiPo batteries (alongside with a low voltage beeper) when the weather is bad to fly...
Allow me to make a modification. You can add a 1K resistor connected from arduino's D9 to GND, because if you have connected a battery (especially a LiPo one) with a lot of Amperes (or a big load) before Arduino boots, the load hits maximum, and the fuses are burnt instantly.
Keep up the good work! ;)

0
TonyF12
TonyF12

Reply 8 months ago

Yes, can you let me have the 3D STL files also. Thank you very much!

0
Arisma
Arisma

Reply 8 months ago

Of course my friend. Just send me your email.

0
jdev99
jdev99

Reply 6 months ago

HI Arisma, If I also may have the stl please, thank you
jdevires@mail.com