# Implementing microcontrollers (AT89C51-24PC)

1. Oct 7, 2012

### Packocrayons

I'm planning on learning how to use microcontrollers (ATmega series) so that I can use the skill for various other projects.
I already know how to use arduino (which use the ATmega series of microcontrollers) and I feel as though this will only be an extension, since the coding will be the same.
What is required circuitry wise in order to run this? I understand I likely need to have a 5V regulator and peripherals in order to power the logic, but what else?
Do I need to add some sort of flash memory? What about SRAM?
Is programming as easy as hooking up the right pins to a USB cord and flashing to the chip (using which program, will the standard arduino program work for this?).

2. Oct 7, 2012

### vk6kro

There is a big difference between programming an Arduino in a C/C+ language and programming an Atmega in machine code.

So, if you want the convenience of the high level language, you should stick to the Arduino.

I often use Picaxe chips because they can be placed in normal circuits like any other IC, perhaps unlike the Arduino which requires a relatively expensive circuit module. Picaxe chips start at about $3. 3. Oct 7, 2012 ### Packocrayons What do you mean by machine code? I'd like to learn and be able to expand my horizons, withing reasonable difficulty. I don't like the picaxe flow chart system, it's too easy. 4. Oct 8, 2012 ### vk6kro Actually I should have said Assembler code. Here is an introduction to Assembler for an Atmega: http://www.avr-asm-download.de/beginner_en.pdf Don't knock Picaxe, at least on the grounds of being too easy. Easy is good. You don't have to use the "kiddy" flow charts. Real programming is done in a type of Basic which is heavily laced with I/O commands. It can be challenging enough if you try to get serious about programming. I have a friend who wanted to read a pot voltage and convert the result to Pulse Width Modulation to control a motor. A hardware solution to this was going to be very complex while a Picaxe did it in about 4 lines of code. Have a look here: http://www.picaxe.com/ http://www.picaxe.com/Getting-Started/PICAXE-Manuals 5. Oct 8, 2012 ### Packocrayons Well I am still 16 so maybe I should go for the kiddy programming :p The main reason I'm moving away from arduino is because I want more of a challenge, as well as the ability to expand by using different micros. I guess picaxe it is, it seems both languages are reasonably similar so I won't be losing anything. Thanks for the help. 6. Oct 8, 2012 ### vk6kro Each Picaxe chip can do a large number of useful tricks and it is worth knowing about them so you can use them if you need to. There are "programming kits" available but these tend to be overpriced and you can make a programming cable yourself for a few dollars or less if you have an old serial mouse you don't want. I like the freedom of buying a cheap powerful chip I can just plug into a socket and use instead of having to buy a module (like Arduino or Stamp) which costs a lot more and is much more bulky. If you want to get started, go for a larger Picaxe chip like the Picaxe 20X2. The 20 means it has 20 pins but it looks like any other DIP chip. 7. Oct 9, 2012 ### Packocrayons I was planning on going with the 28 something one (forget the name). What do I need to make the programming cable so that I can get it on the same order? 8. Oct 9, 2012 ### vk6kro There are several 28 pin Picaxes and some of them are nearly 10 years old now. The important bit is the end part of the type number. Look for an X or an M. These are more recent. They have more memory and can operate at faster speeds than the older ones. Download the manuals from the link above. http://www.picaxe.com/Getting-Started/PICAXE-Manuals The first one gives the programming cable details. It is just two resistors and a serial port plug. It also gives the pinouts of the various chips. 9. Oct 21, 2012 ### Packocrayons Okay so I have it (I actually ended up with 2 20M2's) and I'd like to start programming as soon as possible. I'm planning on making my own cable from a USB port. What is the pinout and/or wire color of a standard USB port on a computer? I don't have the right connectors on my laptop as depicted in the manual, and it never says anything about USB ports as far as I know. 10. Oct 21, 2012 ### vk6kro If you don't have a serial port on your laptop, you will need a USB to serial adapter. You can't directly connect the USB port to the Picaxe input. However, not all such adapters will work for programming a Picaxe chip. You need to get one which is assured to work for Picaxe programming. You could have a look on the Picaxe Forum to get a type of adapter that works OK. This comes up as a topic quite often and you should find one easily. Ebay has them for$1 plus postage, but they may not work.

Alternatively, you can get a USB cable from Rev-Ed in England. It is type AXE027 and sells for about 10 pounds (British).
Other distributors sell these too.

Just about any old PC is OK for this job so you could consider using an older computer just for programming. Even very old laptops had a serial port on them.

11. Oct 21, 2012

### Packocrayons

Alright, I guess I'll have to pull out the dinosaur and use it. It's only 13, it can handle it :p.
What about building the adapter? I do have one built for programming brushless motor controllers, I'm assuming it'll be different?

12. Oct 21, 2012

### vk6kro

The programming board for a Picaxe is so simple, it is easy to just include the couple of resistors on each project board.

You can buy programming boards, but they tend to be expensive. Putting a socket on a bit of circuit board with pre-etched tracks is pretty easy and there are lots of such boards available.

If you can find it, this type would be OK:

You may have an old serial mouse you don't want any more. Like the old ball type. You can use the cable from that.
Just trace the wires with a multimeter on "ohms".

Using a serial port is very simple and avoids the problems some people seem to have with USB ports, so it is good to, at least, start with a serial port.

Last edited by a moderator: May 6, 2017
13. Oct 22, 2012

### Packocrayons

I'll crank out an old computer then and start with the serial port. Once I get it working and want to be able to flash more often I'll start working on a USB to serial.

14. Oct 22, 2012

### vk6kro

Yes, that would be a good choice. You could just leave it set up while you test the various commands from the Picaxe manual.

http://www.picaxe.com/Software
I suggest you print out the pinout diagram for the 20M so that you can refer to it easily.

A useful setup would have a couple of LEDs (with series resistors) a switch, a pot and (because the 20 M can produce music) a sound transducer.

This would let you test various input and output commands. You will find these very well documented in the second manual with liberal use of examples to explain the command structures.

This is a very powerful chip and it should keep you amused for a while.

15. Oct 23, 2012

### Packocrayons

I plan on being very amused. Maybe next I'll build a little ipod with flash memory with an 08M2.
I'll make a book with the cover page being the pinouts and print out the manual on paper for quick reference.

16. Oct 23, 2012

### vk6kro

OK. Maybe try to turn a LED on and off before you make an iPod?

The Programming Editor has a pull down syntax help thing which is useful when you want a quick clue like where to put the brackets, etc.
But a printed version would be nice, if a bit bulky.

17. Oct 23, 2012

### Packocrayons

Yeah I'll start slow. I'll learn quickly once I get started because of my experience with arduino.
Old laptop is not working, so I'm going to have to jump right into the usb to serial. Wheres the best place to get started?

18. Oct 23, 2012

### vk6kro

I did notice this on Sparkfun:

https://www.sparkfun.com/products/9260

Seems promising. You have to install some drivers and it then seems like a com port to your laptop.