Skip to main content

Craftycoder's Automotive PDU - Update

I've been busy working on this project since I last wrote about it. I have a new PCB designed and built up and another that has since been designed but not yet built. Designing electronics is a process. The first design I had built had an analog mux on it that I was using to push all the current sense signaling to a few ADCs on the board. Later designs needed those pins on the MCU for other purposes so I added an 8 channel ADC to the design and removed the mux all together. I then found that the ADC was too fast to measure the current in a useful way because the PWM I use to adjust the current would give the ADC values that were either 0% or 100% instead of a working average. I knew this going in, but assumed I'd be able to get a reliable average in a reasonable amount of time. For whatever reason though, it took about 300 samples per channel to get an reliable average value. Multiply that by 8 channels and then assume a single byte to store the value and you can see that it consumes at least 2400 bytes (I only have about 500 to work with). It also took about a 12ms to get a value (there was a lot of overhead in the serial communication layer I had not accounted for). Multiple that by 2400 and it would take almost 30 seconds to get reliable current values from all the channels. That was a total epic fail. So, I went back to the drafting table and drew up a circuit that did all the averaging in the analog domain which operates WAY FASTER than any digital circuit can. What I drew up is a three stage low-pass filter for each channel. Image below.

Blue: PWM
Green: 1st Stage
Red: 2nd Stage
Celeste: 3rd Stage
As you can see, the circuit is not exactly trivial (especially if you consider I needed 8 of these added to an already crowded board; 56 more components). The PWM input signal is turned into a low impedance DC voltage source (with the help of an op amp) that is proportional to the duty cycle of the PWM signal and whose DC offset is proportional to the current draw. The second part of that is done with another op-amp and a very large but low impedance resistor and then I do a differential measurement to get the voltage drop across the resistor. I multiply that drop so that the upward bound is just below the top DC rail of the ADC so I get the most bits of resolution. Look up high side current measurement for more details on this. I used LTSpice to help select the values for the RC filter network. The values have a lot to do with the frequency of the PWM input and the speed at which you want it to settle. You can see from the above graphic that I settled on a filter that gives me a decently flat, DC like, signal that settles within 50ms of a current change. This is plenty fast for the purposes of a circuit breaker and should provide excellent user feedback as well. When they turn up a circuit they should see the current like move very fast. This is in fact the case and the video below will show that.

I had another exciting and problematic feature that has been a challenge to create. Market feedback suggested that some constant current capability would be appreciated. At first I thought I may be able to shoehorn this in with a software fix. It turned out to be just too slow to work. When you require constant current you really don't want to overshoot too far or you can fry your load before the circuit has a chance to moderate the current. On the latest iteration of the I added some pretty clever hardware constant current stuff by taking advantage of some features on the MOSFET driver that were for another purpose but could support a constant current function with a little external help. I thought about it for a while and drew up a circuit and had boards built but I never bothered to do ALL the math required to fully understand the circuit I designed. It turned out when it was finished that I didn't understand all the variables that controlled the timing of the circuit. I ended up with a perfectly adequate constant current source, but it oscillated at 20Hz instead of the 200Hz I expected. At first I thought I just dropped a decimal when I was doing the math because 20Hz and 200Hz look suspiciously similar. I redid the math and I had not screwed that up so I had to look more closely to see what was happening. I put it on the scope and then it became quite clear. Remember that 50ms number I mentioned about the settling speed of the 3 stage RC filter I created? Well, if you do the math, you will find that 20Hz is a synonym for 50ms. That was the problem. My filter was too slow to support the constant current feature I wanted to offer. I needed another 10x increase in performance. I knew this was going to be a big challenge and I also knew that my LMV324 op-amps (that were part of the circuit) were not going to be up to the task of moving so fast. I completely redesigned the constant current circuit with high performance op amps and much faster filter. I then went ahead and used LTSpice to model the circuit to confirm the design. This is a somewhat time consuming process, but these 4 layer boards and accompanying stainless steel stencils I am buying cost $200 and take about two weeks to get so its worth the effort to prove out the design before wasting all that time and money.

LTSpice is an incredibly useful tool for these sorts of electrical engineering problems. You can see that I am able to get reasonably fast PWM signal that is at a constant current over a roughly 100Hz time frame. The 100Hz speed is a compromise between the slow speed of the former version and fast speed that I desire. My secret sauce here is that I am using only 2 stages of the filter for this instead of 3 and I am adjusting the the first stages a bit. This is the compromise. I could other wise pretty easily get any speed I wanted but I'd have to have even more passive components on the board and its already packed with parts.
I suppose I"ll leave with a couple videos showing the circuit in action.


Popular posts from this blog

Building an enclosure for the LulzBot AO 100

As the cold weather season arrives in Atlanta, with it comes issues with our 3D printers. Specifically problems with temperatures and print stability. Freeside is essentially a big warehouse, and our 3D printing station is setup in the large open area in the front of the space. What this means is that when it is cold in the space, this will affect the printing quality because the ambient temperature is far lower than what is optimal for thermoplastics. The cold ambient air will cause parts to rapidly cool during the middle of a print. And with materials like ABS which can shrink dramatically during cooling, this causes prints to warp, deform, and delaminate during and after printing is finished. The print on the left is showing signs of delamination from plastic cooling mid print. To remedy this, we built an acrylic enclosure for our LulzBot AO-100, which is our dedicated ABS printer. We tested the proof of concept of whether an enclosure would help mitigate printing problem

Build-Out Recap!

A bunch of great stuff got done at the build-out yesterday. A huge thanks to everyone that came out to pitch in! Here are some pictures to recap the projects... Randy's team hung the curtain to the workshop to create more of a barrier between the front of the house and back of the house and to control dust levels a bit more. We'll be finishing the top of the wall soon, but the hard part's already done. Karen, Donald, Tom, Violet, and James framed the doorway to the Media Lab and Bio Lab and hung the door for that area. Next step is AC! Michelle and Mary's team cleaned out project storage and moved the shelves over so that Neils could put the flammability cabinets in that area. That allowed all of us with the help of Adam and Nathan to clean up the workshop and really tidy up. They also sorted out all of the laser cutter raw materials and cut them down to a usable size on the table saw.  For the portal clouds, JW, Nathan, and Kat rolled an aw

A Capacitive-Touch Janko Keyboard: What I Did at the 2017 Georgia Tech Moog Hackathon

Last weekend (February 10-12, 2017) I made a Janko-layout capacitive-touch keyboard for the Moog Werkstatt at the Georgia Tech Moog Hackathon. The day after (Monday the 13th), I made this short video of the keyboard being played: "Capacitive Touch Janko Keyboard for Moog Werkstatt" (Text from the video doobly doo) This is a Janko-layout touch keyboard I made at the 2017 Moog Hackathon at Georgia Tech, February 10-12. I'm playing a few classic bass and melody lines from popular and classic tunes. I only have one octave (13 notes) connected so far. The capacitive touch sensors use MPR121 capacitive-touch chips, on breakout boards from Adafruit (Moog Hackathon sponsor Sparkfun makes a similar board for the same chip). The example code from Adafruit was modified to read four boards (using the Adafruit library and making four sensor objects and initializing each to one of the four I2C addresses is remarkably easy for anyone with moderate familiarity with C++), and