Connect with us

Basic Programming

Discussion in 'Microcontrollers, Programming and IoT' started by Zymus, Apr 1, 2010.

Scroll to continue with content
  1. Zymus

    Zymus

    10
    0
    Mar 31, 2010
    Hello, I want to get into the world of electronics and I've come to the realization that in order to be a jack-of-all-trades, I also need to know how to program microcontrollers, and how to the apply the code to different situations. So my question is, where should I start? I have an IDE, but is there certain languages restrictions?

    Does it have to be in C or ASM, or could it be in something more robust like C++?

    What's the best/easiest way to flash the chip with my new code?

    Are there limitations on the various types of chips?

    Is there a large difference between programming PIC to FPGAs?

    What are some reliable suppliers that have received good reviews from various members of the community?
     
  2. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,384
    2,771
    Jan 21, 2010
    There are always restrictions. Look around there are a number of different languages you can use. Some have more or less support than others.

    Be aware that the very limited memory (ranging from less than a kilobyte to tend of kilobytes) of most microcontrollers means that you will have a far less rich set of libraries at your disposal when compared to programming for a system having gigabytes of memory.

    C++ is no more robust than C or assembler. Robustness is a quality a piece of code has -- it is up to the programmer.

    Generally with a programmer. You may require more than one programmer (and more than one program) to flash a wide range of chips. In addition, some are not flashed, they're "burned"

    Yes. You need to start reading specs. They vary widely in almost every imaginable way.

    Yes

    Microcontrollers are typically propriety, so if you want a PIC, you have only one real option, same with ARM chips, etc... I'm not sure about counterfeit chips in this area, but I would not be surprised if they exist.
     
  3. Zymus

    Zymus

    10
    0
    Mar 31, 2010
    I'm not looking for anything that spectacular, just something that can, say, flash an led every 5 seconds, or send a signal, or array of bytes through a usb cord to the computer, just simple stuff like that.
     
  4. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,384
    2,771
    Jan 21, 2010
    USB is not simple :)

    PicAXE can do everything else.

    Flashing a LED every 5 seconds is actually quite tricky on most PICs as their timers generally time much shorter intervals. Well, maybe not tricky, but not trivially straightforward either.
     
  5. Zymus

    Zymus

    10
    0
    Mar 31, 2010
    Do you know about USB device programming? Or would that require a more advanced chip then PICAXE?

    With a different PIC timing at 5 second intervals, could i just make a assign a byte, have it increase by 1 ever 'tick'(1000ms), and then when it gets to 5, send the signal to the led, wait 250 ms, then terminate the signal to the light, and set the byte to 0 again?
     
    Last edited: Apr 1, 2010
  6. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,384
    2,771
    Jan 21, 2010
    You can get PICs that have USB interfaces, but then you'll likely have to create your own driver for them. The alternative is to use an external USB chip that comes with its own drivers. An example is an FT245RL.

    The USB interface is non-trivial to program directly.

    You should be able to do all you want in a single PIC. I recommend you look at the PICAXE and learn how to use that. Once you've gone as far as you can with that, it may be time to consider directly programming PICs in C or assembler.
     
  7. 55pilot

    55pilot

    434
    3
    Feb 23, 2010
    It is a matter of opinion, and I would beg to differ.

    First, the point of agreement. A "talented" programmer can find a way to screw up even the most robust language. Another talented programmer can write robust code in the loosest language. So yes, in the end it is all up to the programmer.

    Languages like C++ and Pascal make it harder for a programmer to mess up on the simple stuff. Thing like strong type checking, argument type matching and array subscript checking (in Pascal) catch some of the more common mistakes right at compile time. C on the other hand provides ample opportunity for the programmer to hang himself.

    Assembly language hands the programmer a loaded gun and a bottle of hard liquor and eggs him on to have fun with both. If the programmer lacks responsibility, maturity and experience, the results are predictably bad!

    For a beginner, I would recommend C or C++. C++ is a little more intimidating to learn than C, but it makes it a little harder to write bad code. In other words, it makes it more likely that you will write robust code without knowing what you are doing. In the end, you can write robust code in any of the languages and none of them will prevent you from writing terrible code.

    Many of the USB miscros do come with their own drivers that you can get away with using. It depends upon what you are doing. There are a number of "standard" USB devices defined in Windows. If you make your device look like one of them, you do not need a driver. When was the last time you needed a USB driver for a simple mouse, keyboard or memory stick? Many people will implement the standard serial device interface and then open the device using Hyperterminal in Windows. But doing USB programming takes things up a few notches and I would not recommend it as a first project.

    ---55p
     
  8. Zymus

    Zymus

    10
    0
    Mar 31, 2010
    WEll since i already know C++, it should be simple enough. Although, i'm not quite sure how that would work. I"ll have to look into it. Thanks for the help ^_^
     
  9. Zymus

    Zymus

    10
    0
    Mar 31, 2010
    Ok, does anyone know where a microcontroller terminology source would be? THings for like Vss, Vdd, What the RA, RB, RC, RD, etc are for the pins, and stuff like that?
     
  10. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,384
    2,771
    Jan 21, 2010
    Yes, the specs for the devices list all of that.

    Either google the device, or go to the manufacturer's web site and search for them there.
     
  11. coffeecuppepsi

    coffeecuppepsi

    9
    0
    Apr 4, 2010
    To start make sure you understand the pinout of the micro and what needs to be hooked up, also understand the concept of registers and what they do, if you don't understand this then it doesn't matter what language you choose you'll get nowere.
    you always have to select a clock, and set IO pins. that means not only setting a pin on/off but actualy configuring the pin as input or output first! There's an australian website Talking Electronics, they teach to program the PIC in assembler, but they also do a very good job of explaining registers... i'd recomend starting there
     
  12. Revenant

    Revenant

    6
    0
    Apr 14, 2010
    Some devices (Not many these days) don't have C++ compiler support for them. Having at least an understanding of assembly can help you debug tons of issues that could arise, especially with communication to hardware.
     
  13. ElectronWorks

    ElectronWorks

    28
    0
    Aug 20, 2009
    Hi Zymus

    I have just sent you a private message. I might be able to help.

    Please read it and let me know if I can help further

    Bill
     
    Last edited by a moderator: Apr 26, 2010
  14. Ian

    Ian Administrator

    1,487
    435
    Aug 23, 2006
    Sorry Bill, we can't allow members to directly solicit business on the forums- otherwise we would be over-run with people trying to promote their company on here.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-