bertclaes.be

This is my domain.

reprogramming the Arduino Uno R3 to be a ledwiz-compatible device

without comments

hi,

a very geeky post right now.

After a question on ArcadeZentrum’s Facebook page (https://www.facebook.com/groups/arcadezentrum) about whether or not it is possible to use an arduino uno or mega2560 as a ledwiz replacement, I got to work trying it out.

what is ledwiz? It is a usb device that works together with several arcade emulator frontends and virtual pinball frontends to light up leds and spin motors etc in response to game-events. (sold on http://groovygamegear.com) Unfortunately it is quite expensive to get to Europe.

We stumbled upon this: http://forum.arcadecontrols.com/index.php?topic=132903.0, where philip88 is using a bare atmega-32u2 chip on a breakoutboard as the ledwiz replacement. You have to download LWCloneU2.zip from there. (or here: www.bertclaes.be/ledwiz/LWCloneU2.zip) and unpack this.

I tried to replicate it, using the 16u2 present on the uno R3 (the 16u2 replaced the old 8u2).

First I had to reset the 16u2, so I could reprogram it. This is done by powering the arduino (e.g. by plugging in the usb) and shorting these two pins  here:

shorting these pins will reset the 16u2

shorting these pins will reset the 16u2

(CAREFUL: on the R3, there is already the correct transistor there (just above those pins), on R2 and R1, you have to follow this guide: http://arduino.cc/en/Hacking/DFUProgramming8U2)

Second step is to build the firmware philip88 provided with the latest LUFA-source code.

Lufa source code can be found here: http://fourwalledcubicle.com/LUFA.php
The necessary AVR chainset can be found on: http://www.atmel.com/tools/ATMELAVRTOOLCHAINFORWINDOWS.aspx?tab=documents

Be sure to put either (64bit) C:\Program Files (x86)\Atmel\AVR Tools\AVR Toolchain\bin or C:\Program Files\Atmel\AVR Tools\AVR Toolchain\bin (32 bit) in your PATH enviroment variable.

Then you have to edit the file “makefile” in the firmware directory of your unpacked LWCloneU2.zip.
You will have to change  ”LUFA_PATH    = ../../LUFA/LUFA-120730/LUFA” to the correct path where you have put the LUFA source code. I also changed “MCU          = atmega32u2″ to “MCU          = atmega16u2″ just to be sure.

After that you will have to build the new firmware for the 16u2, by running make when in the firmware directory.
If the building is successful it will say “Finished building project \”LWCloneU2\” and several files will be created inside the firmware folder.

Third thing is flashing that firmware onto the 16u2. For this you will need Atmel’s Flip application, which you can download on http://www.atmel.com/tools/flip.aspx. in flip you have to select your target device (ATmega  16U2) and the Communication Medium (USB). If flip gives the error “could not open USB device”, you haven’t correctly reset the 16u2 and have to short the two pins again. Another error i got was “atlibusbdfu.dll not found”, I resolved that one by unplugging the usb of the arduino and plugging it back in, it installed a driver at that moment.

If you have successfully selected the right target device and Communication Medium in Flip, you can load the HEX file from the firmware folder of LWCloneU2 and press the Run button at the bottom left. It takes a couple of seconds, and the firmware is now replaced.

To test the chip, you can use the testapp.exe inside the LWCloneU2.zip in the command line, but you will have to install  Microsoft Visual C++ Redistributable from here:  http://www.microsoft.com/en-us/download/details.aspx?id=30679 (32 and 64 bit just to be sure) or it will tell you “The program can’t start because MSVCR110.dll is missing from your computer.” If all goes well, both the Tx an Rx leds on the arduino board should light up and you will get “ledwiz device found, id: 4″ on the command line.

Another app to test it out is Ledblinky’s simple led test, and there you will find out that port 10 corresponds with the rx line and 11 with the tx one and port 13 with the built in test led. just don’t put it on full intensity, because the led will just go out…

Next step will be to try to use all the ports on the arduino by speaking to the mega328-chip trought the 16u2… not sure this is possible…

Some other useful links:

http://hunt.net.nz/users/darran/

http://blog.arduino.cc/category/hacks/lufa-hacks/

Written by Bert

October 12th, 2013 at 12:11 am

Posted in arcade,diy

Gif!

without comments

output_kw9Rpf

Written by Bert

July 7th, 2013 at 5:39 pm

Posted in Uncategorized

caviaspel

without comments

meer uitleg volgt nog!caviadoos

Written by Bert

May 24th, 2013 at 11:07 pm

Posted in Uncategorized

Cory Doctorow’s latest novel “Homeland” is now available as Creative Commons download.

without comments

Cory Doctorow, photo by Jonathan Worth CCbyA

Cory Doctorow, photo by Jonathan Worth CCbyA

Cory Doctorow, editor at Boing Boing, Fiction Writer, posts all his books on his website with a Creative Commons license.

I read and loved “Pirate cinema”, “Little Brother” and am now reading the sequel “Homeland”.

His works is described as Young Adult fiction, but is just really well-written fiction which deals with surveillance, piracy, crooked copyright laws and homeland security going awry.

If you’re curious about his work, you can download his latest book Homeland at http://craphound.com/homeland/download/.

Written by Bert

March 17th, 2013 at 11:15 am

Raspberry Pi Gpio as a ATmega382 (arduino chip) programmer.

without comments

In this post, I will outline how to connect a barebone ATmega382 IC (the brains of an arduino UNO) to a raspberry pi using the GPIO pins.

Needed parts:

  • This barebones arduino kit (from iprototype.be) : 7,45 € (includes a socket, a 16 Mhz Crystal, some capacitors, some resistors and a LED (which I accidentaly blew :s)) (build instructions can be found here: http://arduino.cc/en/Main/Standalone. The only difference here is that we don’t need the FTDI-usb-breakout board (which costs 14.95$) (This role is taken over by the raspberry pi). This is powered by a 9V battery.
  • A Logic Level Converter: bought this one from ebay (4,5€). (sparkfun also sells one). You will need one with at least 4 channels. This converts the gpio levels from 5v (arduino) to 3.3 v (raspberry pi), since the pi’s pins aren’t protected and 5v can destroy the pi. Remember to connect the ground of the Pi to the ground of the Arduino (this stopped me in my tracks for a while)
  • I also had an Adafruit Pi T-Cobbler and two breadboards.

Mainly I followed this guide: http://www.deanmao.com/2012/08/06/arduino-and-the-raspberry-pi/

The settings made on the raspberry pi (commenting out all the /dev/ttyAMA0) are important, or it won’t connect serially.

BTW: You can monitor the serial output of the arduino by typing “screen /dev/ttyAMA0″. The only thing is that the upload fails when there is traffic on the serial output of the arduino. It only works after a reset of the arduino.

The other main part is to never ever connect the Raspberry Pi directly to the arduino(-chip), or the Pi can be blown up. That’s where the Logic Level Converter comes in.

The connections to be made (All Trough the Logic Level Converter):

Arduino Raspberry Pi
D0 (Rx)
Tx
D1 (Tx) Rx
RST Gpio #24
Vcc 3.3 V
Be Sure to also connect the Ground of the pi directly to the ground of the Arduino, or it won't work! The RST (reset) to Gpio 24 serves to reset the arduino right before uploading the sketch.
Raspberry pi acting as an arduino sketch uploader to a barebone ATmega382 IC.

Raspberry pi acting as an arduino sketch uploader (to the left) to a barebone ATmega382 IC.(right)

The setup here is an arduino connected to a potentiometer on pin A0 and a LED on pin D9 (PWM).

When you turn the potmeter, the LED goes brighter or less bright, and eventually completely off.

</span></span>
<pre><pre>/*
Fade

*/

const int buttonPin = 2
int led = 9; // the pin that the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by

// the setup routine runs once when you press reset:
void setup() {
// declare pin 9 to be an output:
pinMode(led, OUTPUT);
Serial.begin(9600);
Serial.flush();
pinMode(buttonPin, INPUT);
}

// the loop routine runs over and over again forever:
void loop() {
// read the potmeter on A0
int sensorValue = analogRead(A0);

// read the state of the button:
buttonstate = digitalread(buttonPin);

// set the brightness of pin 9:
analogWrite(led, brightness);

// change the brightness for next time through the loop:
//brightness = half of the potoutput;
brightness = sensorValue/4;

if (buttonState == HIGH) {
Serial.println(brightness);
delay(1000);
}
else {
delay(10);
}
}

Written by Bert

March 15th, 2013 at 12:25 am

Posted in diy,raspberry pi

Raspberry pi – First experiments

without comments

Finally got ’round to documenting some of my first experiments on the raspberry pi.

i’ve done some temperature logging with an ds18b20 sensor, used a button and lit some leds.

Raspberry pi with ds18b20 sensor, button and some LEDs

Raspberry pi with ds18b20 sensor, button and some LEDs

some python code I used to blink the LED 5 times when i press the button:

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
# button is connected to gpio #23
GPIO.setup(23, GPIO.IN)
# set up GPIO output channel for the LED
GPIO.setup(18, GPIO.OUT)
# blinking function
def blink(pin):
    GPIO.output(pin,GPIO.HIGH)
    time.sleep(1)
    GPIO.output(pin,GPIO.LOW)
    time.sleep(1)
    return
while True:
    if ( GPIO.input(23) == False ):
    # blink LED 5 times
        for i in range(0,5):
        blink(18)

Reading the temperature sensor

import os
import glob
import time

os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')

base_dir = '/sys/bus/w1/devices/'
device_folder = glob.glob(base_dir + '10*')[0]
print device_folder
device_file = device_folder + '/w1_slave'

def read_temp_raw():
    f = open(device_file, 'r')
    lines = f.readlines()
    f.close()
    return lines

def read_temp():
    lines = read_temp_raw()
    while lines[0].strip()[-3:] != 'YES':
        time.sleep(0.2)
        lines = read_temp_raw()
    equals_pos = lines[1].find('t=')
    if equals_pos != -1:
        temp_string = lines[1][equals_pos+2:]
        temp_c = float(temp_string) / 1000.0
        temp_f = temp_c * 9.0 / 5.0 + 32.0
        return temp_c
    
while True:
    print read_temp()
    time.sleep(1)

The Two Combined: When you press the button, the led blinks five times and each time it probe the sensor for the current temperature:

import RPi.GPIO as GPIO  
import os
import glob
import time  

# blinking function 
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.IN)
# set up GPIO output channel  
GPIO.setup(18, GPIO.OUT)  
os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')

base_dir = '/sys/bus/w1/devices/'
device_folder = glob.glob(base_dir + '10*')[0]
print device_folder
device_file = device_folder + '/w1_slave'

def read_temp_raw():
    f = open(device_file, 'r')
    lines = f.readlines()
    f.close()
    return lines

def read_temp():
    lines = read_temp_raw()
    while lines[0].strip()[-3:] != 'YES':
        time.sleep(0.2)
        lines = read_temp_raw()
    equals_pos = lines[1].find('t=')
    if equals_pos != -1:
        temp_string = lines[1][equals_pos+2:]
        temp_c = float(temp_string) / 1000.0
        temp_f = temp_c * 9.0 / 5.0 + 32.0
        return temp_c

def blink(pin):  
        GPIO.output(pin,GPIO.HIGH)  
        time.sleep(1)  
        GPIO.output(pin,GPIO.LOW)  
        time.sleep(1)  
        return  



while True:
        if ( GPIO.input(23) == False ):
# blink GPIO17 50 times  
             for i in range(0,5):  
                 blink(18)  
                 print read_temp()
                 time.sleep(1)
   

Written by Bert

March 4th, 2013 at 12:15 am

Posted in diy,raspberry pi

Makey-Makey! joy! (+installing it on windows 8 64 bit)

without comments

I got my makey makey today!

makeymakey_kit_1024x1024

What is it?

The makers describe it as An invention kit for everyone.

“MaKey MaKey is an invention kit for the 21st century. Turn everyday objects into touchpads and combine them with the internet. It’s a simple Invention Kit for Beginners and Experts doing art, engineering, and everything inbetween”

It connects to your pc using USB (no drivers needed), and once you connect something conductive (iron, skin, banana, …) to it, the makey-makey sends keypresses to your pc.

This way you can control games, virtual pianos/samplers, … using physical/real objects.

Tested it with my four-year old, who was amazed and thrilled!

 

 (this video is of the makers, not mine)

However, if you want to access the arduino mode (it is based on an arduino), you run into some issues with windows 8. Installing the driver is a bit of a nightmare.
Luckily, the driver isn’t needed for basic experimenting.

These are the steps I follow to get it eventually working for me:

1. from Louis Davis on the arduino Forum

"I have come up with an alternative method to install the Arduino drivers on Windows 8.
 This method does not require new driver files or installation of a test signature."
1. Windows Key + R
 2. Enter shutdown.exe /r /o /f /t 00
 3. Click the "OK" button
 4. System will restart to a "Choose an option" screen
 5. Select "Troubleshoot" from "Choose an option" screen
 6. Select "Advanced options" from "Troubleshoot" screen
 7. Select "Windows Startup Settings" from "Advanced options" screen
 8. Click "Restart" button
 9. System will restart to "Advanced Boot Options" screen
 10. Select "Disable Driver Signature Enforcement"
 11. Once the system starts, install the Arduino drivers as you would on Windows 7
Steps to install driver after Driver Signature Enforcement has been disabled:
 1. Right click the Unknown Device in Device Manager
 2. Select Update Driver Software
 3. Select Browse my computer for software
 4. Click Browse button
 5. Select the Drivers folder under the location of your Arduino software installation. (Do not select the FTDI folder inside the Drivers folder)
 6. Click OK
 7. Click Next

 

next you have to do this: (from Josh Keys on Sparkfun)

1) Remove any drivers you have for the device already
2) Windows will recognize the device as an Arduino Leonardo. Update the drivers and point it to your Arduino folder.. for me /arduino01.0.3/drivers
3) Windows will install the Arduino Leonardo drivers and set it to an available comport.
4) Open your arduino IDE and the Makey Makey source file from sparkfun.
5) Make sure you have Tools->Board selected as Arduino Leonardo and also Tools->Serial Port selected to the appropriate COM Port
6) Open Device manager, get the Arduino IDE and your device manager on the same screen so you can see them both
7) Attempt to upload to the makey makey (The right arrow button)
8) Watch closely in your device manager, you will see the Arduino Leonardo disappear and briefly the Makey Makey will appear under your unknown devices implying it has no drivers. You need to click on it fast to catch it and select “Update Drivers”
9) Direct the driver selection to the location where you stored your sparkfun makey makey driver. For me this is /Documents/Arduino/hardware/MakeyMakey/driver
10) It will attempt to install the driver but most likely say it failed in the end because it didn’t have enough time
11) Wait for the Arduino IDE to fail again, then try reprogramming, possibly one more time if needed.
12) Bask in the sweet joy of seeing “Done Uploading” and enjoy your makey makey
What I believe is going on is that the device is placed in a programming mode briefly when you try to upload and is looking for a makey makey device. Sorry for the long explanation, just trying to make it easy for everyone. Let me know if this worked for anyone.

 

Then select the new Com port in the Arduino IDE and change “board’” to makey makey, and you’re all set!

 

And it finally worked!

Written by Bert

February 26th, 2013 at 10:15 pm

Posted in diy,science

SNES controller on Raspberry Pi

without comments

snes_pinout

On the left you see the pinout for the snes controller.

The connection between the GPIOs and the adapter board is as following:

CC (3.3V) white: pin 1

Ground brown: pin 6

Clock yellow: pin 19 (out)

Latch/strobe orange:  pin 23 (out)

Data 1 red : pin 7 (in)

 

install retropie: https://github.com/petrockblog/Retr

 

oPie-Setup

snesadapterassemblysingle

 

 

 

 

 

 

 

 

 

 

 

 

 

 

stereo amplifier with recycled piece from old stereo: KA2206B chip with pinouts:

KA2206B_stereo_circuit

 

 

 

 

 

 

alternative:ka2206_b

Written by Bert

February 7th, 2013 at 10:17 pm

Posted in Uncategorized

Goose: “Control, Control, Control”

without comments

Morgenavond op acht: Goose live.

Na een eerste luisterbeurt van hun nieuwste worp “Control, control, control” valt me vooral op dat ze eigenlijk een rock-groep zijn, maar ook een groot publiek aanspreken dat vooral “electronic music” beluistert. En volgens mij zouden veel van hun nummers ook werken met een “klassieke” band-opstelling (gitaar, bas, drums).

Was op hun vorige plaat het nummer “words” in hun eigen woorden “een experiment”, nu ligt de volledige plaat in die strekking, namelijk een rock/eighties electronica-richting. Which I love.

Op Spotify is er een commentary track, waarin Goose hun nieuwe plaat bespreekt. Absoluut de moeite!

Hun officieel Youtube kanaal: http://www.youtube.com/user/GooseVideoMan

Written by Bert

November 16th, 2012 at 6:36 pm

Posted in Uncategorized

De dochter van Terry Gilliam is begonnen met de kasten van haar vader uit te kuisen…

without comments

De dochter van Terry Gilliam( één van de mensen achter Monty Python, hun vaste tekenaar/animator en regisseur van films zoals 12 Monkeys, Brazil en The Imaginarium of Dr. Parnassus), is begonnen met de archieven van haar vader uit te spitten. Ze post op regelmatige basis schetsen, mockups en scenarios online op haar blog.

Zeker de moeite waard voor elke Monty Python-fan of filmliefhebber

Link: “Discovering Dad” aka delving into Terry Gilliam’s personal archive

Terry Gilliam - God

Terry Gilliam – God

Imaginarium of dr. parnassus

Imaginarium of dr. parnassus

Written by Bert

August 31st, 2012 at 10:53 pm

Posted in movie