Introduction: DemUinoDuo

An Arduino/Sanguino Inspired Computer by DemeterArt

with USB keyboard and SD FAT support


A dual controller system supporting USB keyboard and SD card with FAT

Primary controller the ATMEGA644-20PU with 64KB flash, 4KB SRAM and 2KB EEPROM

Supporting controller the ATMEGA328 communicating via I2C, SPI-to-USB and RS232

LCD character display 4 lines by 20 columns with linebar graphics

create up to 8 custom characters for user graphics including bargraph

support for interactive and batch modes

full screen line editor up to 100 program steps

if-else conditional, do-while and for-next loops plus goto and gosub statements for branching and timely execution

compute Convolution and DFT of sequences plus any combination of arithmetic and mathematical expressions in RPN

run interactively commands while a program is running

run mini loops/programs from the command line

modify on-the-fly program data and code

system variables allow for timed events, average, rms, min and max values from analog pins, etc

104 bytes of different types of user variables that share memory among them to interact with system variables and commands allowing for bytes, short and long integers as well as floating point numbers

up to 1000 bytes of dynamic memory to work with ranging from unsigned chars to floating point numbers

mini oscilloscope application 16x20 dots and 50KB/sec sampling rate

slow and fast GPIO

save/load programs and data to/from SD card, EEPROM and PC

autoexec to load and run a program from EEPROM after each reset

up to 26 GPIO pins with SD FAT functionality

BUZZER for sound effects


The DemUino concept revolves around a controller-based-computer and in particular AVR 8 bit beasts using Arduino libraries. In an effort to keep the project up to date I had to adapt it to use USB keyboards and modern storage media – SD or microSD with adapters – supporting plain text PC files (FAT).

The major problem with this “upgrade” is the huge resource sacrifice both in flash code and RAM demand either static or dynamic. However, the use of a dual processor system alleviates the pain from the horrid loss and provides a sort of worth-the-effort feeling when the project reaches a tangible useable result. The system can be built with both processors being atmega328s, something that reproduces all functionality of DemUino version 1.66 but with only a little over 700 bytes of RAM free. The use of an atmega644 as the main processor handling the SD card and the delegation of USB, I2C master and RS232 (PC data) to an atmega328 builds a better more capable system with over 1300 bytes free for DemUinoDuo version 1.0 including SD FAT functionality. The display is a standard 4x20 text LCD (parallel mode) driven by the GPOUT port of the maxim controller on the USB host shield.

The following page shows the system architecture. The decision to transfer the USB control over to the atmega328 was based on the tricky nature of the Usb.Task() function that needs to run unhindered in a continuous and predictable loop. The main processor – the atmega644 – needs to service all sorts of situations and even wait for things to happen apart from just user delays. The keyboard presses are sent over the I2C bus causing event handlers in the main MCU to timely respond and feed them to the program as they occur. There is a continuous stream of 21 bytes at a time treated as a group/packet of data from the slave atmega644 (#3 on the I2C bus) to the master atmega328 that are either LCD commands or synchronization data. The external EEPROM slave present is not currently addressed by the master.

There is a 200ms delay for repetition of any key press to register. On the primary controller side the LCD requests are serviced with a 5ms delay and the keyboardavailable() loop introduces a 5ms delay too. However, if the user program does not use any LCD commands then an empty for-loop by itself counting to 1000 executes in about 126ms for a total of 1002 statements. An assignment to a variable in the same loop increases execution time to 535ms for a total of 2002 statements.

The USB host shield is made by the good folks at and I need to thank Kristian Lauszus at for kindly responding to my questions and also for the serial opti-bootloader of the atmega644.

The unit was actually built and photographed by using the DemUino2 and SD2RS232 boards to save money. The schematic presented in the following pages is the suggested way of building the unit which requires fewer parts than what is perceived from the photos.

During start-up the unit checks for the presence of an SD card and if not found then the BUZZER sounds for one second. The LOGO may appear right away but wait till the lights of the keyboard blink momentarily before typing away in bliss.

The hardware as it stands offers very good development possibilities, definitely better that what I presently address with version 1.0 of the released code. Apart from the required optimization to save flash and RAM space (without altering the voracious SD library) there is the untamed potential of the supporting atmega328 as a GPIO module by itself and of course the employment of the external EEPROM as a data repository.



Summary of Commands & Expressions

“ : a nonprintable comment line

00-99 : a two digit number by itself is equivalent to goto

ai : attach interrupt 0,1,2

anf : display the average, r.m.s, max. and min. of axxx

apl : plot the contents of axx using bar graph

ar : analog read

aw :‘analog write’ per sanguino or more properly pwm

ca : analog capture in an array

cl : clears the display

cm : execute the contents of pointer p or a

cno : find a line number index in *Prgm[]

cnv : convolution of two arrays

DFT : discrete fourier transform

di : wait for a series of pulses and measure duration and timing

dim: allocate memory for user array axxx

dl : delay

do : in conjunction with ‘wh’

dr : digital read any pin

dw : digital write any pin

ed : editor mode for batch commands

el : EEPROM read access function

els : in conjunction with ‘if’

end : the END statement of a program

ensb: ends subroutine

es : EEPROM write access function

ev : EEPROM viewer

fl : simple moving average filter

fr : for-next loop (fr-nx)

go : jump to program step

gosb: continue execution to subroutine / timely execution

gt : waits for user input

if : test condition

io : slow GPIO

jmp: similar to goto

ld : load/merge program from EEPROM

lp: : execute multiple commands repeatedly in interactive mode

lpr : define lp: command parameters

ls : list mode

ml : get time

mm : display free memory

nos : converts number to string

nx : in conjunction with ‘fr’

pa : fast 8-bit output from port A

pl : plot array cxx

pm : set pins for in or output

ppr: set apl plotting parameters

pr : prints a message or value or custom character

pw : pwm with keyboard control

rn : run the program in RAM

rgc : range copy command for array operations

rgs : range set command for array operations

rs : soft reset (registers unaffected – heap cleared)

sd : SD card access functions (load, save, delete and dir)

si : synchronous serial input with clock and data pins

sm : mini oscilloscope app

snd : fast user modulated pwm at 7.8KHz

sno : string to number

so : synchronous serial output with clock and data pins

stc : copy string to array

stf : find string in array/ return string length

stm : compare strings

sub : declares subroutine

sv : save program to EEPROM

tn : beep a tone

wh: a do-while loop used in conjunction with ‘do’

Simple Constructs for Expressions in RPN Notation

Var1 = Var2 Var3 + : add

Var1 = Var2 Var3 - : subtract

Var1 = Var2 Var3 * : multiply

Var1 = Var2 Var3 / : divide

Var1 = Var2 Var3 % : modulo - integers only

Var1 = Var2 INV : reciprocal

Var1 = Var2 Var3 > : greater than

Var1 = Var2 Var3 < : less than

Var1 = Var2 Var3 = : equality

Var1 = Var2 Var3 != : inequality

Var1 = Var2 Var3 && : logical AND

Var1 = Var2 Var3 || : logical OR

Var1 = Var2 ! : boolean not

Var1 = Var2 SIN : sinusoid

Var1 = Var2 ASN : arcsin

Var1 = Var2 TAN : tangent

Var1 = Var2 ATN : arctangent

Var1 = Var2 LOG : log10

Var1 = Var2 EXP : exponential

Var1 = Var2 Var3 POW : power

Var1 = Var2 SQR : square root

Var1 = Var2 SQ : squared

Var1 = Var2 : equate

Var1 = Var1 Var2 Var3 BW : bitWrite

Var1 = Var2 Var3 BR : bitRead

Var1 = Var2 Var3 & : bitwise AND

Var1 = Var2 Var3 | : bitwise OR

Var1 = Var2 Var3 << : bit left-shift

Var1 = Var2 Var3 >> : bit right-shift

#p : π ≈ 3.14159265358 (internal)

#e : e ≈ 2.7182818


seamster (author)2014-11-21

Nice work!

demeterart (author)seamster2014-11-22

10Q so much!

About This Instructable




More by demeterart:DemUinoGRAPHDemUinoTVoutDemUinoPortable
Add instructable to: