Pages: [1] 2   Go Down
Author Topic: Where to start for micro controllers (lower level than Arduino)?  (Read 1714 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

I got interested in Arduino because originally I wanted to get into micro controllers.

So there is a knowledge gap for me, between basic electronics (resistors, diodes, soldering, etc.) and Arduino, which is already a pre-packaged solution where I can immediately program it using an IDE and upload the software to the unit.

I have no idea where I should start for going lower level.

I have programmed, for example, in assembler (just basic stuff) on the desktop computer, so I am OK on the software side. I know C, Java, etc.

I tried searching for books with keyword "micro controller" but they are all over the place and I have no idea what to do.

All I know is ages ago, there were things called EPROMs and some things called PICS and stuff like that. How do I learn to program and use an off-the-shelf chip such as the 6502 or the ARM chips, or the ATMega in Arduino, etc? and what equipment do I need to get to program those chips? I assume I need some kind of memory system to hold the code and even load it onto the CPU? Are they even called CPU or just IC chips?

Hope you guys understand what I am trying to look for.

Ultimately I want to be able to take apart any toy or computer and get those chips and repurpose them into my own gadgets just like what I am wanting to do with Arduino, except I don't want to rely on a pre-packaged Arduino or BASIC stamp or things like that.

Thanks!
Logged

Canada
Offline Offline
Sr. Member
****
Karma: 0
Posts: 318
Sometimes teaching, always learning,
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I want to be able to take apart any toy or computer and get those chips and repurpose them into my own gadgets
You can just google one of "those chips", find a datasheet, decide if it is repurposable,  figure out how to incorporate it into a circuit, learn the language to program it ect.ect.

It will be a steep learning curve for each device. There is a reason Arduino is so popular.
Logged


nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8471
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
have no idea where I should start for going lower level.
Arduino is about a low as you can go, but you can just get AVR (or other) processors and a programmer and go it alone.

Quote
there were things called EPROMs and some things called PICS and stuff like that
EPROMs are long gone, PICs are still here and going strong.

Quote
6502 or the ARM chips, or the ATMega in Arduino, etc? and what equipment do I need to get to program those chips?
6502, forget it unless you are seriously into a retro trip. The others all have programmers and dev board in the $20-30 range. For example the LPC ARMs have neat $29 dev boards that are programmers as well. Google "LPCxpesso".  

Quote
I assume I need some kind of memory system to hold the code and even load it onto the CPU?
No, all that is usually inside the processor chip these days although you can use external memory on some chips.

Quote
take apart any toy or computer and get those chips and repurpose them into my own gadgets
Good luck with that, most commercial toys will have the program hard-coded in silicon and you won't even know what chip it is because they have their own serial numbers.

Older toys (using the 6502, Z80 etc) will be easier because their program will be in an external ROM that you can replace with an EPROM or EPROM emulator. In that case re purposing would be fairly simple.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I would recommend the tutorials on Sparkfun ( http://www.sparkfun.com/tutorials/57 ) to get you started with microcontrollers.

In short, resistors are devices that turn electrical 'energy' into heat.  Capacitors are devices that store voltage or charge. Inductors are devices that 'store' magnetic fields. Diodes are devices that restrict current in a certain direction similar to a one-way valve. Now these are very basic simplifications of electrical components and there are many variations of all these device.

A ground is a place of common voltage and is a reference point which is usually close to 0V.  Voltage is potential difference not absolute values so when measuring and notice you have 5V with reference to ground.  'Ground' could technically be at an arbitrary voltage, let's say 1V, making the actual voltage at the positive probe 6V.  The reason it is called ground or earth is because at some point in the circuit, perhaps back at the power station or near the meter, the wire is actually connected to the ground. I'm not exactly sure of this next part so don't quote me on this but from my understanding the reason the ground is 0v is because the Earth can dissipate an 'infinite' amount of voltage because it is so large.  The charges will try to spread as far apart as they can around the surface of a sphere ( earth ) and just because it's so large it is 0 at our point of contact.  Anyways, don't get caught up on whether ground is truly 0 or not.  One other practical application for grounds is for safety to protect consumers from discharge of high voltage.  For instance all metal cases of appliances are grounded.  If for some reason a 120V line became lose and touched the case ( which we're pretending is not grounded ) and you came by an touched the appliance.  The 120V would find a path to ground through you and could cause internal injuries.  If the case is grounded the 120V is 'shorted' ( I'll explain later) to ground and this will likely reset a breaker on your houses panel removing power from the device and keeping you safe if you touch it.

Some other key terms for learning electronics:
Series is when devices are connected one after another. All devices have the same current because there is only one path however voltage is different accross each depending on it's position in the series.
Parallel is when devices are connected to the same two points.  All devices have the same voltage but the current is split between each path between the two points based on the resistance.
Short or short circuit comes from the idea of taking the shortest path.  This is actually the result of a parallel circuit.  The 'short' path is the path with the least resistance and thus the most current.  Usually you would burn the wire or whatever was shorted which is why these scenario's are dangerous and often teh start of fire or in the case micro controllers the frying of chips
Open is just when there is a break in the wire or circuit preventing the flow of current.

Understanding the fundamental devices and these key terms should allow you to understand basic circuitry.

So i'm not sure how much back ground you have in electrical side, but hopefully that was helpful.  Anyways on to microcontrollers.  

I can't really explain microcontrollers without going into semiconductors, VHDL, finite state machines, but basically a microcontroller is just a little computer.  It has memory and a processor on in a single package.  If you think of your big CPU in your computer a microcontroller is just a much much more basic version of that.

EPROM ( Electronically Programmable Read Only Memory ) . I agree it's a weird name because if it's programmable it's not read only but it has to do with being programmable and read-only at different states so both words are valid. There is EEPROM which the first E is erasable with High-Voltage from external source or sometimes from UV lights.  I don't know much about this other than that but it's basically just another memory region for things that will remain constant during normal operation of the device so if you have something that will enver change you could put it in EPROM to free up some RAM space.

You said ages ago. lol there are still PICS and they are still quite popular and the main contender to AVRs ( Arduino / ATmega328 ).  PICS are just different style of microcontrollers that have different feature sets and different memory styles.

If you want to load code onto a microcontroller you need to follow those tutorials i recommended or look at the datasheet for the device and get it in a development board ( oscillators, decoupling caps, and power etc. )  Then you can use an ISP ( In System Programmer ) such as the AVR ISP MK II.

As a matter of fact i'm trying to create a post to teach you this exact skill of getting code originally written for Arduino onto a basic ATmega328 in my post here:
http://arduino.cc/forum/index.php/topic,87026.0.html

However your idea of scrapping IC's from toys is not very practical in my opinion. Each toy manufacture will use a chip specifically designed to be most economical for that toy based on I/O, memory, speed, etc.. There are thousands of variations of chips and the time it takes you to figure out which chip they used if you can even get it out without damaging it and then setting up a whole new development board for that chip each time is not feasible.  Also ATmega328 chips which are used in the UNO's are only about 4 dollars so it would be much  much better IMO to just become very familiar with these and then branch out to more capable chips in the future.

Hope that helps, my hands are tired of typing smiley
Logged

Washington
Online Online
God Member
*****
Karma: 38
Posts: 789
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote

However your idea of scrapping IC's from toys is not very practical in my opinion. Each toy manufacture will use a chip specifically designed to be most economical for that toy based on I/O, memory, speed, etc.. There are thousands of variations of chips and the time it takes you to figure out which chip they used if you can even get it out without damaging it and then setting up a whole new development board for that chip each time is not feasible.  Also ATmega328 chips which are used in the UNO's are only about 4 dollars so it would be much  much better IMO to just become very familiar with these and then branch out to more capable chips in the future.
Agreed. Also you can get chips like attiny13, attiny45 and attiny85 for <$2 if you don't mind just a few IO pins.
And don't forget to use resistors for LEDS from now on.
Logged

Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK thanks a ton everyone!

So looks like lots of IC chips are app specific, so I would be better deciding which specific generic chip(s) I might want to program, and then just read all about that and get the equipment to program them. I had originally thought that maybe there were just a handful of common chips being used everywhere but I guess it makes sense from a mass production standpoint to create custom chips and SMT boards to minimize manufacturing costs.

@mattm - your thread looks interesting & relevant; I will start there. Thanks!
(I eventually Googled to this, which I guess looks about the right chip:
http://www.atmel.com/dyn/products/product_card.asp?part_id=4720&category_id=163&family_id=607&subfamily_id=760)
« Last Edit: January 14, 2012, 10:41:31 pm by alohaduino » Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3941
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I use the Arduino IDE to develop, but as often as not, I've just got an ATmega328P microcontroller on a breadboard, with the necessary support circuitry (which is quite minimal) and whatever other circuitry I need for the particular gadget I'm working on. Sometimes I use WinAVR (Google it, free download), and I've also done a bit with some of the other AVR MCUs, e.g. ATtiny45/85 and ATtiny2313. Once I've got things working, if I want to formalize the gadget into a finished project, I'll design a PC board for it. The final product may or may not be running code generated by the Arduino IDE. Even if it is, it may no longer be fully Arduino compatible, perhaps just because of something simple like using a clock speed or source that no Arduino board supports. An ATmega328P can be had from Mouser for $3.50. I'd have a hard time justifying the salvage approach, and not because of hardware expense, but the learning curve for each salvaged chip would be prohibitive (if they could be figured out at all!)

I think of Arduino mostly as a pretty useful collection of libraries to do often-needed things. You are free to have your way with the hardware in exactly the same way you would with WinAVR or Atmel's AVR Studio, but you have the ability to draw on higher-level functionality if you like. For instance, the Wire library is used for I2C communications. If you'd prefer to roll your own from scratch, simply don't include the library, do your own thing.

In my particular journey, I'd say the following were key:
(1) I started with an Uno. Still very handy to have a couple around.
(2) I spent a lot of time reading the MCU datasheets.
(3) I got an FTDI board to do Arduino-style serial programming with the booloader, for projects on breadboards or PC boards.
(4) I got an ICSP programmer to program chips without a bootloader.

Hope this helps. Great fun!

Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK thanks; its great to get an overview of your journey and 'll that makes sense to me. I understand the flexibility of having libraries so you don't have to roll your own or try to reinvent the wheel while others have tried & tested code to call on.

I don't mind Googling around to find all the pieces, but sometimes a few books can help give the big picture so one knows what one is doing rather than try to stumble through the labyrinth. Are there any books recommended for this progress? I don't even know what a "programmer" is, although I assume it is an interface to load code onto the AT chip (I assume either assembler or c), but I don't know how that code is "typed in" (maybe just a dumb terminal emulator on the PC/MAC connected to the programmer via USB/serial?). So you can see where I am sort of at right now.
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3941
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'll usually look for a book as well, but in this case it was just a matter of piecing it together from various web sites. Correct, a programmer is a device which in the case of Atmel AVR chips, interfaces to the ICSP (in-circuit serial programming) ability of the chips.

Sounds like maybe you haven't taken the plunge yet? Better do it quick smiley-lol at least for me, hands-on is always best. Get an Uno ($30), and download the Arduino IDE. Then all you need is a PC and a USB A/B cable to program the Uno. It's a simple-minded IDE, but quite effective, the code is C/C++. The IDE allows the code to be entered, compiled, and uploaded to the Arduino board.

I have a really bad and neglected blog, but here is a post showing the breadboard approach. I made some little PCBs to help but they're strictly a convenience. Note there are two headers, one which is 1x6 pins, and one which is 2x3 pins. The former is the FTDI header that works with the Arduino bootloader, and the latter is the ICSP interface. The second picture shows an FTDI interface board connected, which is at the end of a USB cable. For all intents and purposes, from the viewpoint of the IDE, and programming, this setup is exactly equivalent to an Arduino Uno. Don't have a picture of an ICSP programmer but here is the one I use. An ICSP programmer can also be used to burn bootloaders onto new chips.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok many thanks! I do have an Uno and have been doing basic experimentation and tutorials on it. The C is fine for me as I know it from desktop computer programming. It's really fascinating to get down to the electrical level and being able to perform programmatic logic to it. I just can't get enough! :-)

I will check out your blog and links as well.
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 124
Posts: 6633
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
have no idea where I should start for going lower level.
Start with Arduino, read it's source code and figure out how it works.
Seriously.  One of the big advantages of Open Source Stuff is that you can LOOK at it and see how it works.

http://avrfreaks.net has a bunch of tutorials using the same processor family, and http://smileymicros.com/ has some more, including some that talk about the transition from Arduino to "lower level" coding.
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3941
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Arduino uses the AVR-GCC compiler, get the AVR-Libc User Manual here, it explains various AVR specifics like accessing registers, interrupts, etc. To go along with it, get the microcontroller datasheet here, as it explains all the various peripherals built in to the MCU, and the associated registers.

The compiler uses the same names for registers, bits, and interrupts as in the datasheet. Sounds like I probably don't need to whet your appetite, but try this alternative to the "Blink" example sketch on your Uno:

Code:
//blink an LED connected to Arduino pin 13

void setup(void)
{
    DDRB |= _BV(DDB5);    //set PB5 as output (Arduino pin D13, DIP pin 19)
}

void loop(void)
{
    PINB = _BV(PINB5);    //toggle PORTB5
    delay(1000);
}

For this one, move the LED to Arduino digital pin 9:

Code:
//use Timer/Counter1 to blink an LED connected to Arduino pin 9

void setup(void)
{
    DDRB = _BV(DDB1);                  //set OC1A/PB1 as output (Arduino pin D9, DIP pin 15)
    TCCR1A = _BV(COM1A0);              //toggle OC1A on compare match
    OCR1A = 62499;                     //top value for counter
    TCCR1B = _BV(WGM12) | _BV(CS12);   //CTC mode, prescaler clock/256
}

void loop(void)
{
}
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Woot! Very good. Thanks again good sirs (madams). I promise I will be diligent in digging deep through all those links and materials suggested.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quick question: This processor, if it has memory built-in, is that volatile? Or does it actually retain code when power is off?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 596
Posts: 33283
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If "This processor" is an Arduino then yes the program memory is non volatile but the memory that holds the variables is volatile.
Logged

Pages: [1] 2   Go Up
Jump to: