Category Archives: Analog to Digital Converter

18F14K22 Accelerometer Analog to Digital Converter C Electronics Microcontrollers Motors PIC Steppers

18F14K22 Self-Balancing Platform

Well, it’s not finished but this is what I’m working on:

Balancing platform on a breadboard
Balancing platform on a breadboard

Ta-da.. yet another balancing something-or-rather.. except this one isn’t so great at it’s balance. This was a big old fail. I went wrong with steppers… I should have just used DC motors and maybe the next version I will. I used Pololu A4988 stepper motor drivers (A4988-based)  to control my steppers while attempting to use variable speed step resolution control. This worked okay but really while trying to drop holding current while balanced was a nightmare. Also the current usage was above what I consider useful… either backing the current limiting off to save some power (and your driver) then loosing control or you’re just cooking your motor driver and the current isn’t useful other than for a cute demonstration or a non-battery powered application.

I’m not dropping code, you can request it directly if you want it but it’s nothing magical. It has my own hacked up version of a PID loop. I didn’t use derivative. I think far too many cycles are wasted on it when PI will probably work for you. I haven’t fine tuned it because I’m unhappy with my results.

I was a little bummed out on past-Chas’ selection of an MMA7361 accelerometer;  I had gotten it from Sparkfun who-knows-how-long-ago. The link leads to the retired product. It’s just plain voltage output per axis. I must have still been shying away from I2C at the point? The board shown below:

Accelerometer break-out board
Accelerometer break-out board

For a micro I used a PIC 18F14K22 on the TAUTIC dev board with some AtomSoft breadboard goodies for troubleshooting, power and the serial interface (Breadboard Buddy).  <– that link will probably die soon. Tindie updates a lot and products are replaced with newer versions.. if you sniff around you’ll find it.

I’ll move along to another project now, perhaps order some parts and revisit this one again. If you run along this and you’ve done this with steppers I’d be interested in knowing how it worked out for you.

Analog to Digital Converter C Electronics Microcontrollers PIC RS-232

PID Control 1: Set up and thoughts

A while ago I acquired some electronics that had plenty of good stuff to “recycle”… An influx of some interesting mechanical bits I hope to add to a future project; It’s also held me up on new project posting after my last Modbus blog post.

Today I entered my shop and realized I was all done for the most part… What to do?! Well next on my projects list is “something PID” … It should really read “something PI”. PID is an algorithm for proportional, integral, derivative control. Wikipedia is your friend on the painful math bits. I don’t really use the D in PID much but it’s something to be aware of if you’re every looking into it yourself. My expectation in this experiment/project is to keep some item level with a stepper motor and hopefully tune my PI loop so it’s not hunting.

I work with PID nearly daily… So I’m going to just shoot from the hip and see what I come up with. No fancy math the first time around, let see where I go?

IMG_5668.JPG

I set up a 18F14K22 on the 20pin breadboard.. All the important stuff, and I’m outputting an accelerometer to an A/D and dumping it to the UART… I’m now at the point of writing the PID code. No code for now, I’ll link in some code when this project isn’t an over-glorified LED blinker and has some purpose.

My notes say I’ll take my process variable which will be accelerometer data on the X-axis. I’ll feed my PID process a setpoint (the value read at level) and the multiplier, a “gain” figure, and then finally process a error correcting value at some set time constant (timer?) I believe this legitimate proportional control.

The integration seems to be much more straightforward but maybe that’s wishful thinking… TBC!