APL on the C3Pi
One of the biggest joys of being the CTO of Dyalog is that you get to write code to help evaluate prototypes of proposed language features, or new tools and tutorials that we are planning to make available. This past week has been one of the most exciting for a very long time, because it started with Jason and Liam presenting me with the first fully-assembled Dyalog-built C3Pi clone!
Jason Rivers has been constructing the hardware, and Liam Flanagan is responsible for the port of Dyalog APL to the Raspberry Pi, which will be the seat of the “brains” of the robot. We have been talking to the folks at Quick2Wire over the winter about this project, primarily with Romilly Cocking, who is one of those select individuals who can boast that he has already achieved the dream of every programmer.
This week, all the bits came together:
• Jason finished assembling the first C3Pi mockup (we are building 4 units to play with, while we wait for the finished item from Quick2Wire).
• The CTO purchased and charged two sets of six AA batteries.
• Dyalog APL version 13.2 (Unicode edition only) passes our tests on the Pi, except for an issue with de-normal floating-point numbers caused by a known issue in the Linux kernel. We aim to officially release a free non-commercial version for the Raspberry Pi by mid-May, contact us for an advance copy if you can’t wait.
• Liam has built a shared library which interfaces APL to the I2C bus which is used to make life a little easier for an APL developer trying to use I2C. We use I2C talk to the Arduino which controls up to 11 outputs and 6 inputs, if I am reading the specification correctly. At the moment, we use three outputs for each of two motors: One analog output to control the speed and two digital outputs to activate the motor going either forwards or back.
• Liam has also constructed some temporary code we are using while we wait for the updated Quick2Link code to become available: This is a “command interpreter” running on the Arduino which accepts 3-byte commands {pin type, pin number, output value) over the I2C interface, providing a very easy mechanism for APL to drive the Arduino outputs.
Now, that’s a pretty exciting package to find on your desk on a Monday morning! OK, Monday afternoon, to be honest – the morning was spent with Fiona Smith, our first full-time Technical Writer – another person who will soon be contributing to our “Pi” project. Needless to say, I shortened every meeting for the rest of the week by 5 minutes, and thus managed to find the time to write some APL code capable of driving the robot (press “play” below).
We’ll be keeping the various bits of code up-to-date in repositories under https://github.com/APLPi. If you think you might want to build your own hardware and play along with us, Jason will soon be starting his own series of blog posts about how to build a C3Pi. I will write a bit more about the APL code, and the longer term goals of this project, in my next post.