Author Topic: Do you guys know where I learn to write c++?  (Read 4234 times)

0 Members and 1 Guest are viewing this topic.

Offline Dylon124

  • Contributor
  • Posts: 10
  • Country: us
Do you guys know where I learn to write c++?
« on: June 30, 2013, 05:11:41 am »
By,c++ I mean what ever the standard microcontroller language. Please correct me if c++ is wrong. I'm completely new to microcontrollers but I really what to program my own atmega328 and maybe any other mcu's. So if you a website or tutorial online about mcu's. PLEASE REPLY!
 

Offline smashedProton

  • Frequent Contributor
  • **
  • Posts: 644
  • Country: us
Re: Do you guys know where I learn to write c++?
« Reply #1 on: June 30, 2013, 05:24:59 am »
Is jumping on the ARDUEEEEENO bandwagon an option?
http://www.garrettbaldwin.com/

Invention, my dear friends, is 93% perspiration, 6% electricity, 4% evaporation, and 2% butterscotch ripple.
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7805
  • Country: us
  • adieu
Re: Do you guys know where I learn to write c++?
« Reply #2 on: June 30, 2013, 05:29:30 am »
The language is C, typically, or C++ for Arduino.

Are you just new to microcontrollers, new to C, or new to programming entirely? That completely changes the answer.
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline netheranthem

  • Newbie
  • Posts: 3
Re: Do you guys know where I learn to write c++?
« Reply #3 on: June 30, 2013, 07:48:16 am »
c++ is probably a poor choice for many applications. (And as a software engineer, I think it's crap for anything really).

If you are curious about the infrastructure and feel like building complex things with very very simple blocks (Basically mathematical operations / memory read-write / jump to label ) go for assembly. I didn't regret learning a bit of it, even if I rarely use it beyond microcontrollers.
Why do I love assembly for microcontrollers so much? Because it's predictable! You assign the memory yourself, and you can know exactly how many cycles your instructions will take, so you can know if that 24MHz will really hold its own and if it can deliver real-time output, for example. You do lose some higher-level constructs, but with most microcontroller applications it doesn't get problematic. If assembly can't solve your problems, maybe a raspberry pi could be worth it.


If you want to get stuff done and follow a recipe that will work the same for all microcontrollers (or almost), go with C.

If you struggle with setup (Which isn't very long, but you gotta learn it once, as they say. I personally think that struggling with the setup is an important part of learning.) for any of those two, then arduino is the way to start.
« Last Edit: June 30, 2013, 07:57:23 am by netheranthem »
 

Offline SharkWrangler

  • Newbie
  • Posts: 3
Re: Do you guys know where I learn to write c++?
« Reply #4 on: June 30, 2013, 09:27:35 am »
When programming 8-bit microcontrollers, the two options you usually have are assembly or C. Each language has its advantages and disadvantages.

Assembly is very low level and involves learning the instructions unique to each processor architecture. This approach gives you control of most aspects of your program and is very deterministic. You'll know how many clock cycles each instruction takes and how the registers are used. If you need a high level of optimization for a small microcontroller, assembly is the way to go. The main disadvantage of using assembly is that it can take much longer to write a program in assembly than in C.

C is a higher level, more portable language that most microcontrollers have compilers for. It's also suitable for programming most applications. The greater abstraction can make writing programs easier and allow you to reuse code between projects. The C compiler you're using can hide many of the implementation details though, so learning about your specific compiler can be as important as learning C itself.

Since C tends to be a bit easier to pick up, I'll assume that you want to use that.

If you don't already know how to write in C.
There are many books and online references that one can use to learn C.

http://aelinik.free.fr/c/ -- Teach Yourself C in 24 Hours in HTML format.

http://www.cprogramming.com/tutorial/c-tutorial.html -- Another tutorial to get one started in C.

Among the numerous printed books one can find online, the classic The C Programming Language, 2nd edition is a small compact book that introduces the main concepts of the language.

If you're already fluent in C.
Once you have gasped C, you just need the platform specific tools for microcontrollers.

Compiler / IDE: AVR and PIC microcontrollers each have free toolchains. Check out AVR Studio 6 for Atmel parts and MPLAB for Microchip parts.

Programmer / Debugger: It is important to get a tool that has both. At some point, your code won't work and a debugger will save you a significant amount of time and sanity. Atmel parts: AVR Dragon. Microchip parts: PICKit3.

Once you have those, you can start prototyping your boards and programming. There are also tutorials floating around the internet based on using specific features of each microcontroller should you get stuck.
 

Offline cthree

  • Frequent Contributor
  • **
  • Posts: 258
  • Country: ca
Re: Do you guys know where I learn to write c++?
« Reply #5 on: June 30, 2013, 12:09:02 pm »
http://arduino.cc

I'd suggest Arduino to get started. Once you outgrow that you'll know what you want to do.
 

Offline Stonent

  • Super Contributor
  • ***
  • Posts: 3824
  • Country: us
Re: Do you guys know where I learn to write c++?
« Reply #6 on: June 30, 2013, 12:34:41 pm »
I took a C class years ago and think Arduino is pretty close even though I know it's based on C++.
The larger the government, the smaller the citizen.
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7805
  • Country: us
  • adieu
Re: Do you guys know where I learn to write c++?
« Reply #7 on: June 30, 2013, 12:38:32 pm »
Yes, the entire Arduino library could be rewritten in C with very few modifications. Once you strip out all the C++ features that are too big to reasonably implement on a microcontroller, you're left with basically "C with namespaces".


OK, OK, that neglects templates and a few other compiler-implemented things that present no overhead once compiled, but Arduino doesn't use them AFAIK.
« Last Edit: June 30, 2013, 01:09:58 pm by c4757p »
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline Stonent

  • Super Contributor
  • ***
  • Posts: 3824
  • Country: us
Re: Do you guys know where I learn to write c++?
« Reply #8 on: July 01, 2013, 08:41:45 am »
I'd recommend watching Sciguy14's videos on Arduino on Youtube. his videos were actually what got me started with Arduino and made me want to buy one, and got me programming up fairly quick.



Also when you're a little more comfortable, start watching videos on AVR GCC or AVR/Atmel studio, but wait until you're writing sketches in Arduino first before you go to Atmel studio because there's a lot more nuts and bolts involved that you don't deal with in Arduino. Basically you want to get to a point where you can write code in Arduino and then translate it to Atmel Studio. And by Atmel Studio I mean AVR C using the AVR GCC compiler. Because that's ultimately what the Atmel Studio is just a Microsoft Visual Studio front end for GCC.

The AVRFreaks forum will be a big help in the transition to Atmel Studio, for the most part the guys there are pretty helpful if they see that you're making an honest attempt at self teaching and not just dumping code in the forum and say fix it for me.

So I would say these should be some paths to look at:

Arduino IDE to Atmel Studio (For Atmel Parts)
MPIDE to MPLAB (For PIC)
Energia to Code Composer Studio (For TI MSP430)

Arduino, MPIDE, and Energia are all basically the Arduino programming environment but for other dev boards. MPIDE works for the Chipkit board with  PIC processor on it, and Energia is for the TI Launchpad (you can buy them for 5 to 10 dollars and are basically like an Arduino)

« Last Edit: July 01, 2013, 09:02:18 am by Stonent »
The larger the government, the smaller the citizen.
 

Offline johnboxall

  • Supporter
  • ****
  • Posts: 514
  • Country: au
    • Tronixlabs Australia
Re: Do you guys know where I learn to write c++?
« Reply #9 on: July 01, 2013, 09:25:19 am »
By,c++ I mean what ever the standard microcontroller language. Please correct me if c++ is wrong. I'm completely new to microcontrollers but I really what to program my own atmega328 and maybe any other mcu's. So if you a website or tutorial online about mcu's. PLEASE REPLY!

Here's an excellent series of video tutorials that will get you started with the ATmega32a:
http://newbiehack.com/MicrocontrollerIntroductionABeginnersGuidetotheAtmelAVRAtmega32.aspx

Offline Stonent

  • Super Contributor
  • ***
  • Posts: 3824
  • Country: us
Re: Do you guys know where I learn to write c++?
« Reply #10 on: July 01, 2013, 09:52:22 am »
By,c++ I mean what ever the standard microcontroller language. Please correct me if c++ is wrong. I'm completely new to microcontrollers but I really what to program my own atmega328 and maybe any other mcu's. So if you a website or tutorial online about mcu's. PLEASE REPLY!

Here's an excellent series of video tutorials that will get you started with the ATmega32a:
http://newbiehack.com/MicrocontrollerIntroductionABeginnersGuidetotheAtmelAVRAtmega32.aspx

Ah yes those are good too, I couldn't think of his name, just remembered him as the Mechanical Pencil guy who's videos seem to speed up really fast when he's writing.
The larger the government, the smaller the citizen.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 6412
  • Country: nz
Re: Do you guys know where I learn to write c++?
« Reply #11 on: July 01, 2013, 01:07:46 pm »
There are full online courses in programming with their lectures all on youtube.

However it's C programming for desktop software and not microcontrollers, but a lot of the content is still relevant.
And you're looking at 20+ 1Hour videos
Greek letter 'Psi' (not Pounds per Square Inch)
 

duskglow

  • Guest
Re: Do you guys know where I learn to write c++?
« Reply #12 on: July 01, 2013, 01:43:29 pm »
Just so you know, Dave thinks assembly programmers are idiots. :)

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf