perkin.org.uk - A node.js-powered 8-bit CPU - part one









Search Preview

A node.js-powered 8-bit CPU - part one

perkin.org.uk
Jonathan Perkin about me · rss · twitter · github
.org.uk > perkin.org.uk

SEO audit: Content analysis

Language Error! No language localisation is found.
Title A node.js-powered 8-bit CPU - part one
Text / HTML ratio 49 %
Frame Excellent! The website does not use iFrame solutions.
Flash Excellent! The website does not have any flash contents.
Keywords cloud » SmartOS packages Jan Dec LED GPIO CPU pin Jun part I’ve rpio Pi rpiowrite11 Raspberry Apr OSX pkgsrc wire
Keywords consistency
Keyword Content Title Description Headings
» 52
SmartOS 13
packages 10
Jan 9
Dec 9
LED 9
Headings
H1 H2 H3 H4 H5 H6
2 3 0 0 0 0
Images We found 2 images on this web page.

SEO Keywords (Single)

Keyword Occurrence Density
» 52 2.60 %
SmartOS 13 0.65 %
packages 10 0.50 %
Jan 9 0.45 %
Dec 9 0.45 %
LED 9 0.45 %
GPIO 8 0.40 %
CPU 7 0.35 %
pin 7 0.35 %
Jun 7 0.35 %
part 6 0.30 %
I’ve 6 0.30 %
rpio 6 0.30 %
Pi 5 0.25 %
rpiowrite11 5 0.25 %
Raspberry 5 0.25 %
Apr 5 0.25 %
OSX 5 0.25 %
pkgsrc 5 0.25 %
wire 5 0.25 %

SEO Keywords (Two Word)

Keyword Occurrence Density
2013 » 18 0.90 %
2012 » 14 0.70 %
2011 » 11 0.55 %
8bit CPU 6 0.30 %
Jun 2011 6 0.30 %
Jan 2013 6 0.30 %
to the 5 0.25 %
A nodejspowered 5 0.25 %
nodejspowered 8bit 5 0.25 %
CPU part 5 0.25 %
Raspberry Pi 5 0.25 %
the LED 5 0.25 %
on SmartOS 5 0.25 %
on the 4 0.20 %
known as 4 0.20 %
to control 4 0.20 %
packages for 4 0.20 %
» A 4 0.20 %
pkgsrc on 4 0.20 %
Dec 2013 4 0.20 %

SEO Keywords (Three Word)

Keyword Occurrence Density Possible Spam
Jan 2013 » 6 0.30 % No
Jun 2011 » 6 0.30 % No
8bit CPU part 5 0.25 % No
A nodejspowered 8bit 5 0.25 % No
nodejspowered 8bit CPU 5 0.25 % No
» A nodejspowered 4 0.20 % No
» pkgsrc on 4 0.20 % No
2013 » A 4 0.20 % No
Dec 2013 » 4 0.20 % No
pkgsrc on SmartOS 3 0.15 % No
» How to 3 0.15 % No
also known as 3 0.15 % No
2013 » pkgsrc 3 0.15 % No
the Raspberry Pi 3 0.15 % No
Jan 2012 » 3 0.15 % No
» Set up 2 0.10 % No
rpio = require'rpio' 2 0.10 % No
going from pin 2 0.10 % No
A jumper wire 2 0.10 % No
2011 » Fix 2 0.10 % No

SEO Keywords (Four Word)

Keyword Occurrence Density Possible Spam
nodejspowered 8bit CPU part 5 0.25 % No
A nodejspowered 8bit CPU 5 0.25 % No
Dec 2013 » A 4 0.20 % No
2013 » A nodejspowered 4 0.20 % No
» A nodejspowered 8bit 4 0.20 % No
» pkgsrc on SmartOS 3 0.15 % No
2013 » pkgsrc on 3 0.15 % No
wire going from pin 2 0.10 % No
2013 » What's new 2 0.10 % No
jumper wire going from 2 0.10 % No
A jumper wire going 2 0.10 % No
as 'high' rpiowrite11 1 2 0.10 % No
2011 » How to 2 0.10 % No
on the Raspberry Pi 2 0.10 % No
known as 'high' rpiowrite11 2 0.10 % No
also known as 'high' 2 0.10 % No
» What's new in 2 0.10 % No
Jan 2013 » pkgsrc 2 0.10 % No
Jun 2011 » How 2 0.10 % No
to get to the 2 0.10 % No

Internal links in - perkin.org.uk

about me
About Me
rss
Jonathan Perkin
Reducing RAM usage in pkgin
Reducing RAM usage in pkgin
Building packages at scale
Building packages at scale
A node.js-powered 8-bit CPU - part four
A node.js-powered 8-bit CPU - part four
A node.js-powered 8-bit CPU - part three
A node.js-powered 8-bit CPU - part three
A node.js-powered 8-bit CPU - part two
A node.js-powered 8-bit CPU - part two
A node.js-powered 8-bit CPU - part one
A node.js-powered 8-bit CPU - part one
MDB support for Go
MDB support for Go
Distributed chrooted pkgsrc bulk builds
Distributed chrooted pkgsrc bulk builds
pkgsrc on SmartOS - creating new packages
pkgsrc on SmartOS - creating new packages
Installing SVR4 packages on SmartOS
Installing SVR4 packages on SmartOS
SmartOS is Not GNU/Linux
SmartOS is Not GNU/Linux
SmartOS development preview dataset
SmartOS development preview dataset
pkgsrc on SmartOS - fixing broken builds
pkgsrc on SmartOS - fixing broken builds
pkgsrc on SmartOS - zone creation and basic builds
pkgsrc on SmartOS - zone creation and basic builds
Multi-architecture package support in SmartOS
Multi-architecture package support in SmartOS
Solaris portability - cfmakeraw()
Solaris portability - cfmakeraw()
Solaris portability - flock()
Solaris portability - flock()
SmartOS and the global zone
SmartOS and the global zone
Setting up Samba on SmartOS
Setting up Samba on SmartOS
Creating local SmartOS packages
Creating local SmartOS packages
7,000 binary packages for OSX Lion
7,000 binary packages for OSX Lion
9,000 packages for SmartOS and illumos
9,000 packages for SmartOS and illumos
Goodbye Oracle, Hello Joyent!
Goodbye Oracle, Hello Joyent!
SmartOS global zone tweaks
SmartOS global zone tweaks
Automated VirtualBox SmartOS installs
Automated VirtualBox SmartOS installs
iptables script for Debian / Ubuntu
iptables script for Debian / Ubuntu
New site design
New site design
Set up anonymous FTP upload on Oracle Linux
Set up anonymous FTP upload on Oracle Linux
Kickstart Oracle Linux in VirtualBox
Kickstart Oracle Linux in VirtualBox
Kickstart Oracle Linux from Ubuntu
Kickstart Oracle Linux from Ubuntu
Last day at MySQL
Last day at MySQL
Installing OpenBSD with softraid
Installing OpenBSD with softraid
Create VirtualBox VM from the command line
Create VirtualBox VM from the command line
Creating chroots for fun and MySQL testing
Creating chroots for fun and MySQL testing
Graphing memory usage during an MTR run
Graphing memory usage during an MTR run
Fix input box keybindings in Firefox
Fix input box keybindings in Firefox
How to lose weight
How to lose weight
How to fix stdio buffering
How to fix stdio buffering
Fix Firefox URL double click behaviour
Fix Firefox URL double click behaviour
SSH via HTTP proxy in OSX
SSH via HTTP proxy in OSX
How to build MySQL releases
How to build MySQL releases
ZFS and NFS vs OSX
ZFS and NFS vs OSX
pkgsrc on Solaris
pkgsrc on Solaris
Jumpstart from OSX
Jumpstart from OSX
Set up local caching DNS server on OSX 10.4
Set up local caching DNS server on OSX 10.4

Perkin.org.uk Spined HTML


A node.js-powered 8-bit CPU - part one Jonathan Perkin well-nigh me · rss · twitter · github A node.js-powered 8-bit CPU - part one Dec 01, 2013 tags: 8-bit, homebrew, nodejs This post is part one of a series, the other posts misogynist are Part two - shift registers Part three - the CPU Part four - putting it all together Introduction As a child growing up in the 1980s, I was naturally drawn towards the 8-bit computers of the day. I spent most of my early diaper on my Atari 400 and Amstrad CPC 6128, as well as stuff familiar with the Spectrum, Acorn Electron, and BBC Model B computers owned by my friends. Other than the occasional bit of BASIC and CP/M, however, I was not at the time that interested in how they worked (I was too rented playing games), and so never took the endangerment to learn turnout and electronics at that crucial early age. This is something I’ve unchangingly regretted, and so recently I’ve found myself increasingly and increasingly interested in revisiting those older systems. While computers today are far increasingly capable and many orders of magnitude faster than those early systems, they have moreover wilt significantly increasingly complicated. Nowadays, plane if you are curious well-nigh exactly how they work, they just are not as wieldy to wordplay those questions in the same way that computers from my diaper are. As a result, there is today quite a large homebrew community, with people towers their own 8-bit systems. One of my favourites is Matthew Sarnoff’s Ultim809 computer, and his work inspired me to have a go myself. Realistically, with a rented job and a family, I’m never going to be worldly-wise to get to the level of Matthew’s work, however I’ve had a lot of fun working on the shit I’ve washed-up so far, and wanted to share it so hopefully others can learn too. So, in these posts we’re going to get to the stage where we can momentum an 8-bit CPU from a Raspberry Pi, using node.js (but any language will suffice). To start with, we need to introduce GPIO. GPIO Quoting Wikipedia: “General-purpose input/output (GPIO) is a generic pin on an integrated spin (commonly tabbed a chip) whose behaviour (including whether it is an input or output pin) can be controlled (programmed) by the user at run time.” Essentially you can think of GPIO pins as small power switches which you can turn on or off. On the Raspberry Pi they provide 3.3V, and in our first simple example we are going to tenancy an LED from one. Here’s what you will need to follow along: A Raspberry Pi (or similar system with user-programmable GPIO) running Linux. A BreadBoard. Some LEDs, preferably green, yellow, and red. Some jumper wire. Some 270 Ohm (Ω) resistors Let’s take a quick squint at the specie board. These indulge fast and re-usable construction of electronic circuits, and are laid out in rows - the verticals lanugo the side are for power (positive and negative), and each horizontal row is for individual components. In the diagram below, the power lines are indicated by the red and undecorous boxes, and the component lines by the untried boxes. To construct the simplest possible electronic circuit, wire up the following: An LED vertically, with the anode (positive) whilom and the cathode (negative) below. To determine the correct orientation the marrow side is usually flat, and/or the anode is longer. A jumper wire going from pin 1 on the Raspberry Pi (this is the +3.3V line) to a socket on the positive line. A jumper wire going from pin 6 on the Raspberry Pi (ground) to the undecorous (ground) power rail. A 270Ω resistor connecting the ground rail to the cathode line. The resistor is required to reduce the voltage from 3.3V lanugo to the 2.0V or so that the LED needs - without it the LED will likely shrivel brightly for a short time surpassing blowing. Doing this should requite you a lit LED, and squint something like this: I’ve widow annotating arrows, with the positive arrows in red and negative arrows in blue, showing the direction of current. This is a good trammels that everything is working correctly, now let’s move on to make it software controlled. To do that, move the red jumper wire from pin 1 to go to pin 11 instead. This is known as GPIO17 (there are variegated numbering schemes for the pins depending on whether you use the physical layout or the chipset’s view - see http://elinux.org/images/2/2a/GPIOs.png for the full layout). Software To turn it on or off, let’s get node up and running. If you don’t once have it installed, grab the latest stable version for linux-arm-pi from http://nodejs.org/dist (latest as of writing is v0.10.21): : You will need to be root to install and use the rpio module. # flourish -O http://nodejs.org/dist/v0.10.21/node-v0.10.21-linux-arm-pi.tar.gz # tar zxf node-v0.10.21-linux-arm-pi.tar.gz -C /usr/local # PATH=/usr/local/node-v0.10.21-linux-arm-pi/bin:$PATH Next, install my rpio module. There are a number of GPIO modules available, however mine appears to be the only one which links versus the bcm2835 library rather than going via the much slower /sys file system interface. # npm install -g rpio Finally, write this JavaScript to a file named led-on.js… // Load the rpio module var rpio = require('rpio'); // Configure pin 11 (GPIO17) for output (i.e. read/write). rpio.setOutput(11); // Turn GPIO17 on, moreover known as 'high'. rpio.write(11, 1); …and run it… # node led-on.js …which should result in the LED stuff lit. You could then create an led-off.js which is a reprinting of led-on.js except waffly this: // Turn GPIO17 on (1), moreover known as 'high'. rpio.write(11, 1); to this: // Turn GPIO17 off (0), moreover known as 'low'. rpio.write(11, 0); and then we have a script which will turn the LED off. For our final example, we can use setInterval() and setTimeout() to implement a shimmer LED: var rpio = require('rpio'); rpio.setOutput(11); /* *Twinklethe LED quickly (10 times per second). It is switched on every * 100ms, and a timeout is set for 50ms later to switch it off, giving us * the regular blink. */ setInterval(function blink() { rpio.write(11, 1); setTimeout(function ledoff() { rpio.write(11, 0); }, 50); }, 100); Here’s a video of my setup running this script. This covers the introduction to GPIO and getting started with using node to tenancy pins. If you wanted to stay at this level and experiment further, you could use a few increasingly of the GPIO pins to tenancy spare LEDs, perhaps subtracting a yellow and a untried for some traffic lights. I’ve washed-up this with my kids and it’s a unconfined way for them to play with electronics. My pilights repository on GitHub gives them an easy to use shell script interface, with some example programs to get started. In the next post we move on to tenancy something a little increasingly complicated. Share this post on Twitter, HackerNews, Facebook or Google+ All Posts 16 Jul 2015 » Reducing RAM usage in pkgin 03 Mar 2015 » pkgsrc-2014Q4: LTS, signed packages, and increasingly 06 Oct 2014 »Towerspackages at scale 04 Dec 2013 » A node.js-powered 8-bit CPU - part four 03 Dec 2013 » A node.js-powered 8-bit CPU - part three 02 Dec 2013 » A node.js-powered 8-bit CPU - part two 01 Dec 2013 » A node.js-powered 8-bit CPU - part one 21 Nov 2013 » MDB support for Go 30 Jul 2013 » What's new in pkgsrc-2013Q2 24 Jul 2013 » Distributed chrooted pkgsrc zillion builds 07 Jun 2013 » pkgsrc on SmartOS - creating new packages 15 Apr 2013 » What's new in pkgsrc-2013Q1 19 Mar 2013 » Installing SVR4 packages on SmartOS 27 Feb 2013 » SmartOS is Not GNU/Linux 18 Feb 2013 » SmartOS minutiae preview dataset 17 Jan 2013 » pkgsrc on SmartOS - fixing wrenched builds 15 Jan 2013 » pkgsrc on SmartOS - zone megacosm and vital builds 10 Jan 2013 » Multi-architecture package support in SmartOS 09 Jan 2013 » Solaris portability - cfmakeraw() 08 Jan 2013 » Solaris portability - flock() 06 Jan 2013 » pkgsrc-2012Q4 illumos packages now misogynist 23 Nov 2012 » SmartOS and the global zone 24 Oct 2012 » Setting up Samba on SmartOS 10 Oct 2012 » pkgsrc-2012Q3 packages for illumos 23 Aug 2012 » Creating local SmartOS packages 10 Jul 2012 » 7,000 binary packages for OSX Lion 09 Jul 2012 » 9,000 packages for SmartOS and illumos 07 May 2012 » Goodbye Oracle, Hello Joyent! 13 Apr 2012 » SmartOS global zone tweaks 12 Apr 2012 » Automated VirtualBox SmartOS installs 30 Mar 2012 » iptables script for Debian / Ubuntu 20 Feb 2012 » New site diamond 11 Jan 2012 » Set up unrecognized FTP upload on Oracle Linux 09 Jan 2012 » Kickstart Oracle Linux in VirtualBox 09 Jan 2012 » Kickstart Oracle Linux from Ubuntu 22 Dec 2011 » Last day at MySQL 15 Dec 2011 » Installing OpenBSD with softraid 21 Sep 2011 » Create VirtualBox VM from the writ line 14 Sep 2011 » Creating chroots for fun and MySQL testing 30 Jun 2011 » Graphing memory usage during an MTR run 29 Jun 2011 » Fix input box keybindings in Firefox 24 Jun 2011 » How to lose weight 23 Jun 2011 » How to fix stdio buffering 13 Jun 2011 » Serving multiple DNS search domains in IOS DHCP 13 Jun 2011 » Fix Firefox URL double click behaviour 20 Apr 2011 » SSH via HTTP proxy in OSX 09 Nov 2010 » How to build MySQL releases 29 Apr 2010 » 'apt-get' and 5,000 packages for Solaris10/x86 16 Sep 2009 » ZFS and NFS vs OSX 12 Sep 2009 » pkgsrc on Solaris 09 Dec 2008 » Jumpstart from OSX 31 Dec 2007 » Set up local caching DNS server on OSX 10.4