Microcontroller Programming With C

This is a discussion on Microcontroller Programming With C within the C Programming forums, part of the General Programming Boards category; I'm getting interested in building and programming robotics. I'm going to do this with C...microcontroller programming with C. Is this ...

  1. #1
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584

    Microcontroller Programming With C

    I'm getting interested in building and programming robotics. I'm going to do this with C...microcontroller programming with C. Is this much different? What would I need (I assume an emulator and/or something to burn the chip)?

    If anybody has any links to a microcontroller programming (preferably in C) with forums, etc., that would be very helpful.

    --Garfield the Programmer

    P.S. If you program microcontrollers in C, can you post some code so I can see the difference? Thanks.
    1978 Silver Anniversary Corvette

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,496

  3. #3
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Thanks for the link. I'll take a loop.

    Do you program microcontrollers, Salem?
    1978 Silver Anniversary Corvette

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,496
    > Do you program microcontrollers, Salem?
    No.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    I really have this new interest to make and write robots. It sounds costly, but I'm willing.

    --Garfield
    1978 Silver Anniversary Corvette

  6. #6
    Registered User
    Join Date
    Sep 2001
    Posts
    412
    Not as costly as you might think. The hardest part (for me, anyway) is the fact that I lack good mechanical engineering abilities -- in a shop, I'm decent, but making precision parts myself just isn't going to happen.

    The control hardware isn't that expensive -- microcontrollers are cheap enough, and if you can design your own programmer + software, it's not that costly to accomplish.

    My big problem with robotics has always ben the difficulty of making the mechanical parts -- the electronics are not that tricky, and rather fun.

  7. #7
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    >> and if you can design your own programmer + software <<

    Um...how would you/I design the software to compile? That sounds like a year project (or more). Not trying to be a ripoff or anything, but could I use yours? But, if you think that it is easy enough to program my own compiler, than I'll take a shot at it.

    Question: In a Win App, I can compile, link, and run the app right there. Uh oh, a typo. Change code. But, when programming a microcontroller, how do you see what you are doing without having to "burn" the chip?

    Thanks.

    --Garfield
    1978 Silver Anniversary Corvette

  8. #8
    xmdvp
    Guest
    Um...how would you/I design the software to compile? That sounds like a year project (or more). Not trying to be a ripoff or anything, but could I use yours? But, if you think that it is easy enough to program my own compiler, than I'll take a shot at it.

    Question: In a Win App, I can compile, link, and run the app right there. Uh oh, a typo. Change code. But, when programming a microcontroller, how do you see what you are doing without having to "burn" the chip?
    well, you are not the only one compiling C-code for microcontrollers. So if you buy a microcontroller you can be sure at 90% that there's a compiler for it. It doesn't mean that 100% of those compilers are free though. That might be the most expensive part.

    On another hand, maybe you'll enjoy coding in assembly language. It's a lot of fun, and you'll need a compiler too, but those are always cheaper.

    When I used to do that at school, programming in assembly language made it easier. For a couple of reasons. If you use C, then to access some registers, you will need a special library. Since it takes time for someone to code that library then it will probably cost you some money. + the home-made assembly language is less expensive in memory than the assembly language produced by a compiler. Also a lot of compilers are doing pretty good now as far as optimizing goes and they save you time.

    It's up to you to choose whether you want to save time but pay more money or save money but spend more time. Electronics and programming are all about compromising. All the ****ing time.

    back to your question. You need a simulator if you want to see what you are doing without burning the chip. But you don't really care because you can burn them as much as you want..... and you can debug them. You only need the tools.

  9. #9
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Isn't assembler hard to learn and program in? Of course, I'll probably move onto that, but for now I want to program the chips in C.

    So, the compiler comes with the chip? Good.

    --Garfield
    1978 Silver Anniversary Corvette

  10. #10
    Banned maes's Avatar
    Join Date
    Aug 2001
    Posts
    744
    You don't really burn them into a chip. You use a flash eprom.(erable programable)
    I didn't do it in c but in assembler but I think it is the same thing.
    first you write your program. then you compile it and then you take the .obj file and use a program and some hardware to program the eprom. then you link the eprom to the microcontroller. And when something is wrong, you flash (erase) the eprom and try again. So you never change the microcontroler itself, only the memory it is linked with.

  11. #11
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Okay, I've been thinking about it. Maybe I should really get into assembler. You know, keep C (to program Windows) for the software, and really get down core with assembler.

    I love a challenge, but could you rate this one? I'm sweating just thinking about learning assembler.

    --Garfield
    1978 Silver Anniversary Corvette

  12. #12
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    I can't stop thinking about assembler. Is it anything like C? Or will it be like learning a whole new trick?

    I really want to do this now. I'm going to go pick up a book on Sunday about assembler. Oh, and what chip (and where do I get all this equip?) do I get?

    --Garfield
    1978 Silver Anniversary Corvette

  13. #13
    Banned maes's Avatar
    Join Date
    Aug 2001
    Posts
    744
    I used a 8051 microcontroller and a flash eproms to program with.

    I think the most expensive thing is the hardware to program the eprom. I've no idea how much it costs. also another thing do you know something about electronics because you must know which resitors, capacitors and stuff to use?

  14. #14
    Sayeh
    Guest
    I've programmed robotics control systems for years. Everything from small home-built projects using 8051s to Nuclear Fuel Handling Machines.

    Let's start off on the right foot--

    THERE IS NO DIFFERENCE BETWEEN C AND ASSEMBLER. Any computer language for that matter-- they ALL compile down to assembly at some point (eg. 'machine code') so that the processor (CPU) can execute the code.

    The _ONLY_ difficult part is understanding how to control voltage on certain pins, so that you get power where you want it, in the quantities you want.

    both are ideal languages, although you would do well to consider learning assembler-- it would give you a big advantage because suddently you would learn how a CPU actually sees and handles code. You could then apply that knowledge elsewhere.

    If you want to learn easy assembler principles, get a book that covers the chip you want to use for your controller, or pick something like a Motorola MC65c02 (aka- 6502).

    Learn the principles, then learn the instructions (called mnemonics - pronounced 'new - monix' or 'knee-monix').

    What is 'machine code' really? Well, at the most basic level it is actual TTL logic in software.

    Let's work on something slightly simpler to begin with--

    Get yourself a stepper motor, and see if you can write a c program that will control that motor through your serial port-- it's not as hard as it sounds, and well worth the learning.

    Hint: you might need a few other parts, like a 16K ram chip, a small processor / eprom, and a transformer, plus battery voltage for the motor, and solenoids.

    If you have a laser printer, you can actually make your own circuit boards-- there are kits.

  15. #15
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    >> Hint: you might need a few other parts, like a 16K ram chip, a small processor / eprom, and a transformer, plus battery voltage for the motor, and solenoids. <<

    Arg!!! Where do I get all of this equip?

    How would I program this "stepper motor" and where would I get one? Wow, this is overwhelming.

    --Garfield
    1978 Silver Anniversary Corvette

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 11
    Last Post: 02-18-2009, 05:10 AM
  2. Replies: 27
    Last Post: 10-25-2007, 10:47 AM
  3. Programming a PIC 16F84 microcontroller in C
    By Iahim in forum C Programming
    Replies: 1
    Last Post: 05-13-2004, 02:23 PM
  4. C for microcontroller
    By phernyt in forum C Programming
    Replies: 2
    Last Post: 12-08-2001, 12:01 PM
  5. Microcontroller Programming With C
    By Garfield in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 11-18-2001, 01:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21