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.


Comments

Popular posts from this blog

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 ...

Onboard Firmware of the Human Brain

Freesiders are continually tinkering with robotics and other such machinery .  Many of these embedded processors and firmware are becoming open source and every-more diversified in the wake of the modern Maker movement . One notable boost to the hackerspace arsenal is the Arduino (an like platforms).  This offers designers an incredible power to devise not just individual devices but even the emergence of complex, integrated systems . This evolutionary pace of modern technological systems may be significantly faster the biologic system development, but there may be a few well learned tricks yet to be mastered.  It seems that studying how nature has managed to solve many development challenges will aid in designing robotics, where efficiently counts just as much. One  challenge, that is particularly interesting, is data processing.  Artificial intelligence is labored with processing data and producing a meaningful and useful output.  When consid...

Freesiders Hackers Collaborate in Medical / Surgical Research

Published in the May issue of the Journal of Foot and Ankle Surgery : " A Novel Combination of Printed 3-Dimensional Anatomic Templates and Computer-assisted Surgical Simulation for Virtual Preoperative Planning in Charcot Foot Reconstruction ." This collaboration of specialties represents an undertaking by members of Freeside Atlanta , Southern Arizona Limb Salvage Alliance , and The Podiatry Institute .  Charcot foot reconstruction remains on of the most challenging procedures in foot and ankle surgery.  These procedures are often lengthy procedures which can be riddled with complications. With the help of Freeside Atlanta Members, institutional researchers used open source Osirix Image viewer and 3D Software such as Newtek's Lightwave or Blender to create simulated surgical reductions as well as 3D printed templates.  Freeside Atlanta members assisted in providing 3D printing solutions and know-how to the project. Experimental test prints were done on a M...