Register to reply

Best programming language for a microcontroller?

Share this thread:
Jarfi
#1
Dec14-13, 07:00 PM
P: 271
So I've taken a course in java and gotten a solid grasp on it, I've learned using the arduino assembly language and messed around with it making some gadgets, and now I wan't to go further.

I want to buy a pure microcontroller or processer without a board, and start programming simple stuff on it, later graduating to more complex stuff like video transmission and all the mind can dream off.

What is the top tier final language engineers can use to do just about anything, like controlling a machine via radio and transmitting and recieving a radio using the same antennas. Even controlling a large LED screen, you get the point.

So the question is, best language for microcontrollers for use in machines

p.s. out of curiosity, what is windows written on?
Phys.Org News Partner Engineering news on Phys.org
Comfortable climate indoors with porous glass
Crash-testing rivets
Customized surface inspection
phinds
#2
Dec14-13, 07:30 PM
PF Gold
phinds's Avatar
P: 6,129
assembly language will always do everything you want but it can be VERY tedious.

C is generally the best language for stuff that is close to the hardware, but you'll need to be sure there is a cross-compiler for the microprocessor you decide on and that you have the wherewithal to move object code from the cross compiler output to the microprocessor.

Windows is written for the Intel x86/Pentium platforms.
Jarfi
#3
Dec14-13, 07:35 PM
P: 271
Quote Quote by phinds View Post
assembly language will always do everything you want but it can be VERY tedious.

C is generally the best language for stuff that is close to the hardware, but you'll need to be sure there is a cross-compiler for the microprocessor you decide on and that you have the wherewithal to move object code from the cross compiler output to the microprocessor.

Windows is written for the Intel x86/Pentium platforms.
Aren't there several types of C ? and if so what one to I choose, also I've tested arduino assembly language which in based on C I think and it all looks almost exactly like java, I think I'd adapt to C in no time.

phinds
#4
Dec14-13, 07:47 PM
PF Gold
phinds's Avatar
P: 6,129
Best programming language for a microcontroller?

Quote Quote by Jarfi View Post
Aren't there several types of C ? and if so what one to I choose, also I've tested arduino assembly language which in based on C I think and it all looks almost exactly like java, I think I'd adapt to C in no time.
No, there is only one C language. There is also C++ and C# but they are object oriented languages and not good if you want to stay close to the machine.

You may be thinking of compilers. Of course there are numerous C compilers, but that's not what you need. You need a cross compiler.

Do you fully understand the concept of what the BIOS is and what it does and what you have to do if you are doing raw programming on a microprocessor that doesn't have a BIOS ?
Jarfi
#5
Dec14-13, 07:58 PM
P: 271
Nope. I have no Idea what a BIOS but Im guessing its something that that makes the processor be able to "talk" in C. Anyways since I need to get to the core I will choose C then, and yes C++ and C# is what I meant, I thought they were variatiants of C itself, apparently I was wrong. So what do I have to do to get my fresh out of the factory processor to work with C?
Nick O
#6
Dec14-13, 08:31 PM
P: 151
When you say that you have used the "Arduino Assembly Language", do you mean this language?

/*
  AnalogReadSerial
  Reads an analog input on pin 0, prints the result to the serial monitor.
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
 
 This example code is in the public domain.
 */

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
  Serial.println(sensorValue);
  delay(1);        // delay in between reads for stability
}
If this is what you mean, it is not Assembly, but C++ with a few custom libraries. Assembly depends on the architecture, and requires a knowledge of the available hardware functions, registers, and memory.

C++ and C are both good languages for working close to the hardware without actually having to know what the hardware is. Of these, C is probably better.
Nick O
#7
Dec14-13, 08:33 PM
P: 151
Quote Quote by Jarfi View Post
Nope. I have no Idea what a BIOS but Im guessing its something that that makes the processor be able to "talk" in C. Anyways since I need to get to the core I will choose C then, and yes C++ and C# is what I meant, I thought they were variatiants of C itself, apparently I was wrong. So what do I have to do to get my fresh out of the factory processor to work with C?
No processor speaks C natively. C must always be compiled to machine language, which is essentially Assembly with keywords swapped almost 1 to 1 with sequences of binary digits.

Don't worry about that though. Almost everything has a C compiler; you just need to find it.
rp55
#8
Dec14-13, 08:41 PM
P: 82
Quote Quote by Jarfi View Post
Nope. I have no Idea what a BIOS but Im guessing its something that that makes the processor be able to "talk" in C. Anyways since I need to get to the core I will choose C then, and yes C++ and C# is what I meant, I thought they were variatiants of C itself, apparently I was wrong. So what do I have to do to get my fresh out of the factory processor to work with C?
I think you're a bit lost. The microcontroller/microprocessor has its own language (machine code). It is a certain configuration of 1's and 0's. That language has been abstracted into "assembly language" by the chip manufacturer. They provide you with an assembler to use to turn that abstraction into the machine code. C is another layer of abstraction on top of assembly abstraction. When you compile a C program it gets turned into assembly and then into the actual machine code (or some shortcuts therein).

C is standardized. The specs must be purchased (but they're out there). Whether or not a particular C compiler will turn your C code into something correct (machine code-wise) for the target chip is probably the main thing to consider.
phinds
#9
Dec14-13, 10:09 PM
PF Gold
phinds's Avatar
P: 6,129
Jarfi, I mean you no disrespect but if you have no idea what a BIOS is then you are planning to go in WAY over your head. I suggest that you study basic computer architecture and then basic operating system architecture before you attempt your project. Right now, you don't even know what questions to ask.
rp55
#10
Dec14-13, 10:27 PM
P: 82
Quote Quote by phinds View Post
Jarfi, I mean you no disrespect but if you have no idea what a BIOS is then you are planning to go in WAY over your head. I suggest that you study basic computer architecture and then basic operating system architecture before you attempt your project. Right now, you don't even know what questions to ask.
I know what you're saying but a microcontroller doesn't require a "BIOS". A microprocessor does. He seems to be leaning towards microcontrollers more. A microprocessor (more difficult to deal with from scratch) has no storage for a program. A microcontroller does and can be flashed or manufactured (internal "bios") with such..
phinds
#11
Dec14-13, 10:56 PM
PF Gold
phinds's Avatar
P: 6,129
Quote Quote by rp55 View Post
I know what you're saying but a microcontroller doesn't require a "BIOS". A microprocessor does. He seems to be leaning towards microcontrollers more. A microprocessor (more difficult to deal with from scratch) has no storage for a program. A microcontroller does and can be flashed or manufactured (internal "bios") with such..
A reasonable point as far as it goes, but I believe my comment is still valid. It seems to me that he doesn't understand the fundamental structure and interrelationship of hardware / operating systems / computer languages. I could be wrong about that. Jarfi, what do you say?
rp55
#12
Dec14-13, 11:45 PM
P: 82
Quote Quote by phinds View Post
A reasonable point as far as it goes, but I believe my comment is still valid. It seems to me that he doesn't understand the fundamental structure and interrelationship of hardware / operating systems / computer languages. I could be wrong about that. Jarfi, what do you say?
Absolutely your comment is 100% valid, sorry if it came off as a negation. I agree he needs to understand architecturally what entails both IC types before proceeding (of which a bios is a key part of). I guess the reciprocal might have been if we said he needed to understand chip programmers before proceeding... which wouldn't necessarily apply much to the microprocessor (besides programming the bios lol).
dlgoff
#13
Dec14-13, 11:54 PM
Sci Advisor
PF Gold
dlgoff's Avatar
P: 2,704
Quote Quote by phinds View Post
I suggest that you study basic computer architecture and then basic operating system architecture before you attempt your project.
I agree. He could use an old PC with an older operating system and play with a this very simple language which can make calls to system interrupts thereby learning it's architecture.
phinds
#14
Dec15-13, 12:54 AM
PF Gold
phinds's Avatar
P: 6,129
Quote Quote by dlgoff View Post
I agree. He could use an old PC with an older operating system and play with a this very simple language which can make calls to system interrupts thereby learning it's architecture.
Yeah, that's a good idea.
Jarfi
#15
Dec15-13, 05:41 AM
P: 271
Quote Quote by phinds View Post
A reasonable point as far as it goes, but I believe my comment is still valid. It seems to me that he doesn't understand the fundamental structure and interrelationship of hardware / operating systems / computer languages. I could be wrong about that. Jarfi, what do you say?
First off, I'd like to say I am 19 years old studying physics with no educational backround in electronics, it is merely self taught apart from some java side courses. Most of my knowledge is assumptions based on observations I have learned over the past couple of months I've been discovering computer sciences and electronics.

Now, I am simply trying to get a solid grasp on microcontrollers, if I'd have to program a microprocessor I'd probably just get somebody to help me with that.

If I can program in C, turn it into the assembly code I need via compiler and then install that on my microcontroller, then that's all I really need. For now, I am not going to be learning hardcore computer science, I just started this.

I want to program, run my C code on some chips and that's it, I don't ask for much more. This is what I am already doing with my arduino I am simply going here because the arduino is a prototyping board which doesn't offer you all the benefits of a custom cirquit board, mainly weight and size wise.
TurtleMeister
#16
Dec15-13, 09:03 AM
TurtleMeister's Avatar
P: 744
Quote Quote by Jarfi View Post
If I can program in C, turn it into the assembly code I need via compiler and then install that on my microcontroller, then that's all I really need.
If I were you I would start out with one of Microchip's PIC microcontrollers. It's very popular and there's a lot of beginner level books written for it. You can download a free IDE from their website. This IDE will allow you to write programs in assembly or C and it will compile and download them to your chip. There are a lot of PIC chips to choose from. I started with the PIC16F84. The only thing that may cost you, other than the chip itself, is the programmer. The programmer connects the chip to your computer and allows you to download your program to the chip. The one I used was the Microchip Picstart Plus. However, I noticed that the price for this has increased since I bought mine more than 10 years ago. There may be cheaper options available (but with limited capabilities).

The things you need to do are: get a beginners book, get a programmer, download the IDE, get a breadboard and associated parts (resistors, capacitors, power supply, etc...), get the part you want to program, and download the data sheet for it from Microchip. Don't be intimidated by the data sheet. You will not need to understand everything on it to write your first program. Your book should explain what you will need to get from the data sheet.

Good luck and have fun.
Jarfi
#17
Dec15-13, 09:29 AM
P: 271
Quote Quote by TurtleMeister View Post
If I were you I would start out with one of Microchip's PIC microcontrollers. It's very popular and there's a lot of beginner level books written for it. You can download a free IDE from their website. This IDE will allow you to write programs in assembly or C and it will compile and download them to your chip. There are a lot of PIC chips to choose from. I started with the PIC16F84. The only thing that may cost you, other than the chip itself, is the programmer. The programmer connects the chip to your computer and allows you to download your program to the chip. The one I used was the Microchip Picstart Plus. However, I noticed that the price for this has increased since I bought mine more than 10 years ago. There may be cheaper options available (but with limited capabilities).

The things you need to do are: get a beginners book, get a programmer, download the IDE, get a breadboard and associated parts (resistors, capacitors, power supply, etc...), get the part you want to program, and download the data sheet for it from Microchip. Don't be intimidated by the data sheet. You will not need to understand everything on it to write your first program. Your book should explain what you will need to get from the data sheet.

Good luck and have fun.

Cost is not an issue, I am looking forward to start and thank you! That was crystal clear.
pantaz
#18
Dec16-13, 06:34 AM
P: 589
I've also been looking into PIC for a new project. Here are some good resources I've found:

Overview for new PIC users -- http://www.electro-tech-online.com/t...pd-0xd1.15035/

PIC Microcontroller, Introduction & Tutorials -- http://www.pyroelectro.com/tutorials...ler/index.html

PICList (User Group) -- http://www.piclist.com/techref/piclist/index.htm


Register to reply

Related Discussions
Language and Programming Language Aero- Engineering Academic Guidance 4
Which programming language should I use? Programming & Computer Science 26
Recommended programming language (and texts) for middle-school beginner programming Programming & Computer Science 9
Microcontroller/fgpa language questions Electrical Engineering 7
Microcontroller programming Engineering, Comp Sci, & Technology Homework 7