Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Implementing microcontrollers (AT89C51-24PC)

  1. Oct 7, 2012 #1
    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. jcsd
  3. Oct 7, 2012 #2

    vk6kro

    User Avatar
    Science Advisor

    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.
     
  4. Oct 7, 2012 #3
    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.
     
  5. Oct 8, 2012 #4

    vk6kro

    User Avatar
    Science Advisor

    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.:biggrin:

    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
     
  6. Oct 8, 2012 #5
    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.
     
  7. Oct 8, 2012 #6

    vk6kro

    User Avatar
    Science Advisor

    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.
     
  8. Oct 9, 2012 #7
    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?
     
  9. Oct 9, 2012 #8

    vk6kro

    User Avatar
    Science Advisor

    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.
     
  10. Oct 21, 2012 #9
    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.
     
  11. Oct 21, 2012 #10

    vk6kro

    User Avatar
    Science Advisor

    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).
    http://www.picaxe.com/Hardware/Cables/PICAXE-USB-Download-Cable/
    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.
     
  12. Oct 21, 2012 #11
    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?
     
  13. Oct 21, 2012 #12

    vk6kro

    User Avatar
    Science Advisor

    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:
    http://www.jaycar.com.au/products_uploaded/productLarge_1105.jpg [Broken]

    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
  14. Oct 22, 2012 #13
    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.
     
  15. Oct 22, 2012 #14

    vk6kro

    User Avatar
    Science Advisor

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

    You need all three manuals and you can download them from here when you download the programming editor:
    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.
     
  16. Oct 23, 2012 #15
    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.
     
  17. Oct 23, 2012 #16

    vk6kro

    User Avatar
    Science Advisor

    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.
     
  18. Oct 23, 2012 #17
    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?
     
  19. Oct 23, 2012 #18

    vk6kro

    User Avatar
    Science Advisor

    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.

    They are in Boulder, Colorado.

    Yes, the batteries in laptops do not cope well with not being used so even a year or so of disuse is enough to wreck them. I fixed one by leaving it on charge for a few days. It suddenly fixed itself and started to charge.

    Have you downloaded the Programming Editor yet?
     
  20. Oct 24, 2012 #19
    Seems like a pretty simple circuit. I might have a line on a free laptop with serial ports but if not I'll do that. Screw the breakout board, it's too easy :p.
    Yes I have the editor.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Implementing microcontrollers (AT89C51-24PC)
  1. First Microcontroller (Replies: 19)

  2. Which Microcontroller? (Replies: 7)

Loading...