Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Next step C coding for electrical engineer Stuff

  1. May 12, 2016 #1
    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
     
  2. jcsd
  3. May 12, 2016 #2
    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.
     
  4. May 12, 2016 #3

    Svein

    User Avatar
    Science Advisor

    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.
     
  5. May 12, 2016 #4
    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
     
  6. May 12, 2016 #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!
     
  7. May 12, 2016 #6

    Thank you for the link! Im going to start reading ASAP.
     
  8. May 13, 2016 #7

    chiro

    User Avatar
    Science Advisor

    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.
     
  9. May 15, 2016 #8

    FactChecker

    User Avatar
    Science Advisor
    Gold Member

    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: May 15, 2016
  10. May 16, 2016 #9
    Tell the compiler to remove the dead code. Add the -fdce (GCC) flag to your compile line, it's not on by default.
     
  11. May 17, 2016 #10

    rbelli1

    User Avatar
    Gold Member

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

    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
     
  12. May 17, 2016 #11

    rbelli1

    User Avatar
    Gold Member

    You can get it down to a monkey of you are careful of the features you use.

    BoB
     
  13. May 17, 2016 #12

    FactChecker

    User Avatar
    Science Advisor
    Gold Member

    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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Next step C coding for electrical engineer Stuff
  1. Next step (Replies: 1)

  2. Critique my C++ code (Replies: 11)

Loading...