Introduction: DemUino - Home Computer/Controller

An Arduino Inspired Computer by DemeterArt


Make the most of your old PS2 keyboard. Hack it into a customized personal computer to control stuff! I ‘ve always wanted to build my own home computer, kind of retro-style, nothing fancy but with particular capabilities tailored to my preferences. So, I got to it with the atmega328 MCU and the Arduino development kit.

Let me state that this project would have taken considerably longer with dubious end results if it were not for the gifted fans out there who selfishlessly supply the freeware libraries for everyone to use. Thank you all :-)

visit my site to read the whole story and download all relevant files

http://www.sites.google.com/site/demeterart

Step 1: Features

  • Based on the ATMEGA328 with 32KB flash, 2KB SRAM and 1KB EEPROM.
  • support for interactive and batch modes
  • line editor and list-while-edit mode
  • 8 custom characters for user graphics
  • 60 program steps numbered 00,...,99
  • ‘If’ conditional, ‘while’ and ‘for’ loops plus ‘goto’ and ‘sub’ statements for branching
  • Basic arithmetic and mathematical expressions plus boolean tests
  • system variables allow for timed events, average, rms, min and max values from analog pins, etc
  • 26 user variables to interact with system variables and commands
  • 104 bytes of a user addressable array or 52 short integers
  • ability to read/write program data as well as code on-the-fly (p variable)
  • mini oscilloscope app with customized characters for pseudo graphics
  • save and load programs and data to/from EEPROM
  • load/save programs and variables from/to PC
  • autoexec into loading and running a program from EEPROM after each reset
  • 9 GPIO pins (SPI included) available on external DB15 connector
  • BUZZER for sound effects

The following mini apps were removed from the last version to allow for more features :

ev : EEPROM viewer (see el command)

pr c : print the contents of cxx (see cxx variable)

pw : pwm with keyboard control (see aw command)

pi : wait for and display incoming pulses (see the ‘di’ command)

la : fast logic capture of 3200 bits in 10.8msec

sc : serial remote control (see example)

The first three can be functionally replicated by use of the ‘lp:’ command. For the rest refer to the ARCHIVED versions.

Step 2: Stuff You Will Need



An old ps/2 keyboard thick enough to house the pcb
LCD character display (the popular parallel format)
MAX232 chip for RS232 port
atmel atmega328PU
Arduino development kit with IDE 1.0.1
LM7805 regulator
5V buzzer
bridge rectifier , capacitors, a reset push button, connectors etc

Step 3: Burning the Bootloader

 


So, after having bought an ‘empty’ atmega328PU chip there is a decision to be made. Do i use a special programmer either external or ISP or do I burn the Arduino bootloader into the beast and render the unit programmable via its UART port? I chose the latter to make my life easier! The new bootloader occupies only half a kilobyte of flash memory leaving a little more than 31KB of user program and static data available. TheArduino site covers the case of burning the bootloader on a new chip, when it came to using avrdude to actually burn the target chip the process failed with an error indicating the wrong id for the particular MCU. So after some searching I found this guy who got it right and I followed his procedure. The only difference was 2 configuration files, avrdude.conf and boards.txt needed by avrdude and arduino IDE 1.0.1 to make it possible. After copying the 2 files to their proper locations (backup the old ones first) the option ‘arduino328’ from tools->Board was available and avrdude proceeded with burning the fuses and the bootloader. Now the chip is ready to be programmed from within the new machine!

Step 4: Building the Unit


A perforated board with copper strips was used as a fast assembly solution with DIP sockets for the chips, you know, just in case! Then the holes and cuts for the connectors, the reset button and the LCD display were opened through the extremely sturdy and thick plastic of the keyboard. Yeah, that was built 25 years ago! There followed the mess of wires emanating from the pcb towards the various peripherals. A rudimentary continuity check and then the supply was connected with no chips populated just to check the sockets for proper voltages. Then came in the 2 ICs and the keyboard case was firmly closed via its plastic snaps at the bottom. The unit was ready to burn sketches in the controller!

I suggest one uses nonpolar 1uF/16V capacitors for the MAX232 charge pumps. Locate the 100nF decoupling capacitors for the two chips as close as possible to the respective VCC and GND pins. Use a star connection for the power and ground referenced to the LM7805 regulator. Switch 2 could be a jumper depending on impementation but it is good to have if only to avoid unwanted MCU resets from the host PC in certain cases. At any rate, the switch must be closed to allow for the Arduino IDE to burn the sketch via resetting the target MCU (pin DTR of RS232). In my case the connection is permanent (always closed). Use a series resistor for the buzzer to isolate the several nFs of capacitance from the driving gate ... you never know.. Locate the XTAL and the loading 18-22pF capacitors as close as possible to the respective pins of the controller.

Due to the rectifier bridge the unit may be powered by both AC and DC power adapters. In case of DC, there is a 1.5 V voltage drop between the adapter and the input to the regulator. In case of AC the input of the regulator is about 1.4 times the RMS output of the adapter or less due to loading. If the difference between the input of the regulator and its output (+5V) is large, say 7 volts, then the power consumed by the regulator approaches 0.5 watts and it is better to use a small heatsink upon which to mount the chip (provided there is space for it) for long hours of operation in hot weather.

The AC input fuse may be selected depending on your external loads (via the DB15 connector). Other factors that influence the fuse choice are the current limiting resistor for the LED backlight of the LCD, the bridge capacitor for the charging current and the current capacity of the supplying transformer.

Step 5: SCHEMATIC

Step 6: SOFTWARE RUNNING ONBOARD

This is the sketch that makes it all happen... and 32KB is NOT enough! You can either use it unmodified, in which case I would appreciate a reference to my name, or change it at will and forget about me ;-)

This is the detailed documentation about the machine.

Summary of Commands & Expressions

“ : a nonprintable comment line

ai : attach interrupt 0 (pin D2)

ar : analog read

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

ca : analog capture in an array

cl : clears the display cno: return *Prgm[] index of line number

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

dl : delay

do : in conjunction with ‘wh’

dr : digital read any pin

dw : digital write any pin

ed : editor mode / load program from PC / renumber lines

el : EEPROM access function

end : the END statement of a program

ensb: ends subroutine

es : EEPROM access function

fl : simple moving average filter

fr : for-next loop (fr-nx)

go : jump to program step

gosb: continue execution to subroutine

gt : waits for user input

if : test condition and jump to step

io : GPIO 1-9 bits

ld : load/merge program from EEPROM

lp: : keyboard controlled loop in interactive mode

ls : list mode / send program to PC a line at a time

ml : get time

mm : display free memory

nos : converts number to string

nx : in conjunction with ‘fr’

pl : plot array cxx

pm : set pins for in or output

pr : prints a message or value or custom character

rgc : range copy command for arrays

rgs : range set command for arrays

rn : run the program in RAM

rs : soft reset

rx : receive a character via RS232

si : synchronous serial input with clock and data pins

sm : mini oscilloscope app sno : converts string to number

so : synchronous serial output with clock and data pins

sub : declares subroutine

sv : save program to EEPROM

tn : beep a tone

tx : transmit a number via RS232

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

Var1 = Var2 + Var3 : add

Var1 = Var2 – Var3 : subtract

Var1 = Var2 * Var3 : multiply

Var1 = Var2 / Var3 : divide

Var1 = Var2 ^ Var3 : integer power

Var1 = Var2 % Var3 : modulo Var1 = Var2 | Var3 : bitwise OR

Var1 = Var2 & Var3 : bitwise AND

Var1 = Var2 < Var3 : shift Var2 by Var3 bits to the left

Var1 = Var2 > Var3 : shift Var2 by Var3 bits to the right

Var1 = Var2 op1 var 3 op1 Var 4 : op1 and op2 are from the set above {+,-,/,*,%}

Var1 = ! Var2 : boolean not

Var1 = SIN Var2 : sinusoid

Var1 = Var2 : equate

Var1 = BW Var2 Var3 : bitWrite

Var1 = BR Var2 Var3 : bitRead

Step 7: Application Example - Circuit & Code

Consider first, as a proof of concept application of the DemUino unit, the following simple circuit implementing the equivalent of a pwm loop controlling the output of a power supply.
Pin D10 (pin DB9) will start at about a 2.5 volts average value or less due to loading (less than 512 count) and after a small drop thru the 220 Ohms resistor the sense of A0 at the variable resistor load will initiate a constant loop control to keep the output across the capacitor between 457 and 437 counts, that is, between 2.23 and 2.13 volts. The code below implements the software control for the circuit above and constantly prints the duty cycle - variable B, the analog filtered output – variable A and the “out of control” variable E.

00 C = 457
01 D = 437
02 pm 10 1
03 E = 0
04 B = 128
05 E = E + 1
06 pr E 12
07 pr B 21
08 aw 10 B
09 ar A0
10 A = A0
11 pr A 11
12 if A > C 15
13 if A < D 18
14 go 09
15 B = B - 1
16 if B = 0 04
17 go 07
18 B = B + 1
19 if B = 255 04
20 go 07
21 en

Step 8: Videoclip of Mini App 'sm' Running

visit my site to read the whole story and download all relevant files

http://www.sites.google.com/site/demeterart

Comments

author
jonahlake made it! (author)2015-04-09

Great

About This Instructable

3,340views

19favorites

License:

More by demeterart:DemUinoGRAPHDemUinoTVoutDemUinoPortable
Add instructable to: