Maker Pro
Maker Pro

Basic Programming

Zymus

Mar 31, 2010
10
Joined
Mar 31, 2010
Messages
10
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?
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
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?

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.

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

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

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

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"

Are there limitations on the various types of chips?

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

Is there a large difference between programming PIC to FPGAs?

Yes

What are some reliable suppliers that have received good reviews from various members of the community?

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.
 

Zymus

Mar 31, 2010
10
Joined
Mar 31, 2010
Messages
10
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.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
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.
 

Zymus

Mar 31, 2010
10
Joined
Mar 31, 2010
Messages
10
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:

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
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.
 

55pilot

Feb 23, 2010
434
Joined
Feb 23, 2010
Messages
434
C++ is no more robust than C or assembler. Robustness is a quality a piece of code has -- it is up to the programmer.
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
 

Zymus

Mar 31, 2010
10
Joined
Mar 31, 2010
Messages
10
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 ^_^
 

Zymus

Mar 31, 2010
10
Joined
Mar 31, 2010
Messages
10
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?
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
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.
 

coffeecuppepsi

Apr 4, 2010
9
Joined
Apr 4, 2010
Messages
9
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
 

Revenant

Apr 14, 2010
6
Joined
Apr 14, 2010
Messages
6
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.
 

ElectronWorks

Aug 20, 2009
28
Joined
Aug 20, 2009
Messages
28
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:

Ian

Administrator
Aug 23, 2006
1,486
Joined
Aug 23, 2006
Messages
1,486
Hi Zymus

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

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

Bill

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.
 
Top