1,105,384 Community Members

Hardware programming with C/C++

Member Avatar
avarionist
Junior Poster in Training
70 posts since May 2010
Reputation Points: 1 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

I spent about an hour or so googling but no luck.
I want to program for hardware(which apparently people seem to think is obsolete for some reason) however i can find no tutorials on it period i suppose i could always use Assembly but my knowledge isn't that great. Is there anywhere i can learn( besides college or anything that requires $$$ since im always broke) hardware programming(firmware or manipulation or just even interaction) with the std library. I really don't want to use anything thats not in the standard library.

Member Avatar
mike_2000_17
21st Century Viking
4,081 posts since Jul 2010
Reputation Points: 2,253 [?]
Q&As Helped to Solve: 800 [?]
Skill Endorsements: 73 [?]
Moderator
Featured
Sponsor
 
0
 

Well, as a robotics engineer, I can tell you that hardware programming is far from obsolete. It is in fact probably the most important and time-consuming task when dealing with robots and other similar stuff.

One thing that is important with hardware programming is what you are programming on. If it is a standard PC and your hardware is via USB, RS232, FireWire, etc. than you will have to resort to OS-specific libraries (but mainly standard parts of the operating system libraries) and this is really like regular programming but often these OS APIs are based on C, but very easily wrappable in a C++ environment (the so-called hardware interface layer of your program).

If you're dealing with a embedded PC or microcontroller (which simple robots, mobile phones and other small stuff use), then you have to check if it is powerful enough to run an operating system like FreeRTOS or micro-Linux (or embedded windows if you are of that painful OS flavour). Then there is a whole bunch you need to look at for so-called "cross-compiling" in order to write, compile and test your programs on a PC. There are editors tailored for that, like AVR-Studio and Arduino, most of which allows you to program in C++, but the standard libraries (std namespace) require that you have the appropriate libraries for the system you use. Often micro-controllers offer only C run-time libraries, but if you can run an operating system than it usually comes with all the std libs, but you have to set up the environment for cross-compiling which I'm sure you can find tutorials on (my friend who barely knew programming could set it up after a few weeks of trying).

Another friend of mine even programmed a robotics system running on cheap micro-controller running FreeRTOS and using C# to program it (so if it is possible to use C#, it's definitely possible to use C++).

All in all, when dealing with hardware it's always a lot very low-level stuff so don't expect many ready-made easy solutions. It's always a lot of reading through your micro-controller, embedded-PC, DAQ card, etc. spec-sheets and getting to know what bit-sequences to use, bit-parity, checksums, shift registers, etc. etc.

Member Avatar
avarionist
Junior Poster in Training
70 posts since May 2010
Reputation Points: 1 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

Well, as a robotics engineer, I can tell you that hardware programming is far from obsolete. It is in fact probably the most important and time-consuming task when dealing with robots and other similar stuff.

One thing that is important with hardware programming is what you are programming on. If it is a standard PC and your hardware is via USB, RS232, FireWire, etc. than you will have to resort to OS-specific libraries (but mainly standard parts of the operating system libraries) and this is really like regular programming but often these OS APIs are based on C, but very easily wrappable in a C++ environment (the so-called hardware interface layer of your program).

If you're dealing with a embedded PC or microcontroller (which simple robots, mobile phones and other small stuff use), then you have to check if it is powerful enough to run an operating system like FreeRTOS or micro-Linux (or embedded windows if you are of that painful OS flavour). Then there is a whole bunch you need to look at for so-called "cross-compiling" in order to write, compile and test your programs on a PC. There are editors tailored for that, like AVR-Studio and Arduino, most of which allows you to program in C++, but the standard libraries (std namespace) require that you have the appropriate libraries for the system you use. Often micro-controllers offer only C run-time libraries, but if you can run an operating system than it usually comes with all the std libs, but you have to set up the environment for cross-compiling which I'm sure you can find tutorials on (my friend who barely knew programming could set it up after a few weeks of trying).

Another friend of mine even programmed a robotics system running on cheap micro-controller running FreeRTOS and using C# to program it (so if it is possible to use C#, it's definitely possible to use C++).

All in all, when dealing with hardware it's always a lot very low-level stuff so don't expect many ready-made easy solutions. It's always a lot of reading through your micro-controller, embedded-PC, DAQ card, etc. spec-sheets and getting to know what bit-sequences to use, bit-parity, checksums, shift registers, etc. etc.

Thanks :D
yeah i know its far from obsolete game,phones,tv,stereos etc. have to have some interaction with the hardware lol. I know its not easy thats why i want to and i'm perfectly ok with C. So basically instead of looking for tutorials for hardware programming just look for the devices spec sheets ? like if i wanted to interact with a rj45 port(ethernet card) i would look that up? that makes sense. ive got a bunch of old hardware that doesnt really matter and was wanting to repurpose them(well tinker with user created firmware) hardware programming really interests me. i'll probably learn more of ASM then since its about as low as you can get with out writing machine code(which there are 0 tutorials guess since it would be redundant with all the languages there are to choose from).

Thanks though that helped a bunch :D

vivek27
Newbie Poster
1 post since Jul 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
Unverified Member
 
0
 

hey which books should I prefer for hardware connectivity

Member Avatar
rubberman
Senior Poster
3,997 posts since Mar 2010
Reputation Points: 513 [?]
Q&As Helped to Solve: 501 [?]
Skill Endorsements: 87 [?]
 
0
 

Each bit of hardware cruft has its own peculiarities - so there is no "one size fits all" book for this stuff. The hardware manufacturer's data sheets and programming guidelines will help. I use embedded ARM processor boards for a lot of projects, and the ones I use support Linux for a board-level OS - mostly Debian distributions. They also provide host-side gnu/gcc compiler tool chains so I can build a new board kernel on my workstation, and then finish by compiling applications on the board itself.

Most direct control of the board's capabilities are via io-in and io-out functions - twiddling low-level i/o ports on the board. You may also have to do some dma programming as well, depending upon the functions required.

Also, if you are getting into embedded hardware, learn about JTAG functionality and tools. :-)

Member Avatar
DeanMSands3
Posting Whiz
358 posts since Jan 2012
Reputation Points: 57 [?]
Q&As Helped to Solve: 49 [?]
Skill Endorsements: 2 [?]
 
0
 

If you really want to get into hardware but have no foundation to start from, I'd suggest getting an Arduino or TI-MSP430. Then buy a bag of LEDs and some resistors and start blinking lights. It's fun. You'll like it.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article