Sunday, 22 July 2012

LED toy details

Parts list

Part number
Unit cost
ATMega368P -16PU (32K 28pin)

74HC595 shift register

10mm red LED

10mm green LED

0.1" Pitch Single Row header strip (16 per module)

0.1" Pitch Single interconnect (8 per module)

2.2uf supply decoupling (1 per module)

100uF Main decoupling

FTDI USB-Serial converter 5V TTL level

16Mhz X-tal


100nf decoupling


10K ohm 250mw (cold-starter)



9600 8 n 1

All command are intended for use over a terminal with a person typing, and are human readable in ASCII. Hence a 10ms character delay is needed if pasting commands into Hyperterminal (Teraterm) or driving via application. A Windows Powershell sample test application to be attached. Commands are terminated by a carriage-return pair (CR-LF.) I.e. enter + ctrl-enter. All input is echoed back to the sender making verification of link easier. Additional information for debugging is attached to each activity, so command responses are not currently machine process-able. Commands generally follow a letter + value pair, all integer parameter values are in the range 0..255.
Set brightness 0=off, to 255 max (maximum brightness is actually around 90, and depends on the PWM configuration of the controller.)

Set brightness from 0..90
Send value2 to shift register value1. Sets the bitmask in register
Set lamp to state . Sets an individual LED behavior.
0=led off
1=led on
2=blinking (on/off)
3=blinking (off-on)
Set blink rate , default=50 (50 is around 500ms)
Query device state, prints out some debug counters and clears the internal debug counters:
1 – number of protocol errors???
2 - number of buffer overflows???
3 – buffer high-watermark

It is only possible to set LED behaviors with the S command, blinking mode 3 blinks an LED in opposing phase to mode2.

Powershell Code

function Send-SerialMessage
param($port, $msg)
       $msgCR = "$msg`r`n"
       $msgCR[0..$msgCR.length]| %{
       write-verbose $msgCR

function Read-SerialTrace
       $string = $port.ReadExisting()
       while ($string -ne "") { $string| %{write-verbose "$portName: $_"};start-sleep -m 50 ;$string = $port.ReadExisting() }


# [System.IO.Ports.SerialPort]::getportnames()
       #$portName = "COM4"
       $port= new-Object System.IO.Ports.SerialPort $portName,9600,None,8,one
       write-verbose "Open port $portName"
       Write-Progress -activity "Job : $label" -status "Open Display serial port $portName" -percentcomplete 50
       $port.Handshake = "None"
       $port.ReadTimeout = 500

       # turn all leds off, from the back forwards
       Send-SerialMessage $port "B:3"    # lower brightness
       Send-SerialMessage $port "R:50"   # rate 50
       0..4 | % {
              Send-SerialMessage $port "L:$_,0"

And that's about it :-)

Thursday, 19 July 2012

Raspberry Python with no X

Continues the trail of using Debian squeeze on the pi without a graphical display and browser.
Since we have not gotten the gpio utility yet, let's do that now
cd /tmp
And next for the install steps go to Gordon's web site .

sudo pip install RPi.GPIO
This will grab the Python gpio library, next we need to get it doing something more interresting in Python.
To speed things up, you may want to set up the root user:
sudo passwd root
and then login again as root this time

The GPIO library sample code can be found in the magpi.
The fun result of all this is the game of ladder, which combines hardware and software with your skill at both :

Here is a video of everything on a breadboard stuck to the prototyping area on my Pi. (The prototyping base is available from SK Pang)

Wednesday, 11 July 2012

Get Debian onto WM8650 Android Tablet

Toxic forums :
Other tablet Android ROMS (Uberoid) :
Preparing a micro-SD with Debian:

Installing curl, installing python packages
sudo apt-get install curl 
Next, you want pip, so you can pull python packages down without a browser
sudo curl | sudo python
cd pip 
sudo pip install
pip search rpi
it will list:
RPi.GPIO                  - A module to control Raspberry Pi GPIO channels
iterpipes                 - Shell pipelines in Python using shell-like syntax
iscorpio.plonepm          - A Plone way to manage project
django-paintstore         - A Django app that integrates jQuery ColorPicker
                            with the Django admin.
PlayerPiano               - Amazes your friends by running Python doctests in
                            a fake interactive shell.
collective.z3cform.colorpicker - colorpicker widget for z3c.form
tarpipe-python            - A Python interface to the TarPipe API
collective.js.colorpicker - UNKNOWN
iscorpio.themes.redmaple  - iscorpio readmaple Plone 3 theme
iterpipes3                - A library for running shell pipelines using shell-
                            like syntax
js.jquery_colorpicker     - fanstatic jQuery color picker
js.jqueryui_syronex_colorpicker - Fanstatic packaging of syronex_colorpicker

Monday, 9 July 2012

Raspberry Pi week 2 ttyS0

Hook a serial terminal to the Raspberry Pi is the goal this week. I still have tonnes to learn about how to run gnu-linux, and still to install the Python interpreter. But this will be much easier with a screen, for which I might be using a cheap Android tablet. I find getting the kids away from the telly so I can plug the Raspberry Pi into it is a bit impossible. Found this post on how to connect a max232 to the Pi : . Note this requires a 3.3 volt maxim chip.

To get going, I open cmdline.txt in notepad
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait
Not sure what the runes here mean though, so connected it using my max 232 and it works when connected to Tera-Term. Don't bother with hyperterminal, use tera-term or on linux, minicom.
Next we want to use the tablet as a terminal, so I have wired the tablet dongle a new serial port via a hole drilled into the dongle, the port works, because when I connect it to me teraterm, it keeps prompting me to login, (every 60 seconds) so this is not what I want, it looks like the default console on the tabled is wired to that port already. I mean like, what's the point. This probably means I need to root the tablet, it has version 2.2 on it, loaded under then brand name Wondermedia 8650. So I'll need to find an old rom on the web, and then work out how to flash this unit.

Saturday, 7 July 2012

Raspberry Pi week 1

Because of the need to run cables all over the lounge, plugging my Raspberry Pi into the antiquated telly is a bit of a bother still. So I have not fired it up again the last few evenings, first trick is to get a power supply. I want to be running it off a regulated boost supply from rechargeable batteries. This might prove all more difficult than it needs to be. I need another 30 quid in the budget, although a digital monitor would have made things move along a lot faster actually.

I have a 128x64 graphical LCD, which should give me 128/6=21 x 64/6=10 (21x10 characters) albeit super tiny using a 5x5 font. I have found a VT102 arduino app written using AVR libraries (not sketches) so it should be trivial to get a basic display using a serial terminal on the ttys0 :
This hack includes keyboard, which I do not want/need actually, will just have to reconfigure the keyboard to come from stdin I suspect. On second thoughts, the 5x5 font does not do upper and lowercase very well, which might be difficult to view, anyway I will have fun trying. Pictured below is a standard 8x5 font.
 (This display is available at Hobbytronics, and looks easier to drive and prettier than mine)

Portable power is still a problem, the boost regulator I have seems to have a design flaw, and the trimmer pot for ref voltage adjust has burned it's track and gone open-circuit at one end. Consequently the reg generates 14 volts from a 3.5v supply instead of the intended 5v. I get the impression I'll need a crowbar fuse. The shed in the back yard is a bit hot and time is limited tonight, so repair will have to wait, besides I need to modify the booster a bit since it's power-up surge is a bit too hungry. I'm still not set on what batteries to use either, nor on what solar charger setup I will use to top them up yet. I do know the charger will be having 3 solar panels, each about the size of my outspread hand though.

Wednesday, 4 July 2012

Raspberry Pi continued

Since the goal is to get started using GPIO, and we are going to be handling the board quite a lot, some hardening of the board is required. My Pi needs a home, it needs a case.

I spotted this one on SK Pang, being used as a simple LED project using Python. Knowing how to get the GPIO under control is going to be critical if we are going to accomplish our goal.

Part 2
Bootup script
Using Nano to edit files
Installing Python package

Tired of Typing Super-User Do?
So on my debian squeeze distro, su is short for sudo (not sure why sudo is too much to type, when frankly my gray-matter has enough trouble remembering just one command.) The answer is revealed by typing
man su
su -l
Which log you on as a specific user you supply. But you will loose your environment and current folder, to keep them, the parameter you want is -m.  NOTE: the -l (letter 'ell' is case sensitive.) Type su -l again to log out of the current shell. For more hints, google is your friend. Just remember to log out of the secure shall afterwards when you do not needed it, it may prevent unfortunate data loss. you have backed up your SD card?
Boot-up script on the Debian distro Raspberry
Apart from the arm setting up the graphics chip, the booting or run-leveling of start-up and shutdown processes is controlled easiest using the bum (Boot up Manager) utility. Boot and shutdown are somewhat analagous to service dependencies in Windows, but with a lot more fine-grained control and perhaps power for end-users.
Using Nano
Haha, gotcha there, I still have to use Nano more than just a few times to really get a good impression of things the help doc that abound on the web are not making bleeding obvious allready. Since my goal is to get up and running quickly with the minimum of "curve", I will rather keep quiet untill I can add real value.

Installing Python
Easy as pie. [TODO:] gotcha there, this will have to appear in the next edition of my Pi exploration. Also up in the next edition will be acessing GPIO.