Raspberry Pi – Only Red (Power) LED is on – Raspberry Pi does not boot

Have you had this problem? You bought a new Raspberry Pi, flashed a new Image from http://www.raspberrypi.org/downloads (2013-09-25-wheezy-raspbian.zip) and powered in on. What I see is that it does not work. The red power LED is on only and very low light from the ACT LED which does not do anything.
Luckily I had lots of different RPis and SD cards available to dertermine the fault.I tried all combinations with these µ/SD cards and adapters. Here the results:

  • San Disk SD card works on RPi China + RPi UK
  • The Samsung and the SanDisk µSD cards with the San Disk adapter works with both the Raspberry Pis
  • The Samsung and the SanDisk µSD cards with the Samsung adapter works with the Raspberry Pi made in China but it does NOT work with the Raspberry made in UK.

Raspberry Pis with SD+µSD Cards+Adapter

This is a very interesting thing I have not experienced before. I thought all adapters were the same and there could not be any differnce, but there is.

So before declaring your fresh and new Raspberry Pi as faulty check it with another SD card and try to avoid adapters for testing purposes.

7 Segment Display with 74HC595 Shift Register and Raspberry Pi

This project shows how to use the Raspberry Pi to drive a 7 Segment Display with the help of a 74HC595 chip.

Parts used in this project:

  • Breadboard
  • Wiring cables (Male-Male, Female-Male)
  • 7 Segement display (it actually has 8 segments because of the dot)
  • 74HC595 Chip
  • Raspberry Pi Revision 2
  • some Python code

Here is a schematic made with fritzing of the project when it is ready. Here a link to download the 7-segment-display with 74HC595 and Raspberry Pi fritzing project.

7-Segment-Display_Steckplatine

the interresting thing here is the 74HC595 Chip. It takes some time to understand what it does. I think that the video from Kevin Darrah describes it fast and easy.

Here is the Python code: rpi_7_segment_74hc595

#!/usr/bin/python

import RPi.GPIO as GPIO
import time

#Data Pins needed on the RPi
DATAIN=17 #DS
LATCH=27  #STCP
CLOCK=22  #SHCP
CLEAR=25  #MR Low
OE=11     #Output Enable Low

#inter character sleep
icsleep=0.06 

#defining all the single LEDs
led1=0x80 #10000000
led2=0x40 #01000000
led3=0x20 #00100000
led4=0x10 #00010000
led5=0x08 #00001000
led6=0x04 #00000100
led7=0x02 #00000010
led8=0x01 #00000001

#definition of all writeable letters and numbers
letter={"0":0xFC,
        "1":0x30,
        "2":0xDA,
        "3":0x7A,
        "4":0x36,
        "5":0x6E,
        "6":0xEE,
        "7":0x38,
        "8":0xFE,
        "9":0x3E,
        "a":0xBE,
        "b":0xE6,
        "c":0xCC,
        "d":0xF2,
        "e":0xCE,
        "f":0x8E,
        "g":0x7E,
        "h":0xB6,
        "i":0x30,
        "j":0xF0,
        "l":0xC4,
        "n":0xBC,
        "o":0xFC,
        "p":0x9E,
        "s":0x6E,
        "t":0x38,
        "u":0xF4,
        "x":0xB4,
        "y":0x76,
        "z":0xDE
}

#loading function sequence
load1=0x06 #00000110
load2=0x22 #00100010
load3=0x60 #01100000
load4=0xC0 #11000000
load5=0x82 #10000010
load6=0x12 #00010010
load7=0x18 #00011000
load8=0x0C #00001100

#up-down loading function sequence
ud1=led8
ud2=led2
ud3=led1+led3
ud4=led7
ud5=led6+led4
ud6=led5

#left-right loading function sequence
lr1=led1+led6
lr2=led2+led5+led7
lr3=led3+led4
lr4=led8

#rotational loading function sequence
rot1=led2+led5
rot2=led1+led6+led3+led4+led7

#putting all segments of the sequences in a list
letterrange=[]
hexrange=[]
for value in letter.values():
    letterrange.append(value)
for value in letter.values():
    if value != "g":
        hexrange.append(value)
loadrange=[load1,load2,load3,load4,load5,load6,load7,load8]
udrange=[ud1,ud2,ud3,ud4,ud5,ud6]
ledrange=[led1,led2,led3,led4,led5,led6,led7,led8]
lrrange=[lr1,lr2,lr3,lr4]
rotrange=[rot1,rot2]
spinrange=[led1,led2,led3,led4,led5,led6]

#GPIO definition
def setup():
    GPIO.setmode(GPIO.BCM)
    GPIO.cleanup()
    GPIO.setup(DATAIN,GPIO.OUT)
    GPIO.setup(CLOCK,GPIO.OUT)
    GPIO.setup(LATCH,GPIO.OUT)
    GPIO.setup(CLEAR,GPIO.OUT)
    GPIO.setup(OE,GPIO.OUT)

    GPIO.output(LATCH,False) #Latch is used to output the saved data
    GPIO.output(CLEAR,True)  #Clear must always be true. False clears registers
    GPIO.output(OE,False)    #Output Enable speaks for itself. Must be False to display
    GPIO.output(CLOCK,False) #Used to shift the value of DATAIN to the register
    GPIO.output(DATAIN,False)#Databit to be shifted into the register 

    #Clean up GPIO, set display to no character
def cleanup():
    #Set all leds to off
    writenumber(0)
    #writeout stored in character
    writeout()
    #writeout "nothing"
    writeout()
    time.sleep(0.7)
    GPIO.cleanup()

#shifts in a bit (but does not write it yet)
def shift(input):
   if input == 1:
       input=True
   else:
       input=False

   GPIO.output(DATAIN,input)
   GPIO.output(CLOCK,GPIO.HIGH)
   GPIO.output(CLOCK,GPIO.LOW)
   GPIO.output(DATAIN,GPIO.LOW)

#writes the stored data from register out to pins
def writeout():
   #Display LEDs
   GPIO.output(LATCH,GPIO.HIGH)
   #needed to read characters. otherwise the characters would be display to fast after each other
   time.sleep(icsleep)
   GPIO.output(LATCH,GPIO.LOW)

#writes a character to the register
def writenumber(number):
    for x in range(0,8):
        shift((number>>x)%2)

#writes a range of character to the display        
def writerange(range):
    for x in range:
        writenumber(x)
        writeout()

#additive and following substractive writeout of a range of characters
def writeaddrange(range):
    character=0
    for x in range:
        character+=x
        writenumber(character)
        writeout()
    for x in range:
        character-=x
        writenumber(character)
        writeout()

#additive and following substractive writeout with reversed call of a range of characters
def writeaddremrange(range):
    character=0
    for x in range:
        character+=x
        writenumber(character)
        writeout()
    for x in range:
        character-=x
        writenumber(character)
        writeout()
    for x in reversed(range):
        character+=x
        writenumber(character)
        writeout()
    for x in reversed(range):
        character-=x
        writenumber(character)
        writeout()

#additive and following reversed substractive writeout of characters        
def writeaddbackrange(range):
    character=0
    for x in range:
        character+=x
        writenumber(character)
        writeout()
    for x in reversed(range):
        character-=x
        writenumber(character)
        writeout()

#chained XORed and reversed XORed writeout of characters
def writexorrange(range):
    #close the chain to have no interrupts while displaying
    character=range[0]&range[-1]
    for x in range:
        character^=x
        writenumber(character)
        writeout()
    for x in range:
        character^=x
        writenumber(character)
        writeout()
    for x in reversed(range):
        character^=x
        writenumber(character)
        writeout()
    for x in reversed(range):
        character^=x
        writenumber(character)
        writeout()

print("####Setup####")
setup()

#Tryout of most ranges and displayfunctions
try:
    print("####Write Stuff####")
    while True:
        writerange(letterrange)
        writerange(hexrange)
        writerange(loadrange)
        writeaddremrange(udrange)
        writexorrange(loadrange)
        writexorrange(udrange)
        writexorrange(ledrange)
        writexorrange(lrrange)
        writexorrange(rotrange)
        writexorrange(spinrange)
        writeaddrange(ledrange) 
        writeaddbackrange(ledrange)
#Wait for KeyboardInterrupt or SystemExit (called by kill or others)
except (KeyboardInterrupt, SystemExit):
    print("Exit...")

finally:
    cleanup()

Raspberry Pi drives a 7 Segment Display with the help of a 74HC595.

Have fun driving your 7 Segment display with the Raspberry Pi.

ZXX Font & OCR – some thoughts

It is in all media that Edward Snowden has revealed the surveillance activities of the NSA. This act of spionage can be criticised as an break-in into the privacy of every person’s life.

Therefore Sang Mun has released a Font called ZXX which makes it more difficult for automated optical character recognition (OCR) programs to detect letters. Here a german article from the austrian online newspaper derstandard.at

I have looked on this font with great interrest and think that this could be a great way to avoid automated spionage from others.

When you watch the ZXX Type Secimen Video you will be surprised by how easy you can confuse OCR programs. The most interessting thing for me were the XED and the noise font. It just adds either a thin cross (X) or optimised “random” pixels to the letters where humans are still able to read the text pretty fast. This is not the case for the Camo Font. More to that later.

So thinking of this, why is a human being able to read the Xed and noised text, while computers can’t? The answer was simple for me. (this might not be scientifically proven). The human eye takes a look at a picture and tries to recognise something. If not it focuses or “zooms in and out” to remember the patterns we have all learned in early school years. Moreover we do not only have one point of view, we have two of them. There are two eyes with maybe two different focuspoints which makes us able to see letters behind all that camouflaging stuff. A very easy trick to solve CAPTCHAs and to read the ZXX font is to unfocus the stuff you want to read. It looks blurry. There was a program which I had in mind which can do this for me.

Simple as that I tried it – with success. Have a look at your own.

I took a sample picture from ZXX and cut off the stuff on the side (for better reading)

ZXX sample

 I uploaded this onlineocr.net

This is the result:

ABCDEFGHIJKLMNOPUPST
UVWXYZabcdefghijklmn
opqrstuvwxyz00123450
789%!?@#/&*().,:$£
+x÷±-=-_"°154afyX%%[]
ABCDEFGHIJKLMNOPUPST
UVWXYZabcdefghijklmn
opqrstuvwxyz00123450
789%!?@#/&*().,:$
+x÷±-=-_"1@4afyflfl?[]
IMBODffiGliffiktMNOPRPSt
UVWOWEabedgeflijklms
owettAvw*gzelS/2@xtga
U;flZYXWVUTSPUPONML
KJIHGEEDCBAzyxwvutsr
ciponmIkjihgfedcbagg8
765432101 ?ABCDEFGHI3,
KEMNOPR•STUVWXYZabcd
afghilkImnopqrstwvwx
wii01.2345878gRIA22DE 
NW N■v1.• • • 
• • wawl0K461ISdielP•E*
4.*AP101010104.: 
twintootra21224Rea,a

As you can see only some of the characters are found be the program.

If I blur the image all the confusing stuff (for the OCR Software) is removed or partly removed, so that the matches are higher than before. See for yourself.

Blurred image:

zxx-blurred

 

and this is the result.

ABCDEFGHIJKLIANOPOPST
UVWXYZabcdefqhijklmn
opqrstuvwxyz00123450
789%!?@0/&*(),,:WO
+x+t-m-_".0:42fOgq]
ABCDEFGHIJKLMNOPOPST
UVWXYZabcdefqh1jklmn
opqrstuvwxyz00123450
789%"?"/"().,:$EV
+x-ft-m-_".11:saiyfint[]
IMOCIVIIIJK5M4GPOOSI
UVIORYilabcdsfeit311Imm
opqrstswesszt62234Vd
Re914ZYKWVUTSPOPONML
KJIHGFEDCBAzyxwvutsr
qponmlkjihgfedcba998
70543210!?ABCDEFGHIJ
KLMNOPOPSTUVWXYZebcd
•ighijklionopqrstuvws
yz00123450789? IABCDE
FGHIJKLMNOPOPSTUVWXY
Zabcdefighijklmnopqrs
tuvwxyz0012345078931

I think this is a remarkable difference to the original image.

I also have some words to the two other fonts.

The False font can be easily trained as I have been trained by the video. One needs to search for a big letter, but does not take its information. Instead you search for another letter within the smallest rectangle you can fit around the big letter you just found. (to explain it technically 😉 )

The Camo font is a real hard one. If you simply read the Camo alphabet it is easy to see the letters, because you expect the very next letter. And with this image in mind you procet the vectors over the image you see where it is easy to recognise. Some sort of this is also used in examples of optical illusion. What I have in mind is the Kanizsa triangle.

Kanizsa_triangle.svg

Image from the Wikimedia Commons

You as human see a white triangle where really is none. You just have some points or “suggestions” of vectors and your brain finishes them to form this triangle.