C/c++ courses

Does anybody know where I can learn c/c++ I've tried Google and can't seem to find anything descent and I'm also looking on the robotic side of things ,sorry if this isn't the right place but I couldn't think of a better place...

Thanks!

hi

search for Sololearn there is a C course there for free.
very usefull to learn the basic and the realy advanced stuff.

but keep in mind arduino does some stuff a little bit differnt.

Oh ok I'll take a look ,thanks

the sololearn course is an abbreviated version of this course:

Bucky's C++ programming tutorials

this one seems pretty good too:

Free Online Programming Course in C for Beginners

also:

Cplusplus.com

Cprogramming.com

learncpp.com

Fredfrizo:
Does anybody know where I can learn c/c++ I've tried Google and can't seem to find anything descent and I'm also looking on the robotic side of things ,sorry if this isn't the right place but I couldn't think of a better place...

Thanks!

Its a good place to look.

Distance learning can be difficult.
I have previously done pascal and others through the OU.

No substitute for university / face to face discussion imho.

This forum provides free tutorial like advice for free.

Thats very difficult to get.

What you learn in the courses and tutorials are the fundamentals you would need to know. Generally when you learn C++ in first year courses and such, the aim is to create applications in a windows based OS. So that is what you are going to see. The programming of micro controllers at it's heart is based in assembler and C.

But robotics in particular can take form in any of the previously mentioned as well as others like ladder logic, etc. It depends on the compiler you are using and the controller you are using.

Soooo, robotics programming in of itself is pretty vague. In addition it usually encompasses the concept of discretization of normally continuous algorithms.

So is it simply programming you want to learn?

I agree, you can't beat taking an actual class if you can find one.

There are LOTS of advantages to taking a class (as boardburner2 says), especially if it's your first programming language. The most important thing I see missing from online tutorials or teach-yourself books, is a "big picture" overview of what programming is all about. They usually just jump-in teaching you the language without really teaching programming.

The Arduino and the examples are actually a good "easy introduction" to programming. But, there's not a lot of explanation so you have to "read between the lines" (and read the comments) to figure-out what's going on.

Although Arduino programming is "easy", if you were studying programming at a university, microcontroller programming (or robotics programming) would be an advanced class, possibly an elective, after you'd been taking programming for a couple of years. An electronic engineering student is more likely to take a microcontroller class than a programming student, and again it would be in their 3rd or 4th year after they have a solid electronics background and at least some programming experience.

So, if you want to take a class in microcontroller or robotics programming, there's a good chance that you'll be expected to know some programming already.

Microcontroller programming is different from Standard C or C++ programming. Standard C/C++ requires a keyboard, text display, and disk storage. And, there are no commands/functions in Standard C/C++ for reading/writing I/O pins or running motors, or anything like that. All of these are additional libraries/functions that are specific to your particular hardware.

Although Standard C++ is missing lots of stuff (there are no graphics or mouse support... all of that is handled by additional libraries) it's still a huge and complex programming language and there's a lot to it! I've never found a book that covers the complete C++ language other than the ISO/ANSI Language reference itself. I believe there are a couple of complete Standard C++ references online.

On the other hand, the basic Arduino language is fairly simple and you can probably read through the entire language reference in less than an hour. The basic language doesn't include any libraries to run servo motors or LCD displays... It's just the foundation. But, I've done a few sound-activated lighting projects involving a several hundred lines of code and I've never gone beyond that basic library.

The first program you learn in any "normal" programming class is "Hello World", which displays "Hello World" on the screen. But, the Arduino doesn't have a screen so instead we have "Blink LED." (We can send a message to your computer screen with the serial monitor, but the idea is to make the simplest program that doesn't rely on any additional hardware and the simplest program that can confirm you can compile and download a program to the Arduino. And of course, "Blink LED" won't run on your PC or Mac.

For learning Standard C++, I second the recommendation of Cprogramming.com. They've got a good beginning tutorial and information about downloading & installing a compiler/IDE and getting started.

I also liked the books Teach Yourself C In 21 Days and Teach Yourself C++ in 21 Days. But, some people hate these books. I had already taken a couple of other classes in other programming languages when I decided to learn C & C++, and these books do jump-in with the language without teaching you what programming is all about.

DVDdoug:
The most important thing I see missing from on line tutorials or teach-yourself books, is a "big picture" overview of what programming is all about. They usually just jump-in teaching you the language without really teaching programming.

That's the bit I think I'm missing.

I did okay with Pascal but with C its different.

Functions and subroutines I understand.

Classes and other terminology I am finding difficult to comprehend.

Its 3 years now and I'm getting reasonably proficient with the arduino but something is definitely missing.

DVDdoug:
I also liked the books Teach Yourself C In 21 Days and Teach Yourself C++ in 21 Days. But, some people hate these books.

I tried those but ended up feeling I had learned nothing. Although i did manage to get my Arduino up and running fairly well.

I learned an awful lot more just by reading threads here though.

I learned C out of the blue book. I think C++ is in the brown book.

Oh, except it's not brown anymore. Have people no respect for tradition?

Boardburner2:
Functions and subroutines I understand.
Classes and other terminology I am finding difficult to comprehend.

If you are a PASCAL programmer, then classes are not your main problem. The main thing you need to get your head around for C/C++ microcontroller programming is C pointer arithmetic.

wfisom:
Ok thanks for the.replies,so really to learn microcontroller programming its not all that easy to learn online and its worth going to uni for it?

Thanks

I think that's largely a career choice.
As a youngster I did something called computer science and had access to a batch punch card fortran system.

After many years I returned and was involved in programming 6800 based micro controller boards using assembly and other low level languages, that was largely learned on the fly.

Like yourself I am looking for the right course, but to "fill in the missing bits".

PaulMurrayCbr:
I learned C out of the blue book. I think C++ is in the brown book.

Oh, except it's not brown anymore. Have people no respect for tradition?

http://www.amazon.com/C-Programming-Language-Bjarne-Stroustrup-ebook/dp/B00DUW4BMS/ref=la_B000AQ349S_1_1

I am using the same but "something is missing".

PaulMurrayCbr:
If you are a PASCAL programmer, then classes are not your main problem. The main thing you need to get your head around for C/C++ microcontroller programming is C pointer arithmetic.

What so coding a microcontroller is a completely different thing?

And also mcus primarily coded in c/c++ or are there others that are popular?

There have been many many languages used

Development systems can support various compilers.

The arduino platform uses c as that was what the developers chose.

If you peruse the Atmega datasheet, you will example code in Assembly and in C.
Example, code for a bootloader:

26.2.5 Simple Assembly Code Example for a Boot Loader

Note that the RWWSB bit will always be read as zero in ATmega 48A/48PA. Nevertheless, it is recommended to

check this bit as shown in the code example, to ensure compatibility with devices supporting Read-While-Write.

;-the routine writes one page of data from RAM to Flash

; the first data location in RAM is pointed to by the Y pointer

; the first data location in Flash is pointed to by the Z-pointer

;-error handling is not included

;-the routine must be placed inside the Boot space

; (at least the Do_spm sub routine). Only code inside NRWW section can

; be read during Self-Programming (Page Erase and Page Write).

;-registers used: r0, r1, temp1 (r16), temp2 (r17), looplo (r24),

; loophi (r25), spmcrval (r20)

; storing and restoring of registers is not included in the routine

; register usage can be optimized at the expense of code size

;-It is assumed that either the interrupt table is moved to the Boot

; loader section or that the interrupts are disabled.

.equ PAGESIZEB = PAGESIZE*2 ;PAGESIZEB is page size in BYTES, not words

.org SMALLBOOTSTART

Write_page:

; Page Erase

ldi spmcrval, (1<<PGERS) | (1<<SPMEN)

rcallDo_spm

; re-enable the RWW section

ldi spmcrval, (1<<RWWSRE) | (1<<SPMEN)

rcallDo_spm

; transfer data from RAM to Flash page buffer

ldi looplo, low(PAGESIZEB) ;init loop variable

ldi loophi, high(PAGESIZEB) ;not required for PAGESIZEB<=256

Wrloop:

ld r0, Y+

ld r1, Y+

ldi spmcrval, (1<<SPMEN)

rcallDo_spm

adiw ZH:ZL, 2

sbiw loophi:looplo, 2 ;use subi for PAGESIZEB<=256

brne Wrloop

; execute Page Write

subi ZL, low(PAGESIZEB) ;restore pointer

sbci ZH, high(PAGESIZEB) ;not required for PAGESIZEB<=256

ldi spmcrval, (1<<PGWRT) | (1<<SPMEN)

rcallDo_spm

; re-enable the RWW section

ldi spmcrval, (1<<RWWSRE) | (1<<SPMEN)

rcallDo_spm

; read back and check, optional

ldi looplo, low(PAGESIZEB) ;init loop variable

ldi loophi, high(PAGESIZEB) ;not required for PAGESIZEB<=256

subi YL, low(PAGESIZEB) ;restore pointer

sbci YH, high(PAGESIZEB)

Rdloop:

lpm r0, Z+

ld r1, Y+

cpse r0, r1

rjmp Error

sbiw loophi:looplo, 1 ;use subi for PAGESIZEB<=256

brne Rdloop

; return to RWW section

; verify that RWW section is safe to read

Return:

in temp1, SPMCSR

sbrs temp1, RWWSB ; If RWWSB is set, the RWW section is not ready yet

ret

; re-enable the RWW section

ldi spmcrval, (1<<RWWSRE) | (1<<SPMEN)

rcallDo_spm

rjmp Return

Do_spm:

; check for previous SPM complete

Wait_spm:

in temp1, SPMCSR

sbrc temp1, SPMEN

rjmp Wait_spm

; input: spmcrval determines SPM action

; disable interrupts if enabled, store status

in temp2, SREG

cli

; check that no EEPROM write access is present

Wait_ee:

sbic EECR, EEPE

rjmp Wait_ee

; SPM timed sequence

out SPMCSR, spmcrval

spm

; restore SREG (to enable interrupts if originally enabled)

out SREG, temp2

ret

wfisom:
What so coding a microcontroller is a completely different thing?

Compiled c is fine for programming so long as you have enough memory to take it.
Libraries are required to support each microcontroller though.

Ok thanks,if anybody knows any online robotics and microcontroller programming courses (doesn't have to be free) please tell me

Thanks!

I took the first iteration of this; it's pretty good, but I think it assumes some prior programming experience (not necessarily in C)

so coding a microcontroller is a completely different thing?

Not completely, but ... substantially. Part of learning to program consists of gaining an understanding of the various libraries you'll need to accomplish "standard" things, and those libraries are different depending on the environment. The famous "hello world" example will look different depending on whether you're putting "hello world" in a Windows Window, an Arduino Serial Monitor, or a command-line terminal.

Ok thanks, what's the difference in programming pic ,avr,and mcu's like the stm32?

what's the difference [different MCUs.]

Everything is different except for the parts that are the same. A good class will teach you about the parts that are the same, and how to recognize and deal with the differences. (A lesser class just teaches you how to do stuff on ONE. And alas, a typical "intro to C/C++" class will just teach you to do SOME limited things on a generic non-specific system.

Which is all both the strength and the weakness of something like Arduino. On the one hand, you get to jump into doing useful things on real hardware without the preceding several YEARS worth of math (so you can do the EE), EE (so you can understand the circuits), and CS classes. On the other hand, some of the basics that you've skipped were important...