Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
This isn't about embedded programming per-se, but I have a question about analog-digital converters for regular PCs. Specifically, what are some good ones out there? I see a few and can't really make up my mind. I was hoping to find something in the short term that takes a signal from the range of 0-5V, samples it very rapidly, like > 10Hz, and has > 8bit precision. Has anybody worked with anything like this before for situations like this?

Adbot
ADBOT LOVES YOU

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
This seemed as good a place as any here to ask about some control systems stuff, since that's a common enough reason to use a microcontroller.
I'm sorry if there's a better place for it, but I didn't get anything at all on SA searching for "impulse response" or "transfer function."

I'm trying to figure out how I might model a discrete system for doing some testing. Particularly, it's a thermal environment where I have a quiescent temperature that things would stay at if not adjusted, and a controller that needs a little help hitting a temperature. If I set my controller to that quiescent temperature, it's as if nothing is happening. So I just assume that as my zero point. I was seeing some odd behavior that I don't model, so I was thinking instead it was time to get an impulse response. I just figured if I soaked at the quiescent temperature and then shot up the controller uncompensated for, say, half of a sampling period, I'd get a rough impulse response.

It's been years since I did any of this in school and the professor seemed to know a lot, but most of it didn't really stick. So I know the terms, but I didn't really get all the techniques down and I've long lost all the mathematical muster. I'm trying to figure out how I might model the system based on it's measured discrete impulse response. Then I'm wondering if I could relatively safely apply this to other temperatures, or if I'm just asking for serious trouble trying.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Delta-Wye posted:

Do you have a closed feedback loop? Can the microcontroller actively read the temperature and compensate? It might help to know what your input/output is (how are you controlling the temperature, for instance).

The thermal controller is in an open loop. I am closing the loop through a regular old PC, but I figured this was my kind of thread for control systems kind of problems regardless of that. There's an option for trying to close the loop to the thermal controllers in hardware, but it opens new problems such as the slew rate being so rapid that it can break something.

Delta-Wye posted:

What I'm trying to say is sometimes you don't really need to know anything, you just slap in a generic PID loop and tune your coefficients. Without knowing much about the system, I would guess that would solve it but you would need closed-loop feedback, at least, for that to be a doable approach.

Right now I'm using a fuzzy-logic approach because I haven't been able to get a PID formula that works in all situations. Yeah, if you have this specific model in the current conditions it's experiencing, I can make an algorithm that will take it from one specific temperature to another, but that's it. If I'm trying different temperature ranges, or somebody farts on the environment, it all would go to hell. I've found out that's the crux of most undergraduate controls courses. :(

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
Edit: Somehow I double posted a quote of myself. :wtf:

Rocko Bonaparte fucked around with this message at 16:41 on Apr 25, 2013

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

evensevenone posted:

There's only one formula for PID. I would think for a thermal system it shouldn't be too hard to find gains that work for a variety of conditions. You don't really need to bother modeling anything to use PID, you just tweak the gains.
I still am hoping to get a model of the system so I can run automatic tests against it. That is my main issue right now. Some of the units I'm using have less consistent behavior. They'll overshoot, but only if they've been jerked around certain ways. It's too complicated for me to derive just by looking at it.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Delta-Wye posted:

What kind of system are you using that a PID loop can't correct for? It sounds more like a terrible implementation when you tried it than a poor fit to your problem. It's usually not terribly difficult to control overshoot by tuning your gains.

I have to deal with different models of thermal controls installed in various different ways. Furthermore, the controllers are moderating different items, and those items can change their behavior at any point in operation. I have to expect to go from any temperature to another temperature within the range of, say, -30C to 100C. When I tried to tune a PID one day, I got it to go from one temperature to another fine enough. A day later, they had to change the environment, including how it was seating, and that PID developed a steady-state error.

Everybody is obsessing over the PID. That's not the thing. Whatever I come up with, I'd like to be able to test across a variety of different models that have given me problems in the past. I'm currently dealing with one with some very odd behavior so the convergence time is longer than I consider acceptable. I do still converge. So I'd like to be able to reproduce it's behavior in a simulation since I can't perpetually sit in front of the gear. Later I want to be able to run regressions against that to make sure I can still handle it. So I'm trying to construct a model of it. That is my preoccupation.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I got my Raspberry Pi the other day and have it running chaser lights now. I figured it was a nice board for writing quick-and-dirty stuff using common tools and powerful languages; I am just too lazy to pick up another ISA, and spend a bunch of time enabling hardware registers and crap rather than doing whatever. Actually my wife just wants me to do some microcontroller things for her for Instructables and whatnot, and I figured I could quickly humor her this way. The big problem I see is with the analog-digital disconnect. There aren't any DACs or ADCs for it. I was wondering what's the, well, laziest way I can get a pile of them on standby for screwing around. I saw this gertboard idea for having a bunch of I/O available:

http://www.element14.com/community/docs/DOC-51726/l/assembled-gertboard-for-raspberry-pi

That was close, but they only had two channels for DACs and ADCs. For whatever reason, the stuff my wife always asks about is the kind of thing that needs, like 8 of them or something else normally excessive. In that spirit I found this:

http://www.abelectronics.co.uk/products/3/Raspberry-Pi/17/

But that's just ADCs. Does anybody know of something for the Raspberry Pi readily available for going DAC/ADC crazy with some other bonus I/O?

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
Can somebody confirm for me that there isn't really a turn-key solution for interfacing with SPI in Python with the Raspberry Pi? I see some people have written wrappers, which I will be trying, but I was hoping by now there was something standard and blessed.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Delta-Wye posted:

Have you tried to read and write directly from /dev/spi with the normal file handling functionality?
I didn't have a handle for it in /dev/spi. Actually it looks like SPI is kind of the shady area of the Raspberry Pi, which makes me sad. There also doesn't appear to be a Python3-friendly module for SPI interaction that would work on the Raspberry Pi. At best I eventually got a spidev wrapper working in Python2 enough to light an LED on and off if I told it to just transmit piles of 0xFF's and 0x00's alternately. I couldn't get anything coherent out of this MCP3008 ADC package I was trying to test with a potentiometer. There's some C code out there so I am thinking I have to drop down into C-land and try ioctl or making my own driver; the Python honeymoon ended pretty quick.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Delta-Wye posted:

There is nothing wrong with C (:getin:), but Python can do ioctl calls.

EDIT: Although if the hw support is poo poo, you're hosed either way. I'm always surprised how terrible the software support for SoCs seems to be. Developing one is expensive enough, I'm surprised it isn't worth hiring a coder to knock out the necessary kernel parts for rock-solid support.
Once I saw that Raspberry Pi comes with SPI and I2C disabled by default in Raspian--and possibly the other distros that are part of the NOOB thing--I got worried. I don't really have a problem with C; I particularly do C++ for home stuff. I just figured I could rapidly prototype some stuff in Python, but if I have to trudge through some low-level details that take as much code to write in Python than C, or possibly even more lines of code in Python, then I might as well just go all the way. I had gotten the Raspberry Pi on that initial, damaged notion that I could use higher-level toolchains with it. Granted, I guess I'm still getting to use a mature C/C++ toolchain instead of one vendor-specific thing that doesn't implement any real standard correctly.

It's just alarming to me to think that people just bit bang with the Raspberry Pi and call it a day. My impression was that it didn't have ADCs, motor controllers, or anything like that, but at least it had SPI and I2C for expansion. Seeing the modules to drive them not even being loaded by default kind of gives me pause. But no matter, I'll get this MCP3008 to listen to me one way or another.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Bad Munki posted:

Post a trip report when you get a satisfactory solution. I haven't run into it yet so I haven't even bothered to look, but I do have some projects in mind where SPI and I2C would be critical factors.
My inspiration to switch to C or C++ came from here:
http://hertaville.com/2013/07/24/interfacing-an-spi-adc-mcp3008-chip-to-the-raspberry-pi-using-c/

I was surprised but this actually worked the very first time. It compiled and ran without a single bitch or moan, and it looks like I had my MCP3008 hooked up correctly.

On the Python side, I'm perhaps unrealistically bitchy because it looks like all the good libraries for SPI require Python2, where I was trying to use Python3 for everything. Particularly I had set myself up with QT4 with Python3 and was hoping to bring up a GUI to show things. I'm now assuming that EE stuff with Python in the world at large it stuck in Python2, and usually not even Python 2.7. I tried to interface with spidev, but whatever I was using was just generating bullshit. I'll have to really review the source in that hertaville tutorial and make sure I actually understand SPI. I actually never worked with it before, and kind of assumed that since there were two chip select pins, that I could potentially control 4 chips. :doh: I don't have a reason to do that, and I know one can do some things to expand things out (as simple as a mux), but I'm just saying I was ignorant even walking into it.

I guess if I were a big boy I would set up Boost.Python or something and write some good Python3 bindings for spidev and publish it. Actually, I'm kind of giggling in my head at the thought of trying to set up the Boost toolchain to do all that and have the result actually run on a Pi. :bang:

I have some stuff here that's technically I2C so later next week I'll probably start playing with that once I know a little more about what I'm talking about. I kind of bought a bunch of random crap to see what it was like interfacing with all this stuff.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

sund posted:

It looks like that mcp3008Spi class is a pretty thin wrapper around a couple ioctl and open/close calls. You could rewrite that in pure python pretty easily.
Maybe, but it's baby's first ioctl here. I can see that easily enough, but how do I handle native open/close calls? Deciphering and translating the proper ioctl values looks like a hoot though. The code I was referencing does drop into spidev's headers, and it's full of things like SPI_IOC_MAGIC, which is apparently the 'k' character.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
My wife was thinking of making a googly-eyed wreath for Halloween. I was wondering if there was something I could to make the eyes move and track something. This would be a lot of eyes on a wreath, so I don't think I could really control each one individually--unless we're talking like 10 servos for a buck or something. Can anybody think of any tricks?

Adbot
ADBOT LOVES YOU

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I am chewing on all the responses. The ultimate would be to have each of many eyes tracking a person, and that means each one moving ever-so-slightly so that they track perfectly. One motor could probably rule them all. Vibration is definitely the easy way out. I had figured for that, I could just slide in an old cell phone running something that makes it vibrate a bunch. I should probably look up getting cheap, little motors though. I have not looked that up in awhile, and I guess that has changed.

I had thought about something with magnets, but that's definitely not my forte. I believe my front door is in a metal sandwich, so I can do some stuff with that. I have to see if a fridge magnet or whatever sticks to it to tell if it might get in the way. I would just figure that magnets of that intensity would interfere with the stuff controlling it. We don't really expect much for trick-or-treaters though; we'd mostly do it in the lead-up to Halloween for people visiting.

  • Locked thread