
Learning hardware programming as a software engineer - diffuse_l
https://blog.athrunen.dev/learning-hardware-programming-as-a-software-engineer/
======
jacquesm
That's a good article for the simple reason that it is written by someone who
still had enough 'outsider perspective' that it can help guide other people
new to the material in ways that old hands never could. It is impossible for
me to tell a person new to this material what the pitfalls will be because
most of what they will be struggling with is obvious to me and it would never
even occur to me to explain it.

The site is a bit slow to load but if you are new to working with Arduino's
and other small boards like that and want to play around with them it is worth
the wait.

Title nit-pick: I'd have used 'low level programming' rather than 'hardware
programming', programming hardware has a different meaning.

~~~
theunamedguy
+1 for the nit-pick. Hardware programming make me think of FPGA design and
Verilog, etc. I'd call this 'embedded programming'.

------
mlazos
I actually thought this was about learning verilog or another hdl. I was a
little disappointed, maybe I should write a blog about my experience learning
an hdl as a software engineer.

Nonetheless them learning embedded systems programming is still an interesting
read! Especially when coming from a language like C#

~~~
Athrunen
Thank you, now I want to learn about hdl. ^^

Languagevise coming from C# and learning c or c++ for low-level programming
was quite smooth, also coming from python was the hard part, that was a lot of
comforts I had to give up.

But as I am also learning some micropython, I might write about porting stuff
to it in the future.

~~~
justinclift
Since you mention MicroPython, TinyGo (eg Go instead of Python) might be
interesting as well: :)

[https://tinygo.org](https://tinygo.org)

[https://github.com/tinygo-org/tinygo](https://github.com/tinygo-org/tinygo)

------
webmobdev
Yes, it is a different experience because with software programming we are
letting system programs like the OS handle the hardware and we don't
manipulate it directly. And computer hardware is standardised.

Where as when doing hardware programming, you have to necessarily understand
the individual hardware to program and control it - there is often no abstract
software lawyer in between to make this task easier for us. And the hardwares
are quite diverse.

------
spectramax
For any high level software engineer, looking to get into embedded
development: A lot of Arduino, ESP tutorials do not teach you fundamentals. I
recommend spending sometime (if not to code along) watching this course:
[https://www.youtube.com/playlist?list=PLPW8O6W-1chwyTzI3BHwB...](https://www.youtube.com/playlist?list=PLPW8O6W-1chwyTzI3BHwBLbGQoPFxPAPM)

~~~
danieldk
_For any high level software engineer, looking to get into embedded
development: A lot of Arduino, ESP tutorials do not teach you fundamentals._

Even books. I read ~two Arduino books that would write something along the
lines of "we need a pull-up resistor to keep the pin from floating", without
ever explaining what floating pins, pull-up, and pull-down resistors are. The
concepts are not all that hard, except that they are often not properly
defined or explained.

------
StavrosK
I can wholeheartedly recommend designing your own PCBs as well. It's a lot of
fun, and routing the tracks on the PCB is surprisingly calming.

~~~
Athrunen
I am currently designing PCBs for my next post using EasyEDA, anything to pay
attention to?

I'm especially concerned about the track width and clearance and stuff. For
12V and I think a max of 8A I calculated 2mm width, 0.6mm clearance, 1.5mm via
diameter and 0.75mm via drill diameter.

~~~
Gibbon1
You can use this for calculating trace widths. I think 2mm is too narrow with
2oz copper and definitely too narrow with 1oz.

[https://www.4pcb.com/trace-width-calculator.html](https://www.4pcb.com/trace-
width-calculator.html)

Most PCB houses can handle 8mil (0.2mm) traces and clearance with no problems.

Best thing way to handle vias in high current designs is to avoid them. Run
the trace from point A to point B on the same layer. Second way is to use
planes for distribution. Other things you can do. Make sure there isn't a
thermal relief. Use multiple/arrays of vias.

------
throwaway55554
This is why I went with a Computer Engineering degree instead of only a CS
degree. I love software development, but I wanted to stay as close to the
metal as possible.

------
ChrisMarshallNY
Can't view the Web site (500 Bad gateway).

In any case, I sort of went the other way. I started in hardware, and
gravitated towards software.

I think that each discipline could learn from the other, as most hardware,
these days, relies on software as a critical part of its operation, and a lot
of software is written as if the hardware on which it depends, doesn't exist.

I look forward to reading it, once the site is back up.

Happy Christmas!

~~~
ChrisMarshallNY
Just got around to reading it.

Good stuff. Welcome to my world, although I seldom work on any kind of
firmware, anymore. I'm mostly about driver-level stuff, and I try to leverage
platform transport, as much as possible.

I have blown up $40,000 (in 1987 dollars) devices with software errors.

FUN!

~~~
eyegor
My favorite part of hardware development is that you learn the true meaning of
"bricking". People often use the term when something is recoverable, having
never felt the pain of 1-2 engineer years worth of assets turning into
paperweights in an instant.

How on earth did you blow something up from software? I'm guessing you were
touching power delivery from software for some reason?

~~~
spc476
Way back in the early 80s, if you programmed in the wrong settings to a video
chip, you could drive a monitor out of spec and severely damage it (I seem to
recall several computers of this era were susceptible to this).

------
peter_d_sherman
Excerpts:

"The most basic pins are digital pins, they can only either be on or off. You
would, for example, use them to check if a button is pressed. Or if you use
them as output, turning a led on or off."

[intermediate content deleted for brevity...]

"And while those pins cannot output a true analog signal, they can use a
technique called PWM to approximate one by only switching the signal on for
some time."

Fascinating! Knew about digital pins before this, and PWM generally speaking
(with respect to PC fans, power supplies, etc.) -- and yet, I did not
proverbially put "2 + 2 together" in my head! (For some inconceivable reason I
always conceptualized PWM as analog/multiple waves per unit time, in
nature...) Yup, makes a ton of sense!

Anyway, thanks for the great article!

------
ddingus
Right now is a great time to learn about lower level, "on the metal" type
programming! Has been for a while now.

People, like Ben Eater, are making great kits.

Components are not so expensive. You can (and will) fail. Get more, get gear,
try again.

One can get good gear, scope, meter, solder station, etc... at good prices.
Used pro gear is a good option too.

Making things, signal generator, logic analyzer, are also fun projects.

And there are many programming options from assembly to Python showing up.

I love this stuff and often couple it with retro computing. The speeds are low
enough to make most things possible for fairly new comers.

Jump in. It is fun!

Great post OP.

------
sbierwagen
[https://blog.athrunen.dev/content/images/2019/10/ESP32-Pinou...](https://blog.athrunen.dev/content/images/2019/10/ESP32-Pinout-1.png)

Weird, the breakout pin between IO21 and IO19 is silkscreened GND, but the
label says NC, not connected. The dev board datasheet[0] says that pin is not
connected, which would be a fun trap for someone who tried to use that pin as
a ground, but a different schematic on the site says it's tied to module
ground. They don't seem to have a PDF of the actual PCB anywhere I can find.

0:
[https://www.espressif.com/sites/default/files/documentation/...](https://www.espressif.com/sites/default/files/documentation/esp32-wroom-32_datasheet_en.pdf)

1: [https://dl.espressif.com/dl/schematics/ESP32-Core-
Board-V2_s...](https://dl.espressif.com/dl/schematics/ESP32-Core-
Board-V2_sch.pdf)

------
TrackerFF
Also, might wanna learn some basic electronics.

With very modular devices, it's easy to avoid that - since you're basically
building stuff like as with lego bricks, and things are abstracted form you -
but if you need / want to build your own sensors, or customized setups, you'll
need to know a thing or two about electronics / circuit analysis and design.

~~~
nickreese
I’ve tried diving into this in my spare time. Where do you start if you have a
web dev background?

~~~
humansvsrobots
Learning Arduino might be a good starting point, since they are easy and
popular. You'll probably need to learn C, since Arduinos (or the controllers
on the Arduino boards) are programmed in C or assembly.

There is a cost for equipment and parts when working with hardware.

Creating effects in the physical world with your code feels awesome. Learning
and building physical tech is just awesome all around.

------
anoncow
The website is down
[https://web.archive.org/web/20191225131030/https://blog.athr...](https://web.archive.org/web/20191225131030/https://blog.athrunen.dev/learning-
hardware-programming-as-a-software-engineer/)

------
keithnz
funny thing is, when "software engineer" as a term came along, it was a bit of
a fuzzy term, but here in NZ a lot of people took it as someone who had a
engineering background and understood something of
electronics/mechanical/chemical/civil engineering, a number of courses made SE
have a common first year with the other engineering disciplines. This was more
my background I did software / electronic engineering and went into embedded
systems for electronic/mechanical/software type systems. Though these days I
do more "full stack" systems development but still highly involved in embedded
development.

But of course, software engineer has no particular definition and lots of
people use the term to describe themselves, even if they have no real
engineering background.

------
mx91
My advice is to read the board and MCU datasheet. Check MCU's peripherals, and
how they can be used in your application. Some MCU's have a PPI (Programmable
Peripheral Interconnect) it is clever to use it, as peripherals can operate
independently together from the processor, especially combined with direct
memory access. Learn bitwise operations as you'll need it to configure the
peripheral's registers. Use a logic analyzer to confirm the bitstream to
pinpoint errors.

Lately I started experimenting with radios. It is difficult. Let me know if
someone has a good guide they read.

------
sprior
I don't feel like creating a userid on his website just to tell him this, but
one thing he seems to have missed that may have caused some of his problems is
that the ESP32 I/O pins are 3V and NOT 5V tolerant. Elsewhere in the article
he seems to assume 5V levels (when he's talking about using PWM to output 2.5V
from a 5V pin). With an ESP32 or ESP8266 when you need to interface with 5V
devices you should use a level shifter.

~~~
Athrunen
Thanks for that information, but I learned that the esp32 is not 5V tolerant
the hard way. ^^

Will fix the bit about the PWM in a second

~~~
sprior
That might be something good to mention in the article as something to watch
out for. You mention checking the specs, but not that kind of issue with
specs.

------
daveFNbuck
When I wanted to learn hardware programming for a similar small project, I
took on online course [1]. It took a few months, but it gave a pretty solid
framework to start from.

[1] [https://www.edx.org/course/embedded-systems-shape-the-
world-...](https://www.edx.org/course/embedded-systems-shape-the-world-
microcontroller-i)

------
Animats
All those multi-function pins! That implies a boot-time setup where you tell
the system on a chip what each pin is supposed to be doing. Lots of bit field
constants to construct. Often more trouble than hooking up to the pins.

------
troysk
This is such a gem of a post. I learned the hard way too and I wish this post
was posted 5 years back! :) All the best to the author for his future
projects.

