Friday, May 18, 2012

Bench Power Supply - Point of no return

Just  a quick(not really) update.

I've got a lot of the code side of things worked out. I had a lot of "fun" doing software debouncing for my rotary encoders. After hooking up a logic analyzer, I realized that using the I2C IO expander for the encoders was not going to work. The I2C chip I'm using, an MCP23018, has a couple interrupt lines, one of which I used to alert my ATmega that the expander needed attention. Since the expander is an I2C "slave", this is the only way it can initiate communication with the microcontroller. An interrupt handler in my code would set a flag and exit. When my "main update loop" got around to checking that flag it would then issue a series of I2C commands to query the expander for the encoder line change that triggered the original interrupt. All of this turned out to be way too slow to process encoder input. The main culprit was the fact that it depended on the main code loop getting around to checking that flag. From my logic captures, I could see that encoder edge transitions could happen sometimes 5ms apart. When there was a lot going on, such as heavy LCD updates, my main loop could sometimes take 20-30ms to complete one loop. Ouch.

You can't easily, if at all do I2C in an interrupt handler, you can not be sure of what state the I2C line is in when the interrupt fires. In the end, rather than figuring out a way to do I2C in an interrupt, or doing more flag checking (which would have been a hack, sometimes most of the CPU time is spent deep in the LCD bit bang code), the simpler solution was to move the encoders to the AVR itself. I had to give up UART functionality that I was planning, since I'm tight on allocated pins, but I was leaning toward doign that anyways.

Most recently, I got the ATX power supply wired in. I bought an ATX 20 pin adapter from a local PC store, and cut it in half to make a harness-breakout. I want to keep the PSU in an unmodified state, since they tend to go bad, and I want it to be easy to swap out for a different one.

As you can see above, I've got a 12 volt line running into the left-most rail on that sloppy breadboard setup. The rest of the circuit for now is powered from a fixed 5 volt regulator(lower left in picture). My 20 year old multimeter reads "5.00" volts, but I also purchased a 0.1% 5V shunt that I may use to ensure additional precision on ADC reference voltage. I don't have a lot of faith that my design will turn out "high precision",  I'd probably be happy with a 5% tolerance in the end, given my lack of experiance in analog power design. But I'll do my best.

Before hooking up some of the op-amps and my LT3080 regulator, I've been working on my regulator circuit in LT-Spice. 12 Volts to an AVR, (or my Dragon) would fry it pretty quickly, so I'm a little nervous and I'm trying to double check and segregate any potential exposure to 12 volts to the "high side" of the circuit. Adding explicit "over voltage" components would exponentially increase the complexity and wont be needed in the end if the design is right. It's mostly in the breadboard phase that I'm paranoid about making a $50 mistake by placing the wrong wire somewhere.

A lot of analog design for me so far is trial and error, and a learning experience. I'm having a tough time stabilizing the current-limiting part of the circuit. Right now, I've been placing caps a various places to try and filter some of the ripple. It's not bad in that it's really helped me get a feel for feedback in analog circuits, and how affected the transient response is by various capacitance values. 

Here's my really, really rough design  for a single channel regulator circuit. I haven't added the voltage sense part of it yet. 

It's supposed to be limiting the output current to 100mA, but there's a 35mA ripple in the current. It's really a work in progress yet.

Soon, I'm going to start placing parts on the breadboard. Also, I've got LT1490A opamps everyone in the LTSpice, design, but I'm only using those particular chips for the high side current sense part of the circuit, as they're kind of expensive.


No comments:

Post a Comment

I welcome you're thoughts. Keep it classy, think of the children.