<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Akshay's hardware and embedded posts</title>
    <link>https://ediblemonad.dev/hardware</link>
    
    <item>
  <guid>/hardware/2026-04-29-fpga-dreams.html</guid>
  <title># FPGA dreams</title>
  <link>https://ediblemonad.dev/hardware/2026-04-29-fpga-dreams.html</link>
  <comments>https://ediblemonad.dev/hardware/2026-04-29-fpga-dreams.html</comments>
  <pubDate>2026-04-29</pubDate>
  <description>
    <![CDATA[<h2 id="fpga-dreams">FPGA dreams</h2>
<p>I want to mess around with FPGAs at some point. It looks really
interesting but I need to grow a few more IQ points before I can play
with that new toy. At this point I know nothing about them or hardware
description languages but can't wait to meet future me who already knows
some of that stuff. If that's you reading this for some reason, is GTA 6
out yet?</p>
]]>
  </description>
</item>
<item>
  <guid>/hardware/2026-04-12-v-usb-is-kinda-neat.html</guid>
  <title># V-USB is kinda neat</title>
  <link>https://ediblemonad.dev/hardware/2026-04-12-v-usb-is-kinda-neat.html</link>
  <comments>https://ediblemonad.dev/hardware/2026-04-12-v-usb-is-kinda-neat.html</comments>
  <pubDate>2026-04-12</pubDate>
  <description>
    <![CDATA[<h2 id="v-usb-is-kinda-neat">V-USB is kinda neat</h2>
<p>I only ran into <a href="https://github.com/obdev/v-usb">v-usb</a>
while going through the <a
href="https://docs.qmk.fm/compatible_microcontrollers">qmk docs</a>
where it mentions that mcus that don't have native usb will use v-usb
instead.</p>
<p>Curiosity killed the akshay. Couldn't resist so started thinking of
what I could use it for. Right now I'm in my 8-bit avr arc so seemed
like the perfect thing to mess around with. I thought it would be fun to
make a simple rgb light connected via USB that changes color via
commands over serial. Seems simple enough, what could go wrong? Plenty
as it turns out.</p>
<p>First challenge: realized the internal clock of attiny84a and
attiny4313 (the only 8-bit avr mcus I have) is 8MHz and v-usb only
supports 12/15/16/18/20 MHz clocks. No biggie, heres a 16MHz crystal
oscillator.</p>
<p>Second challenge: we need 3.3V for the usb data lines but the LEDs
need 5V. I can either drive the attiny4313 with 3.3V and maybe add a
mosfet for the LEDs or use 5V for the mcu and LED but shift D+/D- to
3.3V level. Went with the latter using a zener diode to maintain the
3.3V level on data lines since that seemed simpler.</p>
<p>Third challenge: after writing the fuse bits to use the external
crystal oscillator, couldn't program it again. The crystal is connected
with load caps and the program (an rgb version of blink) seems to run
fine with or without the crystal. Makes no sense. Saw somewhere that you
can set up a high voltage programmer (12v) to get the fuse bits to
reset. So will try that next.</p>
<p>To be continued...</p>
]]>
  </description>
</item>
<item>
  <guid>/hardware/2026-03-08-analog-of-digital.html</guid>
  <title># The analog of the digital</title>
  <link>https://ediblemonad.dev/hardware/2026-03-08-analog-of-digital.html</link>
  <comments>https://ediblemonad.dev/hardware/2026-03-08-analog-of-digital.html</comments>
  <pubDate>2026-03-08</pubDate>
  <description>
    <![CDATA[<h2 id="the-analog-of-the-digital">The analog of the digital</h2>
<p>In digital electronics something that always catches me off guard is
the analog suprise. A random part of your schematic that depends on a
very specific analog behavior. I ran into one of those while working on
<a href="https://github.com/makedaft/daft-watch">a clock using attiny84a
microcontroller IC</a>. That project was my re-creation of <a
href="https://ingep.net/breadboardwatch/">breadboard watch</a> which
taught me a very simple but cool trick.</p>
<p>An rtc based on timer interrupts on a microcontroller, displayed on a
4 digit, 7 segment display seems simple enough but theres a sneaky
problem with attiny84a. The total number of pins in the IC is 14. 1 for
Vcc, 1 for GND, 1 for reset. Since it's battery powered, to avoid
drawing more power than needed, we also need to use an external 32KHz
crystal oscillator which then takes up the 2 XTAL pins. This leaves us
with 9 pins to drive the display. But for 4 7-segment displays, you need
1 shared pin for each segments and 1 control pin for each digit (with
that we can draw 1 digit at a time). That comes out to 11 (7 + 4). But
we only have 9 pins left so how do we drive the display?</p>
<p>In avr, for a given pin, you can set the data direction (DDR*
register) and the port value (PORT* register). When DDR bit is 1, the
data direction is output so the respective PORT bit decides whether the
output is high or low. But then if the DDR bit is 0, the value of PORT
instead of being used for the output of that pin, it engages an internal
pull-up resistor if the value is 1, and leaves it floating if the value
is 0.</p>
<p>This is the magic that makes feel things in the crotch. The solution
used here is to use diodes to create a kind-of OR circuit by deriving
segment states based on the state of the control pins. Here's the <a
href="https://raw.githubusercontent.com/makedaft/daft-watch/refs/heads/main/watch.svg">full
schematic for reference</a>.</p>
<blockquote>
<p>Note: in my case it's a common anode display so segment pin low and
control pin high means that segment on that digit is on.</p>
</blockquote>
<p>In the schematic, with
<code>DDRA = (1 &lt;&lt; PA6) | (1 &lt;&lt; PA7)</code> (PA6 and PA7
both output),</p>
<ul>
<li>When PA6 is high, and PA7 is low, it enables digit 3 and the F
segment.</li>
<li>When PA6 is low, and PA7 is high, it enables digit 4 and the F
segment.</li>
</ul>
<p>If we have <code>DDRA = 0</code> (PA6,PA7 both input),</p>
<ul>
<li>When <code>PORTA = 0</code> (PA6,PA7 without internal pullup), being
floating, there is no current flowing which means both digits are off
and the F segment is off. This state can be used when drawing the other
2 digits.</li>
</ul>
<p>So far we can turn off both digits or have either one on but with F
segment enabled. But how do we disable the F segment?</p>
<p>If we have <code>DDRA = (1 &lt;&lt; PA6)</code> (PA6 output, PA7
input),</p>
<ul>
<li>When <code>PORTA = (1 &lt;&lt; PA6)</code> (PA6 high, PA7 floating),
digit 3 is on but the F segment is off as the current has nowhere to
flow through the diodes.</li>
</ul>
<p>Applying the inverse of that, we can achieve the last state we need
to draw anything on each of the 7 segment displays. With this we now
have 2 pins doing the work for 3. Adding states in our digital logic
that don't exist in pure boolean logic. Doesn't that feel
satisfying?</p>
]]>
  </description>
</item>

  </channel>
</rss>
