Introduction: Control Peristaltic Pump With TA7291P and an Arduino
This is my first Instructable and a few evenings invested in trying to understand how to use the TA7291P with a peristaltic pump without frying it convinced me that someone, somewhere, could probably be happy to get this information without loosing too much time.
The objective is to use an Arduino to control a peristaltic pump both in forward and reverse pumping while avoiding the risk of frying everything because of the back EMF generated when stopping the pump.
This project could be used to :
- Control the level of fluid in a vessel (that was my primary objective);
- Create a temperature-controlled variable flow liquid cooling unit;
- Plant watering (scheduled or as needed, if you add a sensor);
- Scheduled addition of nutrients (aquariums, hydroponics, etc).
It is part of a much bigger project and I will probably post it once it is completed.
Warning : French is my first language. I apologize in advance.
As I hate instructables that don't give you all the necessary details, there is no tricks nor missing secret ingredient in this one. I tried to be as complete as possible but if something could be improved, please comment!
Step 1: Background
If you already know all this stuff or just don't care, please jump to the next section.
For the others...
Back EMF : When you suddenly stop the current flowing in any solenoid (relay, motor, pump, electromagnet, inductor, aka anything with a coiled wire in it), the magnetic field will collapse and create an opposing current (going the wrong way) with a voltage being many times the original voltage. This is likely to fry any IC despite the very short duration of the voltage spike.
As a general rule, never directly connect any circuit to any inductive load without some kind of protection from back EMF. You can find a much detailed explanation here.
Flywheel diode : One of the technique to avoid damage caused by back EMF is to use a flywheel diode that will divert the pulse away from your IC (back into the coil actually).
However, you cannot use the flywheel diode with a peristaltic pump as someone would have to reverse the diode depending if the pump is used in forward or reverse pumping.
You could probably use a MOV (Metal-Oxyde Varistor) instead of the flywheel diode, but to tell you the truth, I don't have any to test and I only thought of it after starting writing this...
If I can get a few of them, I'll make some tests and post and update. If you have some, try it and share your results!
Peristaltic pump : Works like your gut, squeezing a tube to get the stuff out. However, unlike your gut, most of them will simply work in reverse when you reverse polarity (inverting the positive and the negative connection on the pump), so you can fill or empty a vessel with the same pump. Always check the characteristics of your stuff before plugging it (ideally, before buying it!). Also, some pump may or may not be destroyed by "dry pumping" (being used to pump an empty tube).
Current draw : Also called Inrush current, power-on surge, etc. This is the other reason why you want to use a PWM-based control for your pump. Every electric motor doesn't like two things : starting and stalling. When they do so, they will draw a current that is mostly limited to their (very small) internal resistance.
Avoiding Back EMF :
The more sudden the change in the current (if you suddenly "pull the plug"), the more severe will be your back EMF (now, there is a limit to this, but it is way too high anyways for your precious IC...)
The secret is reducing/increasing the current slowly.
And slowly here means a few milliseconds, not minutes...
Now, the easy solution if you have an Arduino is to use 2 PWM pins to slowly increase and decrease the amount of energy in the coil, thus avoiding the back EMF issue as we don't abruptly cut the power (actually, there is always some back EMF, but this way it is within the IC tolerances). By the way, this is a great way to power up or down power transformers or charging supercapacitors, as these little things are thirsty for current and will behave like short circuits. However, this is a completely different story (and Instructable). I'm only throwing it here to tickle your intellect.
Now, I will not start explaining how all that PWM stuff is working, as some great tutorials are already waiting for you.
Step 2: Get the Stuff...
This project only needs a few basic parts...
I used an Arduino UNO R3 (But you probably could use any of them... as long as 2 PWM pins are free and you can output 5V)
It is a 0-20V 1A (2A peak) Bridge Driver. It is quite cheap. I used the through-hole 10 pins version. Available at my local electronic surplus for 3.98$ CDN but close to 2$ at Digikey...
Datasheet : TA7291P
Link to Digikey : Part number TA7291PO-ND
3- 12V Peristaltic pump
I selected the 12V peristaltic pump from Adafruit for two reasons :
1- I really needed a peristaltic pump
2- It only draws 300-400mA
It is not cheap, but it works as advertised. You could probably pay less on Ebay... Just don't use any heavy duty 12V pump here... Remember, your bridge is rated 1A...
4- LED (your choice of color)
Completely optional... Just for debugging. Absolutely no other use, and please remove it if you want to reduce your energy usage. You could also use the LED already on your Arduino...
The mandatory resistor if you use an external LED. Value is not critical, just make sure no more than 20mA will get through your LED. I used a 330 Ohm resistor.
6- A bunch of wires
To connect everything...
7- A 12V battery
8- The USB cable to upload your sketch and power the Arduino
9- Obviously, a breadboard!
1- Arduino IDE
I'm assuming it is already installed, working, and that you know how to upload a sketch... If not, go straight to www.arduino.cc and you will get some great tutorials!
Step 3: Connect All the Stuff...
On a breadboard, place the TA7291P in any convenient spot.
Connect according to the following :
- Arduino GND (any of them) to TA7291P pin 1 and 12V GND
- Arduino (+)5V to TA7291P pin 7 (Vcc)
- Arduino D5 to TA7291P pin 5 (IN1)
- Arduino D6 to TA7291P pin 6 (IN2)
- Arduino D13 to R1 (if the optional external LED is used)
- R1 to (+) leg of LED
- (-) leg of LED to GND
- TA7291P pin 2 (OUT1) to (+) terminal of your pump
- TA7291P pin 4 (Vref) and pin 8 (Vs) to (+)12V
- TA7291P pin 10 (OUT2) to (-) terminal of your pump
- TA7291P pin 3 and 9 are not used
Step 4: Upload the Sketch...
Here is a (very) basic sketch to test your pump. No libraries, nothing complicated... The code is self-explaining, just read the comments.
What you are supposed to get is a pump that starts, stays at maximum speed for ten seconds, slow down to a complete stop, then reverse the pumping action to pump back the fluid.
If you installed the optional LED, you will see it increasing/decreasing its luminosity, shadowing the speed of the pump.
Step 5: In the End... to Heat Sink or Not to Heat Sink... That Is the Question!
My biggest concern was more related to the thermal effect of powering the pump for a few minutes or even hours. With a pumping rate of 100ml/min, I would realistically need to power it for up to 10-15 minutes at a time (each few hours in the worst conditions, each other day typically) for my project. When they are not in use, both pump and bridge will have plenty of time to cool down to room temp.
As the pump is rated for continuous use, 10-15 minutes is not an issue, but this is something you really have to check, especially with relays, solenoids and pumps! The real problem is the TA7291P heating up...
According to the datasheet, the P version I used as a power dissipation of 12.5 W at room temp (25 degrees Celsius). Now, this is called lab conditions and it relies on an interesting concept, the infinite heat sink. It doesn't in any way reflects real life, where ambient air temperature, humidity, air circulation, definite heat sink capabilities, phase of the moon, etc, will influence your circuit. However, as our pump only draws 300-400 mA, we are sitting right in the middle of the comfort zone here, far from the 1 A max. However, according to the datasheet, power dissipation drops to less than 2.5 W (a mere 200 mA) when the bridge is used without heat sink, but it doesn't say if it is for burst (less than 1 minute), short usage (1-5 minutes) or long term (more than an hour). The safe design would add a heat sink. But I was wondering if we could go without one.
As I got two TA7291P, testing one without a heat sink was worth a try... As the absolute operating temperature is 75 degrees Celsius, I decided to push the test to a maximum of 65 degrees, with complete cool down between the experiments.
It is easy to modify the sketch to make the pump work for a longer period. Using an infrared thermometer (a nice gadget to have by the way, put it on a wish list for a Birthday present!) I was able to verify that without heat sink, in an environment of 18.5 degrees Celsius, and only with natural convection (no fan) the bridge would stay at less than 20 degrees Celsius after 10 minutes pumping 25 degrees Celsius water. This gives you an idea of the real performances, but these numbers will likely change depending of your local temperatures and if the bridge is enclosed in a case, reducing the natural convection.
Here is a small graph of temperature vs time of the bridge in two different experiments.
For me, in the end, it seems unnecessary to add a heat sink.Time will tell if I was right. I'll keep you posted!
And by the way, no, the graph was not reversed by mistake. In both experiments, it looks like the temperature was slowly drifting down. That makes no sense, but as it is within the error margins of the infrared thermometer, I disregard it as noise until I get more time to investigate!
Step 6: What Can Go Wrong?
Common mistakes (at least I made them)...
1- You have to tie your Arduino GND to the PIN 1 of your bridge AND to the 12V Battery GND.
2- Don't increase the value of PIN 5 and PIN 6 at the same time. One should stay at 0. If not, it is like pushing the brakes on your pump. Look at table FUNCTION on page 3 of the Datasheet.
3- PIN 2 (OUT1) on your bridge goes to the (+) terminal of your pump and PIN 10 (OUT2) goes to the (-) negative terminal. Don't connect the second pump terminal to GND! However, you can switch terminals. The pump will work in reverse, at least for the model I tested.
4- Don't use a flywheel diode, unless you will not use the reverse pumping. Using one will create a short when the pump is switched in reverse pumping. This is why you slowly increase/reduce the current using PWM pins to reduce the negative impact of back EMF.
5- Don't pull the plug suddenly. Doing so will create a back EMF that could probably fry your bridge and/or your Arduino. Always bring the pump to a full stop (PIN 5 and PIN 6 LOW, not HIGH which is full brakes!). This is why in the sketch, I inserted a pause, so you can plug or unplug everything during that time.
Step 7: Conclusion
I hope you have a working peristaltic pump by now and that you learned a few things along the way. I'll try to answer comments and questions to the best of my knowledge and in a timely manner. This being said, I'm quite busy, so do not despair if you don't get a reply within the hour.