Quantcast
Channel: Sustainable Suburbia
Viewing all articles
Browse latest Browse all 234

Hello 2015 - What's New?

$
0
0
FPGAs

Last summer, I backed a couple of Kickstarter campaigns - and now they have both delivered.

I am now the owner of a couple of FPGA boards - and I am slowly learning FPGA technology - aided by the subtle democratisation of programmable hardware. More on this later.

Meanwhile, I am still tinkering with the minimalist programming language SIMPL.  As of Feb 9th 2015 - I can report, with some joy and enthusiasm, that I have managed  a quick and dirty hack, to port it to one of my FPGA boards.  I now have a FPGA, hosting a 32 bit, 96MHz soft core processor - that runs one of the simplest interpreted languages on the planet. Is all a bit bass-ackwards, but it's fun.

The sketch is here as a Github Gist. You will need a Papilio Duo and perhaps a LogicStart Shield - or just run it, native on an Arduino if you want a quick play.

https://gist.github.com/monsonite/97730b0456762da20a98

I'm currently trying to condense all my Txtzyme and SIMPL experimentation into a single, easy to read, Quick Start Guide. please bear with me on this - it might take a little time.

SIMPL and BLE

A meeting with an old work colleague over a pub lunch, rekindled my active interest in SIMPL.  As such I have compiled the various blog posts from 2013 and 2014, into a single document, and I am working out the best way to present it as a useful document describing SIMPL and how it can best be used.

We discussed the idea of passing SIMPL programs via a Bluetooth Low Energy (BLE) connection between a Smartphone and a BLE device. SIMPL programs are very compact and ideally suited to the short packet format of a BLE communication packet.

A SIMPL Compiler?

Having "lifted the hood" again on SIMPL, I have been thinking about the possibility of a SIMPL compiler. There might be a way in which  C code source could be compiled into an interpreted SIMPL program. A machine compiler would help with more complex programs and reduce human errors in coding.

SIMPL has a number of primitive operators, that are mapped into machine language, using an interpreter written in C.  Lower case alpha and punctuation characters limit the primitives to just 58 instructions.  This ensures that a microcontroller that runs SIMPL  - has a memorable and easily managed reduced instruction set.  For future implementations it means that a machine could run SIMPL from a 6 bit instruction.

This would allow more complex SIMPL programs to be machine generated from C source code, and reduced to an interpreted text file to be run on any micro.  It's kind of like the Java Bytecode idea where common code can run on a variety of different platforms - provided that they have the interpreter.  Imagine what sort of a SIMPL program could be conveyed in a 140 character text message - sent to a remote device by SMS.

Better Branching

For this to happen, SIMPL needs some further augmentation to allow easier branching and decision making - in what I call  "If this  - then that" or IFTTT- popularised by a recent new IoT service.

Ideally, and in its simplest form, a parameter needs to be tested against a number (using subtraction) and then branch if the result is positive, negative or zero. The branch would be to either execute the next character (code block) or skip it. This would allow the popular constructs of If-Then-Else and While loops to be generated.

I have implemented a simple < or > test, but it's a little clunky and also needs an equality test as to be included as well.

The round brackets (.....)  represent a block inline of code that should be executed on the outcome of a test or skipped. This would allow While and For constructs to be programmed.

The square brackets [....] could be used for a switch-case construct to be generated.

Whilst I am running out of lower case characters for the primitive commands - only e,f,g, t and v remain, there is loads more scope for expansion by using some of the remaining printable punctuation characters - a total of 32. Some such as +, -, *, / ,>, <, {, }, :, ;,@, !, _ and ? have already been defined leaving about 18 for later.  Logical operators such as & and | (or) are an obvious extension leaving a few like £, $, %, ^, ~, # to acquire some meaning - probably similar to their meaning in a C context.

So in theory, SIMPL can have a maximum of (26+32) primitive commands plus 26 user defined words - as defined by uppercase alpha characters.

Better Arithmetic

SIMPL currently has an x variable and a y variable that can be set to the previously entered value of x using the @ (fetch) and ! (store) operators. This is a bit clunky and a better way of handling multiple variables would probably be by using a stack. I want to try to keep the interpreter simple, and not implement the full stack logic. As most microcontrollers only combine 2 variables in their math operations,  just x and y will be sufficient to handle this.

In FORTH, numbers are automatically put on the stack, but in SIMPL, they always go into x, unless stored to y using the ! operator.  A neat idea would be to use the space character (instead of !)  to inform the interpreter that another number is expected immediately, and so that x should be stored to y, so that x is free to accept the second number.

This would make the math operations a whole lot more readable - just by separating the variables with a single space.

123 456+p  would add 123 and 456 and print it out.

As well as the math operators, the logical operators would also benefit from this increased flexible notation.  The space operator implies - push the top of the stack down to make room for another parameter - allowing constructs such as

123 456+ 23-p    so the interim sum of 123+456 is pushed down by the 2nd space, allowing room for the 23 and the subtraction operation.  This makes it a lot more FORTH like and very much improved readability for numerical operations involving two variables.

Rule: A space following a number implies that the number is automatically copied from x (top) to the y (next) variable.

More Operators

&   Bitwise AND
|     Bitwise OR
^     Bitwise XOR
~    NOT (invert)

$     String operator
%    modulo operator
(...)  Conditionally execute this block of code
[...]  Use x to select an option from the list contained within the square brackets
£     Invoke SIMPL interpreter
#  
,      separate a list of integers
.      Pop x and print it (FORTH compatibility)
?     Print out the current set of definitions
\    
"

:     Start of colon definition
;     End of colon definition
_     Text string identifier


Other Developments.

A few notable things have happened since I was last using SIMPL to control stepper motors and LED arrays using shift registers. I have developed a new compact RFM12/69 wireless I/O breakout board for the Raspberry Pi in association with my friends at Open Energy Monitor and I have invested in a couple of FPGA dev boards - launched via Kickstarter.

Both of these developments can benefit from SIMPL. I have a compact I/O board (33 x 28mm) which can execute SIMPL commands via a 250m range wireless link, or can be used as an Arduino compatible wireless I/O extender for the Raspberry Pi. It breaks out 12 digital I/O pins and 8 analogue pins from the ATmega328 SMD package, giving almost complete Arduino functionality in a small form factor.

SIMPL is a great way of getting the Pi to drive the I/O board - by a series of easy serial commands. This would open up the Pi to driving LED arrays, stepper motors and indeed, anything that the Arduino can do - just with a few high level commands.  The Arduino has 5V tolerance, so best to have it take the knocks when experimenting with I/O - rather than frying a more expensive Pi.

Lithium Battery Developments

I have also been doing some work developing hardware that runs on a single Lithium Ion cell.  This has involved the use of the MCP1640 boost converter and also the MCP73832 battery charger IC. This development work has gone very well and I am confident that I can make an economical battery powered design based around these ICs. The MCP1640 at just 30p in volume, is a fraction of the cost of the LTC3525 boost converter. Combined with a small inductor - such as this one from Farnell - you have a very compact boost regulator for about 50p.

FPGAs - The Democratisation of Programmable Logic

Meanwhile, a couple of Kickstarters that I backed last summer have come to fruition - I have now entered the exciting world of FPGAs and soft-core processors.  The great thing is that now an Arduino can be emulated by a 32bit 100MHz soft core processor on an FPGA, and as such SIMPL can be ported to the FPGA ecosystem.   Here's an update on FPGA developments:

Field Programmable Gate Arrays (FPGAs) are definitely the future for digital electronic design.

They are a "blank canvas" of logic gates and registers, onto which you can paint your own digital design.

However, the FPGA manufacturers tool chains are certainly not intended for easy access to this wonderful technology, and to be thrown in at the deep-end of the various hardware design languages - Verilog and VHDL will appear daunting to most.

Fortunately, some forward thinking individuals have succeeded in providing an abstraction later to these tool chains in the form of an Integrated Design Environment (IDE) and with this easier entry level, have managed to make FPGA technology open to a much wider market of hobbyists and enthusiasts.

Background

There are two competing FPGA manufacturers - who between them each hold about 45% of the world market. With this combined 90% world market domination - there is very little space for their competitors.

Altera - known for their Stratix and Cyclone families of FPGAs.


Xilinx  - known for their range of Spartan FPGAs.



Recently, two crowd funded FPGA dev-boards have come available via Kickstarter. Whilst subtley different - they share the same Xilinx Spartan 6 FPGA.

Scarab Hardware  MIniSpartan 6+ 

This is a professional dev-board with two HDMI sockets, 3.5mm audio jack, 8 channels ADC, miniSD card socket and 2MB of SRAM.   The Spartan 6 is a BGA package  - and most of the I/O is brought out to a pair of dual row headers. There is a miniB USB connection via the ubiquitous FTDI chip.  The board is white in colour with great care taken in matching track lengths for maximum performance.

Gadget Factory    Papilio Duo 

The Papilio DUO - whilst sharing the Spartan 6 FPGA offers a different approach in familiarising the hardware.  It has the footprint of an Arduino MEGA, and additional hardware may be attached in the form of shields or "Wings".   The FPGA is in a LQFP pagkage as opposed to BGA.  There is also the same FTDI  USB interface IC, but on the bottom of the pcb is an Atmel ATmega32U4 which can be programmed as an Arduino (Leonardo).

Whilst not providing on board video, Audio or microSD connectors - these can be added in the form of a "LogicStart" Shield or Gaming shield.

The unique selling point of the Papilio DUO, is that it is supplied with a soft-core processor - the "ZPUino" - which emulates an Arduino, but at 100MHz on 32bit hardware.  Once the hardware is loaded with the logic design for the ZPUino, it will then accept and run a normal Arduino sketch - but at many times the speed performance. 

Arduino users can port their sketches almost directly across to the DUO board and run them on the soft-core.  They can also progress to designing their own hardware designs to accompany the Z- core on the FPGA. 

In my opinion - this allows the Arduino user a smooth transition into the world of FPGAs.


Viewing all articles
Browse latest Browse all 234

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>