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
overeager overeater
Oct 16, 2011

"The cosmonauts were transfixed with wonderment as the sun set - over the Earth - there lucklessly, untethered Comrade Todd on fire."



The old thread was archived, time for a new one! Please suggest corrections and additions.

What is embedded programming?
"Embedded systems" is a catch-all term for all the computers around us that we don't think of as computers. It covers a large range of platforms - from tiny microcontrollers where every byte counts, to powerful SoCs running full-blown Linux setups. Unlike PCs, embedded systems are typically programmed to handle a set of specific tasks and do them indefinitely.

What languages do I need to learn?
The number of available languages increases with processing power and memory - Linux boards like the BeagleBoard can run just about anything, and boards like the Netduino let you do embedded programming with .NET (embedded Visual Basic, anyone?).

On the lower end of the scale, though, you'll mainly be using C, and further along you'll want/need to look into assembly as well.

Embedded platforms - a short rundown

TI Launchpad (MSP430)


On the low end of the scale, the TI Launchpad is a simple programming board for the MSP430G2xx chips - 16-bit RISC CPUs with 2 kB of flash memory and an absurdly low power usage.

It's incredibly cheap to boot, costing just $4.30 shipped.

Arduino (AVR)


Based on the 8-bit AVR chips, the Arduino is one of the more popular microcontroller platforms out there. An official board costs around $30, but as it's open source hardware, cheaper clones are easy to find. It has a simple IDE that lets you set things up fairly quickly, and there is quite a lot of example code and tutorials available for it as well.

STM Discovery (ARM)


SilverAlicorn posted:

ARM was developed by Acorn Computers in the early 1980s to replace the aging 6502 family. The developers pretty much saw the dropping cost of semiconductor fabrication, thought to themselves "hey we could probably make our own CPU" and designed the single-most prolific ISA to date. ARM is literally everywhere, seriously. Your router, your cable modem, your cell phone, your GameBoy, your DVD player, probably.

At just under $10, the Discovery is probably the cheapest ARM dev board around. It has fairly good performance for the price, though, with a 32-bit CPU with 5 kB of RAM and 128 kB of flash memory.

Raspberry Pi


The Raspberry Pi is a fairly impressive system - it's credit card sized, it runs Linux, and it costs $35. It has a Broadcom BCM2835 SoC, with a 700 MHz ARM11 CPU and a dedicated GPU. (Right now the demand is huge, though - be prepared to wait or to pay extra if you want one.)

BeagleBoard (ARM)


The BeagleBoard blurs the line between embedded system and PC - it has fun things like a 1 GHz ARM CPU, 512 MB of memory, a dedicated DSP, USB, Ethernet, and just about everything else you could ever need. At $149, though, you probably won't be getting one to blink LEDs.

Other interesting platforms

Useful resources and links

overeager overeater fucked around with this message at 22:03 on Aug 12, 2012

Adbot
ADBOT LOVES YOU

Huragok
Sep 14, 2011
I'd also throw the Netduino into the OP: it's an ARM board running the .NET Micro Framework. I've found that a lot of others can make the jump from Desktop programming to micros through this nifty little board.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
There's an ARM version of the TI Launchpad coming out shortly as well; notably, it's based on a Cortex M4 which has an fpu! http://www.ti.com/ww/en/launchpad_site/stellaris.html?DCMP=stellaris-launchpad&HQS=stellaris-launchpad-b

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
Also the OP should probably talk about PIC at greater length and mention 8051s which are still pretty common

Pham Nuwen
Oct 30, 2010



The Raspberry Pi and the Beagle Board are both very cool, but I wouldn't call them embedded environments. They're really general-purpose computing devices which just happen to be in a small package. Also, though it seems counter-intuitive at first, Linux actually makes embedded work *more difficult*. With a simple device like an Arduino or a PIC, it turns on and immediately starts running your software, and ONLY your software.

Also, I'd like to point out that you don't need to spend $30 on an Arduino, depending on what you're doing. I built a 7-key USB chording keyset around an AVR chip (same as they use in an Arduino); aside from the $3 chip, IIRC I only needed a few resistors, a diode, and a crystal oscillator--total cost, probably $5-8.

Edit: vvv forgot about that part, but for $15 you can get one (https://www.sparkfun.com/products/9825) and re-use it over and over.

Pham Nuwen fucked around with this message at 18:44 on Aug 12, 2012

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

Pham Nuwen posted:

Also, I'd like to point out that you don't need to spend $30 on an Arduino, depending on what you're doing. I built a 7-key USB chording keyset around an AVR chip (same as they use in an Arduino); aside from the $3 chip, IIRC I only needed a few resistors, a diode, and a crystal oscillator--total cost, probably $5-8.

And a serial programmer.

Tetraptous
Nov 11, 2004

Dynamic instability during transition.
I started out with an AVR and an STK-500, and I think it's not hard to understand and makes more sense in the long run, but I understand why the Arduino is so popular--it's easy, self contained, and there's a huge community of people using it. Same reason people used to use the BASIC Stamp instead of just targeting the PIC directly. For a non-programmer non-hardware person, these make a great starting point.

ImDifferent
Sep 20, 2001
Also worth mentioning the Teensy: http://www.pjrc.com/teensy/

Basically an AVR CPU with USB interface in a DIP package. Pre-programmed with a USB bootloader, and comes with a few bits of sample code for implementing various USB device classes.

Popete
Oct 6, 2009

This will make sure you don't suggest to the KDz
That he should grow greens instead of crushing on MCs

Grimey Drawer
Gonna throw in for Renesas, they have some really nice low power chips like the RX family and the documentation is decent. But I have to say Atmel's documentation is the easiest and most straightforward for people new to embedded. Build your own high powered Arduino with an Atmega 1284P it's a good learning experience.

Popete
Oct 6, 2009

This will make sure you don't suggest to the KDz
That he should grow greens instead of crushing on MCs

Grimey Drawer
Can we talk about embedded operating systems in this thread? I have been working a bit lately with FreeRTOS and it's been great for small memory systems, very simple and configurable too.

overeager overeater
Oct 16, 2011

"The cosmonauts were transfixed with wonderment as the sun set - over the Earth - there lucklessly, untethered Comrade Todd on fire."



PIC, 8051, Netduino, and Teensy have all been noted! I'll write a bit as soon as I can - I'm actually using the Teensy for a simple MIDI box I'm making.

Pham Nuwen posted:

The Raspberry Pi and the Beagle Board are both very cool, but I wouldn't call them embedded environments. They're really general-purpose computing devices which just happen to be in a small package.

Fair enough - I put them there mostly to show the range of systems you can get for embedded use. The RPi in particular has been brought up often for DIY projects.

Popete posted:

Can we talk about embedded operating systems in this thread?

By all means!

Pham Nuwen
Oct 30, 2010



Popete posted:

Can we talk about embedded operating systems in this thread? I have been working a bit lately with FreeRTOS and it's been great for small memory systems, very simple and configurable too.

If we're going to talk embedded operating systems, have any of you used Inferno? It's a lot of fun and runs in a couple megs, which puts it outside the range of a PIC but it can run on ARM, MIPS, PA-RISC, PowerPC, SPARC, and x86 (according to wikipedia, I've only run it on ARM and x86) with only a little bit of RAM. It can run natively on hardware or hosted on top of Linux, Windows, or OS X. It's implemented as a register-based virtual machine; you write programs in Limbo which is a lot of fun.

hobbesmaster
Jan 28, 2008

Tetraptous posted:

I started out with an AVR and an STK-500, and I think it's not hard to understand and makes more sense in the long run, but I understand why the Arduino is so popular--it's easy, self contained, and there's a huge community of people using it. Same reason people used to use the BASIC Stamp instead of just targeting the PIC directly. For a non-programmer non-hardware person, these make a great starting point.

You don't even need to get an STK500, theres a lot of little micro board with USB built in so you don't need JTAG/serial programmers.

Pham Nuwen posted:

The Raspberry Pi and the Beagle Board are both very cool, but I wouldn't call them embedded environments. They're really general-purpose computing devices which just happen to be in a small package. Also, though it seems counter-intuitive at first, Linux actually makes embedded work *more difficult*. With a simple device like an Arduino or a PIC, it turns on and immediately starts running your software, and ONLY your software.

Also, I'd like to point out that you don't need to spend $30 on an Arduino, depending on what you're doing. I built a 7-key USB chording keyset around an AVR chip (same as they use in an Arduino); aside from the $3 chip, IIRC I only needed a few resistors, a diode, and a crystal oscillator--total cost, probably $5-8.

Edit: vvv forgot about that part, but for $15 you can get one (https://www.sparkfun.com/products/9825) and re-use it over and over.

Just buying the parts and throwing it on a breadboard/proto board from rat shack is not very nice if you don't wire everything up the first time.

Speaking of rat shack, they actually have arduinos in their physical stores!

One last thing since you mentioned the beagleboard - the leopard board is a similar board with plugin camera modules for image capture/processing.

hobbesmaster fucked around with this message at 01:34 on Aug 13, 2012

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

hobbesmaster posted:

Speaking of rat shack, they actually have arduinos in their physical stores!

Some of them do. Others are just cell phones, as far as the eye can see :(

hobbesmaster
Jan 28, 2008

Otto Skorzeny posted:

Some of them do. Others are just cell phones, as far as the eye can see :(

If you live in a decent size city at least one is probably a proper "hardware" radio shack with all of the drawers and everything.

Pham Nuwen
Oct 30, 2010



hobbesmaster posted:

If you live in a decent size city at least one is probably a proper "hardware" radio shack with all of the drawers and everything.

My city has a proper hardware radio shack. Admittedly, it's still a low selection, poor quality, and high prices, but the mere fact that I can walk 1/4 mile and pick up some caps, 7400 series logic, switches, etc. is pretty awesome.

Popete
Oct 6, 2009

This will make sure you don't suggest to the KDz
That he should grow greens instead of crushing on MCs

Grimey Drawer
One of the strangest things happened, radio shack actually had reed relays I needed that worked. Was trying to use a micro to control a AC system through opto isolators and digital triacs from digikey and nothing worked! Finally decided to just try a mechanical relay but didn't want to wait for shipping. Looked online and took a gamble headed to radio shack and they actually had the right ones rated for 120V, miracles do happen folks.

duck monster
Dec 15, 2004

I used to love those tiny little basic stamp things. You could pack a lot of punch into those tiny little guys for quick and easy automation projects. Like sure you cant run XMMP whilst downloading nzbs and mining buttcoins but I'm not even convinced that something like a raspberry pi in that sort of role counts as "embedded" anymore, anyway.

floatman
Mar 17, 2009
The netduino seems really interesting with the ability to code it in C#, but while looking up on that I came across this .Net Gadgeteer thing by Microsoft. Kinda like the netduino, but with more modules and costing more cash.

Anybody have any experience with either or both of them to share?

astr0man
Feb 21, 2007

hollyeo deuroga
I would count raspberry pi as an embedded device. Just because it runs linux doesn't make it not embedded.

hobbesmaster
Jan 28, 2008

astr0man posted:

I would count raspberry pi as an embedded device. Just because it runs linux doesn't make it not embedded.

Stuff running windows/x86 is considered embedded in some contexts too.

Arcsech
Aug 5, 2008
Anybody here used Cypress PSoC? I'm working in an embedded project at an internship this summer, with a fair mix of analog and digital stuff using the PSoC 3, which is basically an 8051 with a small FPGA and some analog hardware (op amps, PGAs, and comparators come to mind, plus some really cool internal signal routing hardware) stapled on. It's pretty easy to use, not Arduino easy but more so than, say, the MSP430.

(Edit: disregarding the recent port of the Arduino stuff to MSP430, Energia)

Although once you start pushing the limits of the internal routing, wrestling with the software to get it to do what you want can be difficult and basically requires understanding the layout of said internal signal routing hardware. Fortunately, they just updated PSoC Creator to include a feature that makes this much easier.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

Arcsech posted:

Anybody here used Cypress PSoC? I'm working in an embedded project at an internship this summer, with a fair mix of analog and digital stuff using the PSoC 3, which is basically an 8051 with a small FPGA and some analog hardware (op amps, PGAs, and comparators come to mind, plus some really cool internal signal routing hardware) stapled on. It's pretty easy to use, not Arduino easy but more so than, say, the MSP430.

(Edit: disregarding the recent port of the Arduino stuff to MSP430, Energia)

Although once you start pushing the limits of the internal routing, wrestling with the software to get it to do what you want can be difficult and basically requires understanding the layout of said internal signal routing hardware. Fortunately, they just updated PSoC Creator to include a feature that makes this much easier.

Ahahahahahahahahhaha yes, I will regale you with tales later

Arcsech
Aug 5, 2008

Otto Skorzeny posted:

Ahahahahahahahahhaha yes, I will regale you with tales later

I think I've seen some of your posts in the "learning electronics" thread, although I think your more detailed posts had already gone far past got buried by the time I started reading it. I'd like to hear your tales of (presumably) horror.

Huragok
Sep 14, 2011

floatman posted:

The netduino seems really interesting with the ability to code it in C#, but while looking up on that I came across this .Net Gadgeteer thing by Microsoft. Kinda like the netduino, but with more modules and costing more cash.

Anybody have any experience with either or both of them to share?

PlaIn ol' Netduino is just like any other embedded board but there is a downside: it's garbage collected. Without a few custom libraries floating out there you may have squishy interrupts (ie not push state, jump to subroutine).

The only benefit of the gadgeteer stuff is it basically makes makes the circuits plug and play. No wiring or components needed.

That's not how Schottky intended! :argh:

OctaviusBeaver
Apr 30, 2009

Say what now?
I'm trying to drive a small DC motor from an arduino using an H bridge. Do I need to size the H bridge to handle the stall current of the DC motor or just the normal operating current plus a safety margin (but still not as high as the stall current)?

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
Xpost from the electronics thread for a wider audience: Anyone know of a good USB-to-serial chip like the FT230 series that works as a USB CDC device without a driver install?



PS I haven't forgotten about the writeup about the PSoC that I promised somebody

movax
Aug 30, 2008

OctaviusBeaver posted:

I'm trying to drive a small DC motor from an arduino using an H bridge. Do I need to size the H bridge to handle the stall current of the DC motor or just the normal operating current plus a safety margin (but still not as high as the stall current)?

Personally, I'd size for at least 1.5x the normal operating current. Do you have any idea what in-rush current/transients can spike to? Safety margin(s) are always a good idea. If you have a chip rated for 1A, you have no idea if that chip barely passed QA or exceeded requirements with flying colours.

Also I am offended that PIC doesn't even get a picture in OP. PICs own, the devtools are great and the programmers are reliable as all hell. I love PIC24s/dsPICs; PIC32 isn't half shabby either.

e: you could separate a lot of the boards/CPUs in OP by whether they have a MMU or not, or are Linux (ignoring non-MMU ucLinux)-capable too.

OctaviusBeaver
Apr 30, 2009

Say what now?

movax posted:

Personally, I'd size for at least 1.5x the normal operating current. Do you have any idea what in-rush current/transients can spike to? Safety margin(s) are always a good idea. If you have a chip rated for 1A, you have no idea if that chip barely passed QA or exceeded requirements with flying colours.

Yeah, we went with the 5A h-bridge so I don't think it will be a problem. Unfortunately I'm not sure what the transients might look like this because I don't have the motors yet.

CapnBry
Jul 15, 2002

I got this goin'
Grimey Drawer
I've got a gcc-avr question I was hoping to get some light shed on. Imagine this code:
code:
// class.h
class Foo
{
private:
  int _x;
  int _y;
public:
  void Bar(void);
  void Baz(void);
};

// class.cpp
void Foo::Bar(void)
{
  ++_x;
  Baz();
}
void Foo::Baz(void)
{
  _y = 0;
}

// main.cpp
int main(void)
{
  Foo A;
  A.Bar();
  A.Baz();
  return 0;
}
avr-gcc 4.3.2 is inlining Baz() into Bar() and also inlining Baz() into main(). Normally I'd be all woohoo and poo poo about that but in my case Baz is 144 bytes of code and I'm really concerned about the code size here. I can flag Baz() the method with __attribute((noinline))__ for this instance, but in a 5,000 line program I'd like the compiler to decide to only inline functions when it makes the program smaller. I thought gcc wouldn't inline across module boundaries unless you used link-time optimization (-flto).

Command line
Compile: avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p ...
Link: avr-gcc -Os -Wl,--gc-sections -mmcu=atmega328p ...

Pretty Cool Name
Jan 8, 2010

wat

So, I've just started working at a company that develops an operating system (and some other stuff) for embedded systems and DSP-processors. Still in the training phase trying to get up to speed with everything but drat, it's so much fun.

some kinda jackal
Feb 25, 2003

 
 

Otto Skorzeny posted:

There's an ARM version of the TI Launchpad coming out shortly as well; notably, it's based on a Cortex M4 which has an fpu! http://www.ti.com/ww/en/launchpad_site/stellaris.html?DCMP=stellaris-launchpad&HQS=stellaris-launchpad-b

Thanks for this, by the way. I picked up a pair and the very next day they went to $12 apiece.

I guess now I should get off my rear end and figure out how to develop for these, huh.

some kinda jackal
Feb 25, 2003

 
 
Hey fellas, hate to doublepost but I want to bump the thread with a question:

I picked up a Freescale FRDM dev board on a whim just to dick around with. Unlike Arduino, which is ridiculously easy to start developing on, this seems to be a nightmare of toolchains and outdated facts from 2008.

I'd like to build a development environment using MacOS, but failing that I'd be okay developing in a Linux VM. However Freescale seems to only offer development tools for Windows. Should I be able to use some off-the-shelf ARM GCC toolchain to target this bad boy or do I have a lot of reading ahead of me?

Moving from Arduino development to ARM develoment is like going from riding a car to flying the space shuttle. As far as instructions go, anyway.

astr0man
Feb 21, 2007

hollyeo deuroga
I think you can probably cross compile, but building a cross-gcc toolchain is a giant pain in the rear end. It might be easier from inside a linux vm.

some kinda jackal
Feb 25, 2003

 
 
Yeah, I see that osx host support is in the roadmap for the arm gcc toolchain, but I'm not really going to wait until 2013 or whenever they get around to it. I'll be happy to do it from inside a VM if that's the case.

Anyone have any recommended "hit the ground running" resources for ARM coding? Arduino makes it pretty easy to get up to speed quickly, but something tells me this is going to be a little more painful.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
I'm surprised the Freescale ARM stuff isn't cross platform; the HCS08 stuff I sometimes use at work is all based on Eclipse these days.

some kinda jackal
Feb 25, 2003

 
 
Yeah, the download on their site is CodeWarrior something-something. I'm looking at a bunch of Eclipse stuff, and tried to compile my own cross-compiler but that was a giant pain in the rear end, as astr0 predicted.

I'll be more than happy to run this all in a VM. Again, my main problem is a lack of clear instruction for people who aren't already terribly familiar with embedded development. It's nothing I won't be able to overcome since I like to think I'm a pretty bright guy, but there's so much specialization where every board developer recommends their own set of tools, etc.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
Extra aside: I know I promised a real review of the PSoC a while back. Here's the abbreviated version:

- The libraries they provide are generally real easy and less buggy than the average embedded library in the classical sense, although there are many semi-documented assumptions that are made (eg. that your CPU clock at run time is the same as your bus clock was at design time) that can bite you in the rear end. Also they use camelcase which is kind of grating but whatever.

- The digital stuff is almost spectacular. While their logic blocks don't really comprise the "mixed signal FPGA" that they try to sell it as, they are often very useful.

- The DMA capabilities are awesome.

- Power usage is kind of meh. Pretty much dead average.

- The analog spec is a lie through and through. Every word of it. Including "and" and "the". And even the parts that resemble the truth are full of annoying limitations. Especially PSoC 5, which is basically evaluation silicon masquerading as a product. The PSoC 3 on the whole is much more mature and generally works the way it is supposed to, although there are some bugs and limitations that effect both.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

Martytoof posted:

I'll be more than happy to run this all in a VM. Again, my main problem is a lack of clear instruction for people who aren't already terribly familiar with embedded development. It's nothing I won't be able to overcome since I like to think I'm a pretty bright guy, but there's so much specialization where every board developer recommends their own set of tools, etc.

This is the biggest pain in embedded development in my opinion. Everyone vendor has their own special snowflake one-off half tested development toolchain. This poo poo factors into business decisions, by the way - once you have a couple of developers that are comfortable with the toolchain for a particular chip, it's pulling teeth to switch to something else for another project after they've already learned the ins & outs & quirks & register names.

FWIW, CodeWarrior is pretty slick once it's configured (it has something like CTags/CScope built in), and if they haven't changed the debugger from the one that I've used it's about the best there is.

Adbot
ADBOT LOVES YOU

some kinda jackal
Feb 25, 2003

 
 
All told, I'd rather do my development on a Linux VM than a Windows VM, but if it's going to be a tremendous pain then I'm not going to fight it and just go with what Freescale recommends and build a Windows environment.

So just one thing I'd like to be clear on: If I can find a generic ARM toolchain, I should be able to compile code for my Freescale FRDM-KL25Z, right? I just want to make sure that I'm not wasting days trying to cobble together a Linux VM with ARM toolchains I download from source forge and then find out that it's irrelevant because I have to use whatever Freescale gave me.

I also found http://www.gnuarm.com but everything there seems to be six years old so I'm not sure I really want to install packages that old.

Sorry if these are really basic questions, I don't mean to flood the thread with things I could easily google online, but I'm having some trouble wrapping my head around the whole ARM development workflow, coming from an Arduino background, combined with the fact that there's a LOT of diverging information online.

  • Locked thread