<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>Controlling a Printer With a Soundcard (I2S) on a Raspberry or orange Pi</title>
        <description> This is not a question, this is me bragging I did it! A working proof of concept! :-D Below is a video of it running 3 steppers with acceleration profiles and independent speed.

[www.youtube.com]

A little while ago I realized an I2S digital sound output looks a lot like a SPI output, and SPI outputs can drive shift registers. back then I was focused on the ESP8266, so I build a small 32 bit shifter board based on 4x 74H595 and wrote a realtime bitbanger demonstrating it as a GPIO expansion (see [forums.reprap.org]). Then, a couple of days ago I found a few post of people using I2S DACs to improve sound quality on single-board-computers, more specifically Raspberry Pi and Orange Pi. Then it hit me:

I2S is a realtime digital output present on most SBCs, and we may use may shifter board to control a printer with it!

I just happened to have an idle Orange Pi One at hand and a few days to spare, so decided to try it out.

Code is here: [github.com]
Shifter PCB was previously released here: [github.com]

What was done:
- Replaced /boot/bin/orangepione.bin with the included fex file, so as to enable and configure I2S output.
- A C++ program renders motion for 4 steppers (only 3 connected on the video).
- The C++ program outputs 32 bit words, a bitmask for step/direction of several steppers.
- alsa player (aplay) feeds the 32bit words directly to the &quot;sound card&quot; (not really a card, part of the SOC).
- The &quot;soundcard&quot; outputs raw I2S, and feeds a 32bit shift register. Sample rate is 192k words/s.
- Just 5 wires from OrangePi to the shfter: GND, 3.3V, I2S-Data, I2S-BitClock, I2S-WordClock.
- Shifter outputs drive the stepper drivers. Bits 0-3 are STEP, bits 16-20 are DIR.
- I let out a tear of happiness. :&#039;-D

What could we do with this:
- Discard the arduino-like controllers used on pretty much every single motion control board out there.
- Remove distinction of software and firmware, as they would run on the same processor. (Eases development).
- Make printer software mostly hardware independent, as long as there is I2S and alsa on the backend.
- Modify reprap-firmware to be more OS-friendly, and run as a backend on the *Pi.
- Have a quad-core computer running accurate motion control for the crazyest of mechanics, at high sample rates.
  - Theoretical limit of 46 steppers (2 channels, 24 bit per channel, using 2 bits for a secondary shifter for DIR bits).
- Have a vision feedback system for calibration? OpenCV?
- Have a full-blown linux system control your printer:
  - python, nodejs, octoprint, and whatnot providing web/touch interfaces.
  - Fast uploads, as there is no serial link anywhere.
  - A really nice interface to the printer: OpenGL and HDMI displays.
- Real easy updates, apt-get style.

Required for a working printer, but not tested:
- I2S input via alsa-record could allow parallel-in serial-out shift registers to read 32 bit data.
  - Temperature reading via RC charge time?
  - Endstops, and a few buttons.</description>
        <link>https://reprap.org/forum/read.php?2,685993,685993#msg-685993</link>
        <lastBuildDate>Mon, 11 May 2026 16:42:21 -0400</lastBuildDate>
        <generator>Phorum 5.2.23</generator>
        <item>
            <guid>https://reprap.org/forum/read.php?2,685993,860135#msg-860135</guid>
            <title>Re: Controlling a Printer With a Soundcard (I2S) on a Raspberry or orange Pi</title>
            <link>https://reprap.org/forum/read.php?2,685993,860135#msg-860135</link>
            <description><![CDATA[ Hello,<br />
<br />
What happened to this project, any progress ?<br />
<br />
Seems to me that the way to go with this is to bring up LinuCNC/MachineKit on a cheap arm based board like this project did [<a href="https://github.com/orange-cnc" target="_blank"  rel="nofollow">github.com</a>] , then write a hal driver using the I2S out and input of the board for linuxcnc.<br />
<br />
Then you get a full, extremely flexible CNC controller. (I admit I am biased to LinuxCNC which I use with my CNC)]]></description>
            <dc:creator>bschwand</dc:creator>
            <category>Developers</category>
            <pubDate>Mon, 30 Sep 2019 15:46:19 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?2,685993,687022#msg-687022</guid>
            <title>Re: Controlling a Printer With a Soundcard (I2S) on a Raspberry or orange Pi</title>
            <link>https://reprap.org/forum/read.php?2,685993,687022#msg-687022</link>
            <description><![CDATA[ My 165 set is still somewhere in China, so I cannot help for now :(<br />
But I am looking forward to it!<br />
Excellent job, @lhartmann!]]></description>
            <dc:creator>rklauco</dc:creator>
            <category>Developers</category>
            <pubDate>Fri, 15 Jul 2016 04:55:31 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?2,685993,686970#msg-686970</guid>
            <title>Re: Controlling a Printer With a Soundcard (I2S) on a Raspberry or orange Pi</title>
            <link>https://reprap.org/forum/read.php?2,685993,686970#msg-686970</link>
            <description><![CDATA[ Just tested I2S loopback to see if I2S input is possible: Good news, IT IS! (probably) (:P)<br />
<br />
For now I just tested wiring I2S data output pin back to I2S data input. I also tried pulling the wire and it stopped working, so this is not an internal loopback. Since I2S-IN and I2S-OUT share the same clocks it will probably work fine with a 74HC165 shifter. I'll try making a pcb for these soon.<br />
<br />
For the test I used 2 processes: reader and writer. See [<a href="https://github.com/lhartmann/orangepi-i2s-steppers/tree/master/loopback" target="_blank"  rel="nofollow">github.com</a>]<br />
- The writer.cpp just writes a tag (0x11223344) then 127 words (32 bit) of a continuous counter.<br />
- The reader.cpp looks for the tag, then checks if the following 127 words are a correct counting.<br />
<br />
Issues:<br />
- I could not yet get these working on the same process (loopback.cpp), loosing data. A thread or proper use asynchronous IO with select(...) should probably do the trick.]]></description>
            <dc:creator>lhartmann</dc:creator>
            <category>Developers</category>
            <pubDate>Thu, 14 Jul 2016 23:35:38 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?2,685993,686368#msg-686368</guid>
            <title>Re: Controlling a Printer With a Soundcard (I2S) on a Raspberry or orange Pi</title>
            <link>https://reprap.org/forum/read.php?2,685993,686368#msg-686368</link>
            <description><![CDATA[ Yup ADS1115 seems like a really good choice. 16 bit resolution is almost overkill. Ordered one just in case, but china packages take 20-180 days to deliver here... <br />
<br />
Another option would be to use <a href="http://s.aliexpress.com/Y3EZnemm" target="_blank"  rel="nofollow">555 analog timers</a> in astable configuration, but with the NTC as one of the resistors. If I2S inputs work as I hope they will then I may be able to find out the NTC resistance by reading the timer period.<br />
<br />
I may have some other I2C or SPI ADCs lying around too... Will give it a try once I get some spare time again. I'm pretty sure those are expensive models, though...]]></description>
            <dc:creator>lhartmann</dc:creator>
            <category>Developers</category>
            <pubDate>Wed, 13 Jul 2016 07:21:07 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?2,685993,686296#msg-686296</guid>
            <title>Re: Controlling a Printer With a Soundcard (I2S) on a Raspberry or orange Pi</title>
            <link>https://reprap.org/forum/read.php?2,685993,686296#msg-686296</link>
            <description><![CDATA[ For me, this looks like a way to go: <a href="http://m.aliexpress.com/item/32311656694.html?aff_click_id=9b2af41f70614e259da8c065f105584d-1461243498882-04487-eub6yrrBy&amp;aff_platform=y" target="_blank"  rel="nofollow">ADS1115</a>]]></description>
            <dc:creator>rklauco</dc:creator>
            <category>Developers</category>
            <pubDate>Wed, 13 Jul 2016 01:13:47 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?2,685993,686294#msg-686294</guid>
            <title>Re: Controlling a Printer With a Soundcard (I2S) on a Raspberry or orange Pi</title>
            <link>https://reprap.org/forum/read.php?2,685993,686294#msg-686294</link>
            <description><![CDATA[ This was my first googling attempt:<br />
<a href="http://m.aliexpress.com/item/32683392619.html?aff_click_id=9b2af41f70614e259da8c065f105584d-1461243498882-04487-eub6yrrBy&amp;aff_platform=y" target="_blank"  rel="nofollow">4channel 12bit I2C adc</a>]]></description>
            <dc:creator>rklauco</dc:creator>
            <category>Developers</category>
            <pubDate>Wed, 13 Jul 2016 01:00:46 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?2,685993,686293#msg-686293</guid>
            <title>Re: Controlling a Printer With a Soundcard (I2S) on a Raspberry or orange Pi</title>
            <link>https://reprap.org/forum/read.php?2,685993,686293#msg-686293</link>
            <description><![CDATA[ Well, for the One, I do not regret it - I have the webcam that connects directly to the board, I connect the printer directly to the 26pin header, so still I do have the USB port free. However I do not use wifi as it was a bit unreliable for me, so I vonnect the Ethernet...<br />
But I see your point.<br />
I have to google a bit, but I remember having i2c chip with 8ADC and 1 DAC, but only with 8bit resolution. So I have to search some more. That chip was, however, under $2.]]></description>
            <dc:creator>rklauco</dc:creator>
            <category>Developers</category>
            <pubDate>Wed, 13 Jul 2016 00:57:26 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?2,685993,686290#msg-686290</guid>
            <title>Re: Controlling a Printer With a Soundcard (I2S) on a Raspberry or orange Pi</title>
            <link>https://reprap.org/forum/read.php?2,685993,686290#msg-686290</link>
            <description><![CDATA[ I2C has completely slipped my mind while posting this. A dedicated ADC would definitely be more accurate, but how about price?<br />
<br />
I am already regretting getting the one. It is nice, but I am missing the 3 USB ports and the wifi of the Orange Pi PC+... In order to use octoprint+wifi+webcam I already need an USB hub. :-/<br />
<br />
Next step: Finding out how to run RepRapFirmware on Linux.<br />
<br />
P.S.: Updated the video, a commented version. I did not realize that mobile platforms and chromecast do not show video comments...]]></description>
            <dc:creator>lhartmann</dc:creator>
            <category>Developers</category>
            <pubDate>Tue, 12 Jul 2016 23:53:29 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?2,685993,686005#msg-686005</guid>
            <title>Re: Controlling a Printer With a Soundcard (I2S) on a Raspberry or orange Pi</title>
            <link>https://reprap.org/forum/read.php?2,685993,686005#msg-686005</link>
            <description><![CDATA[ Wow! I have Orange Pi one layinh around, too!!! Have to test this.<br />
Btw, for analog in you'd be better with i2c, wouldn't you?]]></description>
            <dc:creator>rklauco</dc:creator>
            <category>Developers</category>
            <pubDate>Tue, 12 Jul 2016 02:34:30 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?2,685993,685993#msg-685993</guid>
            <title>Controlling a Printer With a Soundcard (I2S) on a Raspberry or orange Pi</title>
            <link>https://reprap.org/forum/read.php?2,685993,685993#msg-685993</link>
            <description><![CDATA[ This is not a question, this is me bragging I did it! A working proof of concept! :-D Below is a video of it running 3 steppers with acceleration profiles and independent speed.<br />
<br />
[<a href="https://www.youtube.com/watch?v=BX-CLXqmRqE" target="_blank"  rel="nofollow">www.youtube.com</a>]<br />
<br />
A little while ago I realized an I2S digital sound output looks a lot like a SPI output, and SPI outputs can drive shift registers. back then I was focused on the ESP8266, so I build a small 32 bit shifter board based on 4x 74H595 and wrote a realtime bitbanger demonstrating it as a GPIO expansion (see [<a href="http://forums.reprap.org/read.php?2,594898" target="_blank"  rel="nofollow">forums.reprap.org</a>]). Then, a couple of days ago I found a few post of people using I2S DACs to improve sound quality on single-board-computers, more specifically Raspberry Pi and Orange Pi. Then it hit me:<br />
<br />
I2S is a realtime digital output present on most SBCs, and we may use may shifter board to control a printer with it!<br />
<br />
I just happened to have an idle Orange Pi One at hand and a few days to spare, so decided to try it out.<br />
<br />
Code is here: [<a href="https://github.com/lhartmann/orangepi-i2s-steppers" target="_blank"  rel="nofollow">github.com</a>]<br />
Shifter PCB was previously released here: [<a href="https://github.com/lhartmann/esp8266_reprap" target="_blank"  rel="nofollow">github.com</a>]<br />
<br />
What was done:<br />
- Replaced /boot/bin/orangepione.bin with the included fex file, so as to enable and configure I2S output.<br />
- A C++ program renders motion for 4 steppers (only 3 connected on the video).<br />
- The C++ program outputs 32 bit words, a bitmask for step/direction of several steppers.<br />
- alsa player (aplay) feeds the 32bit words directly to the "sound card" (not really a card, part of the SOC).<br />
- The "soundcard" outputs raw I2S, and feeds a 32bit shift register. Sample rate is 192k words/s.<br />
- Just 5 wires from OrangePi to the shfter: GND, 3.3V, I2S-Data, I2S-BitClock, I2S-WordClock.<br />
- Shifter outputs drive the stepper drivers. Bits 0-3 are STEP, bits 16-20 are DIR.<br />
- I let out a tear of happiness. :'-D<br />
<br />
What could we do with this:<br />
- Discard the arduino-like controllers used on pretty much every single motion control board out there.<br />
- Remove distinction of software and firmware, as they would run on the same processor. (Eases development).<br />
- Make printer software mostly hardware independent, as long as there is I2S and alsa on the backend.<br />
- Modify reprap-firmware to be more OS-friendly, and run as a backend on the *Pi.<br />
- Have a quad-core computer running accurate motion control for the crazyest of mechanics, at high sample rates.<br />
  - Theoretical limit of 46 steppers (2 channels, 24 bit per channel, using 2 bits for a secondary shifter for DIR bits).<br />
- Have a vision feedback system for calibration? OpenCV?<br />
- Have a full-blown linux system control your printer:<br />
  - python, nodejs, octoprint, and whatnot providing web/touch interfaces.<br />
  - Fast uploads, as there is no serial link anywhere.<br />
  - A really nice interface to the printer: OpenGL and HDMI displays.<br />
- Real easy updates, apt-get style.<br />
<br />
Required for a working printer, but not tested:<br />
- I2S input via alsa-record could allow parallel-in serial-out shift registers to read 32 bit data.<br />
  - Temperature reading via RC charge time?<br />
  - Endstops, and a few buttons.]]></description>
            <dc:creator>lhartmann</dc:creator>
            <category>Developers</category>
            <pubDate>Tue, 12 Jul 2016 01:19:53 -0400</pubDate>
        </item>
    </channel>
</rss>
