Next step C coding for electrical engineer Stuff

  • #1

Main Question or Discussion Point

hi,
I'm an electrical engineering student and have studied c programming. Everything I was doing however was just to familiarize myself with c and the language, therefore just executable programs that could create a database, or make an array or data to programs that aided me like a resistor color band program or math performing applications. you know, new guy stuff.

I know the next step in my education is learning microcontrollers and eventually a pic controller or similar based platform. I want to get a head start on programming for hardware. I've been playing with arduino for a few year and have coded small projects (not easily at all) and I can understand most code I've used for larger scale projects. However I know I could not have processed the code myself.

Where can I find specific information/tutorials on coding for hardware?

I know obviously practicing is the way to learn but I just don't know where to look to get the basics.

in elec engineering is c++ used ? Would a better idea be to start learning c++?

any books, webpages, videos. Etc much appreciated...

Thanks
 

Answers and Replies

  • #2
87
138
...Where can I find specific information/tutorials on coding for hardware?...
I would definitely start to learn about programmable logic devices if I were you.
You can read any books about micro-controllers you want but be sure that you need only to extract the concepts not really the particular know-hows or the libraries written to target specific platform the books offer. Manufacturing industrial robots in known companies requires more disciplines and constraints. Either C or C++ or any others e.g python, scala etc is fine to get you a heads up on building things you prefer. Programming languages to me are only useful means either to control the programmed or already configured devices or to evaluate the models of the automated systems under development.
This link offers something about your likes also.
 
  • #3
Svein
Science Advisor
Insights Author
2,025
649
in elec engineering is c++ used ? Would a better idea be to start learning c++?
No. C++ assumes a (huge) library is present. Inside a microcontroller you do not have anything (except if the manufacturer provides something).

Remember: You have no screen and no keyboard. You might possibly have a serial interface you can use. Your best bet is to familiarize yourself with the JTAG interface. If it is present, you will be able to load the code and debug it using a PC.
 
  • #4
402
120
It's amazing how much the libraries increase the size of the program.
In second year we had to write a program to run on an ATMega 64.
My program was taking up ~12% of the available EEPROM. When I needed a few math functions and included math.h it shot up to 90%.

Look into getting a development board from some chip, lots of new stuff to learn around interupts, and timers, and controlling I/O pins and so forth
 
  • #5
Okay, I have taken a digital logic class and we used altera quartus and the cyclone FPGA. Is there any cheap ones you recommend? any specific programs? We did mostly block diagram style programs ending with the architecture of a basic computer/cpu. I've heard libraries are a killer and that its tough because you can't just steal the bit of the library you are using.

In my schooling we made a robot project using an atmega328 and next year we will be programming that to sensors and other functions. I'm just trying to get a bit of a head start.
Thanks for the replies guys!
 
  • #6
I would definitely start to learn about programmable logic devices if I were you.
You can read any books about micro-controllers you want but be sure that you need only to extract the concepts not really the particular know-hows or the libraries written to target specific platform the books offer. Manufacturing industrial robots in known companies requires more disciplines and constraints. Either C or C++ or any others e.g python, scala etc is fine to get you a heads up on building things you prefer. Programming languages to me are only useful means either to control the programmed or already configured devices or to evaluate the models of the automated systems under development.
This link offers something about your likes also.

Thank you for the link! Im going to start reading ASAP.
 
  • #7
chiro
Science Advisor
4,790
131
Hey Weightofananvil.

I'd suggest you getting the programming specification for the platform you are using and look at things like hardware ports, interrupts (as mentioned by a poster above), memory locations for certain functions and the instruction set it uses.

Different platforms do things differently and if you are using the embedded, logic controller stuff, then you will probably end up having to do some assembly coding.

As far as procedural languages go, C is the closest to this sort of thing next to using mnemonic assembly code. There are versions of C that are designed for embedded devices and you should look those up.
 
  • #8
FactChecker
Science Advisor
Gold Member
5,381
1,950
Embedded Linux is becoming more important as the computer on a chip systems like Raspberry Pi and C.H.I.P. evolve. A good overview of the concepts is contained in "Linux for Embedded and Real-Time Applications" by Doug Abbott. I also highly recommend the Raspberry Pi kit with one of the many tutorials. One of the problems with C++ OOP for small embedded programs is the way Object Oriented code includes large libraries ("You wanted a banana but you got a gorilla holding a banana").
 
Last edited:
  • #9
1,516
617
It's amazing how much the libraries increase the size of the program.
In second year we had to write a program to run on an ATMega 64.
My program was taking up ~12% of the available EEPROM. When I needed a few math functions and included math.h it shot up to 90%.

Look into getting a development board from some chip, lots of new stuff to learn around interupts, and timers, and controlling I/O pins and so forth
Tell the compiler to remove the dead code. Add the -fdce (GCC) flag to your compile line, it's not on by default.
 
  • #10
rbelli1
Gold Member
920
339
you do not have anything (except if the manufacturer provides something).
Or the tool provider or some other 3rd or nth party provides it. C++ is perfectly viable on many modern-ish cpus. Nothing in an intel cpu or general purpose desktop system provides anything C++.

It's amazing how much the libraries increase the size of the program.
I use several processors that don't have any multiply at all. Floating point takes almost 10k just to do 2.0 + 2.0. Most compilers will eliminate unused parts of the libraries however sprint and varients uses lots of floating point so if your CPU is not FP native then you will take a hit.

BoB
 
  • #11
rbelli1
Gold Member
920
339
"You wanted a banana but you got a gorilla holding a banana"
You can get it down to a monkey of you are careful of the features you use.

BoB
 
  • #12
FactChecker
Science Advisor
Gold Member
5,381
1,950
You can get it down to a monkey of you are careful of the features you use.

BoB
I agree if you have control of it and can keep it simple. I highly recommend keeping things as simple as possible. It seems like everyone who writes a class thinks he has to develop a whole new language, overload every operator, and turn it into a MATLAB competitor.
 

Related Threads on Next step C coding for electrical engineer Stuff

  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
5
Views
2K
  • Last Post
Replies
3
Views
2K
Replies
20
Views
2K
  • Last Post
Replies
3
Views
1K
  • Last Post
Replies
2
Views
858
  • Last Post
Replies
11
Views
3K
  • Last Post
Replies
7
Views
5K
  • Last Post
Replies
1
Views
12K
  • Last Post
Replies
16
Views
10K
Top