The next step: measuring and controlling flow rates

Today I worked with Andy on the next big step of the project, which is correlating our motor-controlled valve with actual air flow rates. In other words, when controlling the motor, we need to move up one rung on the ladder of abstraction, so that instead of just controlling the motor’s position or the number of steps it takes, we need to be able to specify parameters like a desired “flow rate” and a “time duration” and have the motor take care of the rest, via software that we create for this purpose.

However, the meat of our experiment will probably not be in adjusting flow rate and time duration. We already know these variables are likely to be set at 70 Liters/minute sustained for 4 seconds. The interesting stuff is going to happen when we start to control the speed and acceleration of the motor, like how long it should take to ramp-up to the desired flow rate (i.e. how fast the valve is opening), and how fast the motor should be turning at each moment during the ramp-up (i.e. the acceleration “curve” of the ramp-up). Andy has already given us some acceleration curves to investigate, namely linear, logarithmic, sigmoid, and step.

This can be accomplished in several ways, some more sophisticated than others. We have a digital flow meter at our disposal (TSI 4000 Series, Model 4043 E) with an 8-pin output plug designed to be connected to a computer. See photos below.

  • One option would be to use absolute measurements. We take measurements to correlate how far the motor has turned with how fast the air is flowing, and then build equations from that to control the motor, i.e. X steps = Y L/min.
  • Another option would a system of real-time feedback, where the software is monitoring the flow rate in real-time and adjusting the motor accordingly in order to achieve the desired parameters. This solution is obviously superior in an ideal world, but we might discover that uncontrollable factors like lag-time between readings make it impractical.

I believe we are going to try the real-time option first and see how it performs. The work we did today was related to this. We do not have the required cable to connect the flow meter to a computer, but Andy pointed out that a better solution might be to connect the flow meter directly to the Arduino. We would connect the two analog pins in the flow meter’s 8-pin plug (pins 3 and 4, named AnalogOutput[+] and AnalogGround[-] respectively) to the analog-input pins on the Arduino.

The AnalogOutput[+] pin on the flow meter produces a voltage that varies directly with the flow rate, and we were able to determine with a multimeter that the voltage varies approximately 0.5V every 10 L/min. Ex: 0V=0L/m, 0.5V=10L/m, 1.0V=20L/m, 1.5V=30L/m, 2.0V=40L/m, etc.

So the presumed equation for converting voltage to flow rate is: F = 20(V), where F is flow rate in L/m, and V is voltage.

The next step is to actually connect the analog pins of the flow meter to the Arduino, and then use the Arduino to measure the voltage at each flow rate and compare the results with that of the multimeter.

IMG_0613 IMG_0614 IMG_0615

What NOT to do when building your next power supply

In the spirit of Andy’s comment on my last post, I’m going to elaborate on a few things that gave me trouble during my project to build a power supply.

I feel like I had to do quite a bit of troubleshooting to get this power supply to work. But by the time I realized the culprit was a faulty power switch, I had already dismantled most of what I’d already assembled. The best practice is to always make sure everything behaves the way you expect it to at the time you install it. I read the reference material twice beforehand, but I didn’t test anything until the very end because I was afraid of getting electrocuted. The documentation alluded that there was a way to manually discharge the power supply with a resistor (so you can safely work on it again immediately after unplugging it), but it didn’t go into detail so I conveniently ignored my better judgement. That was the wrong shortcut to take. I ended up having to learn how to do it anyway.

However, the faulty power switch was a blessing in disguise, because in the process of re-testing all the components, I discovered that the large 10-watt 10-ohm power resistors (that the documentation “suggested” I install) were getting so hot that they were beginning to melt nearby wires; they are supposed to get hot, but not that hot. The documentation mentioned that “a few” atx power supplies will work without power resistors, and I knew that our last power supply worked without power resistors, but I figured, “Why not? Can’t hurt to add them anyway.” Well, I should have tested it first without them, because it works much better without them.

Overall it was a nice refresher course on not making assumptions if you don’t have to. Know for sure.

Finished building the new power supply

This afternoon I finished building our new variable power supply, converted from a Dell ATX power supply (Model: NPS-305AB C, Rev: 04). Hopefully this will improve the performance of our stepper motor even further by allowing us to run it at the recommended 12 volts. Below are the specs (note that the amperages can also be found on the factory label, and you can just ignore the plus or minus sign before the voltage, and ignore the “A” or “B” after the voltage, as it’s all the same to the motor):

  • Yellow light = plugged in
  • Ground = Black pin
  • +5Volts / 22Amps = Red pin
  • +12Volts(A) / 18Amps = White pin
  • +12Volts(B) / 18Amps = Yellow pin
  • -12Volts / 0.5Amps = Blue pin
  • +3.3Volts / 17Amps = Brown pin
  • That gaping hole will eventually be filled with an ON switch, but for now we’ll have to do without one because the switch I got from Radio Shack was faulty.

IMPORTANT: Feel free to measure the voltage of the power supply with a multimeter, but do not try to measure the current (aka amperage). This is an easy procedure to screw up and accidentally blow out the power supply (this is how I broke the last one). It was also a current spike that fried our last motor driver (again, my fault), so to protect the Big Easy Driver we should probably use a 2 amp fuse between it and the power supply.

The reference material used in building this thing is here and here. And thanks to team member Damian Jimenez for all his help along the way.

Update: See my followup, “What NOT to do when building your next power supply”.

IMG_0573

Tips from Brian Schmalz, the designer of Big Easy Driver

Tomorrow (Friday) I’ll be working with Damian (and whomever else) to convert the ATX power supply into something that will power our project. I’ve purchased all the parts we need at Radio Shack, including some “luxury” items like a power switch, indicator LED lights, and some 2-amp fuses to make sure we don’t burn out another motor driver. (To those who weren’t there, last Friday I accidentally burned out the ArduMoto motor driver shield after connecting it to a “real” variable power supply and cranking up the amperage too high.)

Damian and I had trouble getting the stepper to turn last week, so here are some thoughts on troubleshooting:

  • Big Easy Driver requires 8V min, 12V optimal, we were only running 7V.
  • Big Easy Driver defaults to 16-step microstepping mode, we may need to change this to full-step mode (maybe you can make this change Gio, see email correspondence below).
  • Note: the arrow indicator on the current adjustment potentiometer is backwards, so make sure it’s turned to the maximum.

I also emailed the guy who designed the Big Easy Driver, Brian Schmalz, and my email and his reply are below:

EMAIL FROM ME TO BRIAN SCHMALZ:

Hi Brian, thanks in advance for your time!

I’m trying to run a unipolar stepper (six wires) with the Big Easy Driver (BED). Do I need to make any changes to the sample code to get it to run correctly? Also, if the BED defaults to 16-step microstepping mode, how do I change that to full-step mode? Feel free to point me to any resources that answer the above questions.

Best,
Tyler Fields

REPLY FROM BRIAN SCHMALZ:

Tyler,

A 6-wire stepper motor can be wired in uni-polar or bi-polar modes. To see how they should be wired, you can look at the top diagram on this page: http://www.schmalzhaus.com/BigEasyDriver/index.html

Notice that there are two unused wires for each coil – the center wires. If that doesn’t work well for you, you can use the center wire and outer wire (it doesn’t matter which one) on each coil and connect those 4 wires to the BED (Big Easy Driver). Either way will work, but they will have different performance characteristics.

If you don’t have a datasheet for the motor, you’ll have to ohm out the coils with a meter to know which wires are connected to which coils.

As for the microstep mode – you control that with the M1, M2, and M3 inputs on the BED. Normally all 3 inputs are high (pulled up with resistors on the BED). This defaults it to 16-microstep mode. To go to full step mode, simply ground each of the three inputs (M1, M2, M3).

*Brian

Success with stepper motor by using ATX power supply and heat sink

Yesterday, by using the ATX power supply (12V yellow plug), and after applying a heat sink and using a fan (aka blow dryer on cool setting) to the main chip on the motor driver, I was able to get the stepper motor to perform up to its full specifications. It worked fine at all speeds without stutter, including those in the midrange that were giving us trouble before. And the torque was more than enough to turn the same valve used by Matt Herpin several years ago in his own experiment.

I think this worked because we finally gave it a power supply with the right characteristics:

  • a max current rating (18A) that was greater than the stepper motor’s rating (2A).
  • a voltage that was many times higher (12V) than the stepper motor’s rating (3V), as recommended on the forums.

Anyway, some important notes:

  1. Matt says we can continue to use his valve if needed. It is attached to the stepper motor using the same metal connection he had milled for this purpose. It requires the small allen wrench to loosen.
  2. The quality of the stepping started to decline after 30-60min of continuous use. It could be that the voltage was running too high for too long, or something with the ATX power supply (I took a picture of the spec label).

Variable power supply

I don’t know why I didn’t think of this before, but why don’t we just see if we can get someone on campus to loan us their variable power supply? That way we can produce the exact voltage and amperage levels that we need and test our present setup at a range of combinations to see what works best. And hopefully this would eliminate the need for chopper drivers, buckpucks, et al. Gio, can we checkout one of these from the EE dept? Anyone else have any connections?

Wiring the buckpuck to the stepper motor

Today I tried to hook up the 1000mA buckpuck (model 3023-DE) that I found in the lab to the Arduino/motor-driver/stepper-motor in every configuration I could think of with little success. The stepper motor actually performed poorer in all cases. My first thought is that, unless I’m missing something, we’ve already determined the stepper motor works best at 2A, and a 1A buckpuck limits the current to 1A, so the stepper isn’t going to get the current it needs.

In case I am in fact missing something, I’ll elaborate on what I tried anyway. Gio’s last post was literally the first entry in Google when I searched for “buckpuck motor driver”, if that gives you any indication of how often this has been done before, so I’ve been mostly making educated guesses after reading the buckpuck documentation.

The buckpuck has six wires: Voltage(+), Voltage(-), Reference(5V), Control(0V-5V), LED(+), LED(-).

* V(+) is synonymous with Vin.
* V(-) is synonymous with Ground.
* Ref(5V) is an extra source of 5V power if you need it (not applicable for us).
* Ctl(0V-5V) is used for pulse/strobe control of LED lights (n/a for us).
* LED(+) and LED(-) would normally be connected to a string of LED lights. In our case, this is supposed to provide our current-controlled voltage.

I’d like some feedback on this next part because it’s very possible I was doing something wrong. I’m thinking that, for our purposes, the buckpuck can be spliced either between the power supply and the motor-driver, or between the power supply and the yellow/white wires of stepper-motor (0 and 0not, which are supposed to be connected to a voltage source). In both cases I connected the V+/V- of the buckpuck to the V/Gnd of the power supply. And then in the first case I connected the LED+/LED- of the buckpuck to the Vin/Gnd of the motor-driver. And in the second case I bridged the yellow/white wires of stepper-motor between the LED+/LED- of the buckpuck. Again, in both cases the stepper motor performed worse.

NOTE: I obviously only tried using the 12V 1A power supply since it’s the only one we have with exposed wires. I tried measuring the V and A that the buckpuck was producing with a multimeter but, according to the documentation, “Because there is a small, high-frequency component in the 3021/3023 output, many multi-meters may give an incorrect reading.”