Getting into Microcontrollers?

Status
Not open for further replies.

svdsinner

Ars Legatus Legionis
15,152
Subscriptor
I've often wanted to get into micro-controllers (Note, I might be misusing the term microcontroller. I'm talking about embedded programming, whatever the correct term is.) for some evil-scientist garage projects, but have never had any idea where to begin.
The things I've been interested in doing are basic control circuits for things like:
  • Turn things on/off based on temperature
  • Turn a motor on and shut it off based on some boundary switches. (Motor opens door until door contacts end of motion switch, etc.)
  • Daily timers. (Do some things on a schedule each day. Home automation type things.)
  • Internet connectivity or remote control stuff would be cool.

I understand all the theory, but have no pragmatic knowledge of microcontrollers. I'd need to learn all the ground-level stuff like:
  • How do I pick a microcontroller for what I want? Where do I buy them, how do I figure out what features can be had from "stock" microcontrollers?
  • What type of an IDE do I use to program them? What languages can I use to program them?
  • How do I connect one to my dev machine to download code to them?
  • I probably could use a good "Embedded programing for Dummies" book. Any suggestions? (Doesn't need to be "for dummies," just needs to contain the basics since I have zero practical experience with them.
 
Yep, they're microcontrollers.

Everything you want to do is within easy reach by the sound of it. Think about whether you want to go low-level, like a main loop or tiny OS, or Linux.

From my experience, the critical step is understanding that when you write to a port at some given address, pins change state as a consequence of that, and the opposite for inputs. And that's how you sense or control the outside world. Registers map pins (or more generally, hardware blocks). That's it. Otherwise it's just the same as any other programming, modulo hardware weirdnesses and high-level features like GC.

See if you find this interesting. Notice the product-line-name-as-price gimmick. You simply can't do better than this for price, and it's a pretty decent family. Reminiscent of the PDP-11, a little. If you want something else, there's always ARM-based (Stellaris, LPC, lots of others). Or AVR or Microchip if you like the idea of 8-bit.

They all come with differing feature sets. Depending on what you want to do, look for varying amounts of flash, SRAM, EEPROM; GPIOs, external interrupts; timers, PWM, capture/compare; ADC; SPI, I2C, USART. Those are the basics, then there are some with DMA, DACs, I2S, etc. Also think about the voltages you want to work with, typically 3.3 or 5, but TI does some single-AA battery jobs.

Programming is normally by JTAG, which costs, although you can often find inexpensive USB programmers for certain families.

Most programming is C, with some ASM of whatever flavour. Not much C++ until you get to 32-bit jobs with lots of flash. The IDEs are typically either very proprietary and expensive, or GCC/Eclipse. (Edit: But either way you can always get crippled versions which either handle teeny projects, or die after a few weeks. We tend to get free full licenses from our component suppliers. You could too, if you have some interesting ideas, and contact a rep.)

If you prefer really stretching yourself, you might find Forth for any given device.

For intro level advice, "Jan Axelson" is well regarded (Google it). But pretty much any dev kit will have an introduction sufficient to begin with.
 

svdsinner

Ars Legatus Legionis
15,152
Subscriptor
PastorOfMuppets":95oliw91 said:
Get this and this; there you go your developing for micro-controllers.
There looks to be 1001 different types of Aruindo thingies to buy. (And similar TI thingies in the other link.) If I got the book, does it break down what all the variations are and what I'd need to buy?

What would I actually need to start, and how would I figure out what to expand to when I wanted to?
 
svdsinner":2axuy16g said:
What would I actually need to start, and how would I figure out what to expand to when I wanted to?

Get the base Arduino and download the software from the website. That is everything you need to "start". Create a simple das blinkenlights to get a feel for the development process and take it from there. You can get shields later to expand as needed.
 

norton_I

Ars Tribunus Angusticlavius
6,174
Subscriptor++
svdsinner":brkktnz7 said:
There looks to be 1001 different types of Aruindo thingies to buy. (And similar TI thingies in the other link.) If I got the book, does it break down what all the variations are and what I'd need to buy?

What would I actually need to start, and how would I figure out what to expand to when I wanted to?

The one you want is the Arduino Uno, the latest revision of the basic dev board. It is programmed over USB, so the only extra hardware you need is whatever you want to connect to it.
 

Wildbill

Ars Praefectus
3,327
Subscriptor++
If you don't already have basic electronic components to hand, consider getting an Arduino starter kit - it's an easy way to get a few resistors, LEDs, switches, interconnect wire and a breadboard to plug them into. Otherwise, you're stuck with turning the LED on the board on & off, which is nice to get working, but gets old pretty quickly. If you want internet, there's an ethernet shield available, and cutedigi sells a wifi one - I have one sending room temperature data to my web server right now.

As to books, there's plenty of documentation at the Arduino web set to get you started with basic stuff.
 

Edzo

Ars Praefectus
4,460
Subscriptor++
svdsinner":3dwof8hm said:
I was clicking around, and saw the .NET Micro Framework.
Anyone know anything about it? Since I've already got tons of C# experience, I thought it might be worth investigating.
There's a .NET version of Arduino (well, the same idea) that uses the micro framework called Netduino.
http://www.netduino.com/
 

Wildbill

Ars Praefectus
3,327
Subscriptor++
Edzo":14xa58g9 said:
svdsinner":14xa58g9 said:
I was clicking around, and saw the .NET Micro Framework.
Anyone know anything about it? Since I've already got tons of C# experience, I thought it might be worth investigating.
There's a .NET version of Arduino (well, the same idea) that uses the micro framework called Netduino.
http://www.netduino.com/

If you go this route (and why wouldn't you, just for multi-threading) look at the netduino-plus - it has on board ethernet. Sadly, it's also out of stock everywhere at the moment.

edit: Spelling
 
As an alternative the Arduino, the Propeller chip from Parallax is an interesting piece of work.

Eight on-board 'cogs' -- think processors/threads -- shared memory, semaphores, I/O ... if you get the YBox2 Kit from thinkgeek.com or adafruit.com, the kit includes ethernet as well as a network-based firmware/uploader so you can even program it without a special cable.

Different programming language/environment from the Arduino family, however...
 

svdsinner

Ars Legatus Legionis
15,152
Subscriptor
I decided to look at the Netduino Emulator project to "try before I buy" in familiar old C#.

I downloaded stuff and tried to run it, but am running into the same errors that these guys got and haven't found a way past them. (Needless to say the one posted suggestion didn't work.) Any ideas? (I'm a newb to the remote debugging stuff, so I assume there is something basic to fix this that I just don't know.)
 

BlackHex

Ars Tribunus Angusticlavius
9,638
Subscriptor++
svdsinner":166s6zo9 said:
I was clicking around, and saw the .NET Micro Framework.
Anyone know anything about it? Since I've already got tons of C# experience, I thought it might be worth investigating.

I was reading up on it but the non-realtime nature seems a bit worrisome.. imagine not being able to react because the framework was busy doing GC... it's ok on the desktop because most likely the only thing that will have to wait is a user but in a microcontroller where god knows what is attached? Scary :eek:
 

Deffexor

Ars Tribunus Angusticlavius
7,607
Moderator
I can't imagine GC on 128KB of RAM would take too long (even at a lowly 48Mhz) ;)

But your point is well taken in that there is overhead with the NETMF stack. Apparently typical response times for the Netduino are measured in milliseconds, not microseconds (like with the Arduino)

Still, millisecond response time is often fast enough for most projects.
 

norton_I

Ars Tribunus Angusticlavius
6,174
Subscriptor++
BlackHex":2jzu1vr0 said:
I was reading up on it but the non-realtime nature seems a bit worrisome.. imagine not being able to react because the framework was busy doing GC... it's ok on the desktop because most likely the only thing that will have to wait is a user but in a microcontroller where god knows what is attached? Scary :eek:

I think the idea with .NET micro framework is that it would be mostly likely acting as a hub coordinating with individual sensors / devices with their own local controller (which could even be an AVR) and a serial (i2c or SPI) interface. Still, as you say the netduiono and friends are not going necessarily going to be suitable for controlling devices like ADCs that don't have a FIFO and need the sample read immediately when it is available.
 

svdsinner

Ars Legatus Legionis
15,152
Subscriptor
svdsinner":34e2k2a2 said:
I decided to look at the Netduino Emulator project to "try before I buy" in familiar old C#.

I downloaded stuff and tried to run it, but am running into the same errors that these guys got and haven't found a way past them. (Needless to say the one posted suggestion didn't work.) Any ideas? (I'm a newb to the remote debugging stuff, so I assume there is something basic to fix this that I just don't know.)

Anyone? Bueller? Bueller?
 
Status
Not open for further replies.