Skip to content

Welcome Disqus Comments!

2012 January 15
tags: ,
by Tedb0t

I just implemented Disqus comments for the entire blog, which should make things a bit nicer, since there’s been a lot of discussion on some posts.  Let me know what you think!

Wireless Positioning & Location Awareness: An Overview

2011 December 21

For one of my major projects I’m tasked with figuring out how we can locate mobile wireless devices within a limited location, and it seems a lot of other people I’ve talked to are in the process of figuring out the same thing, so here’s an overview of what I’ve learned so far. read more…

Using the RN-XV WiFi Module as a Remote Switch

2011 December 20
by Tedb0t

It’s been a struggle, but I finally figured out how to use a Roving Networks RN-XV WiFi module as a remote switch.  It’s not hard now that I know how it works, but figuring out was quite difficult, as the manual is apparently incorrect and the firmware it shipped with was causing problems.  Read on for the solution!

Hardware

Simple! Here’s all you need:

  • An XBee breakout board (so you can plug it into your breadboard)
  • An XBee Explorer (not necessary with ad-hoc mode, but I had one around so this tutorial will use it)
  • 3.3V regulator (ONLY—the module has a 10% tolerance, so anything beyond that will either not work or damage the module).
  • 10µF and 0.1µF capacitors for good measure (clean power is especially important when using radio devices)
  • Power and Ground (Pins 1 and 10, the top and bottom pins on the left side of the module)
  • An LED connected to pin 9.  In practice you’d want to put a current-limiting resistor on it, i.e. 220 ohms, but for a quick test it won’t matter.  The module only drives 8mA on this pin.
  • That’s it!
Setup
Although the module has an ad-hoc setup mode, where it broadcasts its own ad-hoc wifi network that you connect to with your computer, I found it faster to just plug it in directly to my computer using a serial adapter such as the XBee Explorer.  When you connect with ad-hoc mode, you talk to the module over telnet, when you use direct serial, you use a serial terminal such as CoolTerm, which the following instructions will use.
With your module plugged into USB, open up the port in CoolTerm.  You may see some data from the unit or a status message (it’s ok if you don’t).  Type $$$ (without hitting return) to enter command mode.  Now you can setup the module’s wifi settings (hit return after each command):
set wlan phrase <your wpa password>
set wlan ssid <your ssid>
save
reboot

 

The module will power-cycle and the green status LED will start blinking.  After 5-10 seconds it should start blinking more slowly, which indicates that it has successfully connected to your WiFi network.  If your terminal session is still open, you should see a status message that indicates its success and its IP address (which you’ll need soon).
Now we need to update the firmware.  Luckily, they made this extremely easy!  Just do this:
ftp u
And it will take care of the rest—connecting to the Roving Networks FTP server, downloading the newest firmware image and ‘installing’ it.
Once that’s done, you can transfer your module to your breadboard.  The rest of the work happens over telnet, so make sure your computer and module are connecting to the same WiFi network!  When the module is on your board and it’s joined your network, open a shell on your computer and do:
telnet <module's ip address> 2000
You should see a ‘*HELLO*’ message.  Congratulations!  Now you can talk to your breadboarded module from anywhere!  To switch the LED on and off, first set the I/O direction mask:
set sys mask 0x21f2
This adds GPIO (General-Purpose Input/Output) Pin 1 (hex 0×2) to the default mask, setting it as an output.  To switch it high, do:
set sys output 2 2
Similarly, to switch it low:
set sys output 0 2
And that’s it!  You can now, for instance, have a web server connect directly to that port and issue those commands dynamically to control your hardware remotely.  Try hooking up a relay to switch a house light!

References

Getting Started Developing with the WiMM One

2011 December 16
tags: ,
by Tedb0t
We just received a Developer Preview of the new WiMM One wearable touchscreen device, and dove into developing for it.  It runs Android so you have to get the Android SDK set up.  Here are our notes so far.
  1. Install Eclipse.  I had the “Galileo” version which I found out the hard way isn’t supported, so I downloaded the newest as of writing (“Indigo”).
  2. Install the Android SDK.
  3. Install the Android Developer Tools (ADT) plugin for Eclipse.
  4. Download the WiMM Android Add-On (make a free developer account first to get it).
  5. Put the WiMM Add-On folder in the add-ons folder in the Android SDK.
  6. Run the Android SDK Manager from Eclipse > Window.
  7. Select and install Android 2.1 (API 7) and the Android SDK Platform Tools.
  8. Make a WiMM Android Virtual Device with SD card 2 GiB and resolution 160×160.
  9. You can now make new projects that target the WiMM One Add-On.

Building and Running on the Emulator

  1. Open a terminal at [your-android-sdk]/add-ons/addon_wimm_one_7/tools and run ./emu.
  2. Wait for the emulator to boot up (it takes a minute).
  3. Hit “Run” in Eclipse.
    1. If you get an expired certificate error, look here.
  4. If you’re prompted to choose a device, choose the emulator.

Building and Running on the Device

  1. On your WiMM, go to Settings > Advanced and turn on “Allow USB debugging”
  2. Plug in your WiMM.
  3. Open a terminal at addon_wimm_one_7/tools and run ./android update adb.
  4. Go to addon_wimm_one_7/platform-tools and run ./adb kill-server and ./adb start-server.
  5. Now run ./adb devices and you should see your hardware device listed as well as any running emulators.
  6. Now when you run your app from Eclipse, you can choose your hardware device!

Getting started with the RN-XV WiFi Module & Node.js

2011 December 7

The RN-XV WiFi module is a nifty little WiFi module designed to fit the same pinout as an XBee, so it’s intended to be a drop-in replacement.

Tonight I whipped up a little test of the module to get a joystick to talk to a Node.js server over WiFi.  I attached +3V power and ground to the module (pins 1 and 10, respectively), pin 2 (TX) to Arduino digital pin 0 (RX), and pin 1 (RX) to Arduino digital pin 1 (TX).  That’s all the hardware setup you need.

I used this WiFly library to handle the connection.  All it does is talk to the WiFly module over serial and send control commands, so the library abstracts that a bit.  Here’s the Arduino sketch I built: read more…

PQLabs Multitouch Screen Not Working in Windows 7? Enable It

2011 November 21
by Tedb0t

I just discovered that, in order to get a PQLabs Multitouch screen in Windows 7 to properly report multitouch events (to Adobe AIR/Flash, in my case), one must go to Settings > Pen and Touch, go to the Touch tab, and check “Enable multi-touch gestures and inking.”  Thanks, Windows. >:-|


Controlling Deluge Auto-Management and File Priorities via Python

2011 November 15
by Tedb0t

Today I was working away from my home file server which runs the BitTorrent server Deluge.  My Deluge Web UI stopped working for some reason (and it never worked that well in the first place) and I really needed to start a torrent at home.  Deluge has an “Auto Managed” feature that’s enabled by default, but since I seed a lot of torrents, it actually prevents a new torrent from starting to download automatically, so I have to disable that and the resume the torrent after adding it.  Thankfully Deluge has a Python client interface we can use to write our own scripts.

Here’s an example script that adds a URL from an argument with auto_managed turned off:

#!/usr/bin/env python
# encoding: utf-8
"""
DelugeEasyAdd

Starts a new Deluge torrent from a URL.

Created by Ted Hayes.

"""

import urllib, os, sys, re
# Import the client module
from deluge.ui.client import client
# Import the reactor module from Twisted - this is for our mainloop
from twisted.internet import reactor

# Set up the logger to print out errors
from deluge.log import setupLogger
setupLogger()

# Connect to a daemon running on the localhost
# We get a Deferred object from this method and we use this to know if and when
# the connection succeeded or failed.
d = client.connect()

PRIO_NORMAL = 1
PRIO_MAX = 5

torrentURL = sys.argv[1]
# btjunkie URLs use 'download.torrent' as the filename, get a better one
if re.search("btjunkie", torrentURL):
    filename = re.findall("torrent\/(.*?)\/", torrentURL)[0]
else:
    filename = os.path.basename(torrentURL)

print "Using filename: %s" % filename

def addTorrent():
    client.core.add_torrent_url(torrentURL, '/home/daleth/Downloads/'+filename, {'auto_managed':False}).addCallback(added)

def added(s):
    print "Added status: ",s
    #client.core.resume_torrent()
    disconnect()

# We create a callback function to be called upon a successful connection
def on_connect_success(result):
    print "Connection was successful!"
    addTorrent()

def disconnect():
    print "disconnecting"
    client.disconnect()
    reactor.stop()

# We add the callback to the Deferred object we got from connect()
d.addCallback(on_connect_success)

# We create another callback function to be called when an error is encountered
def on_connect_fail(result):
    print "Connection failed!"
    print "result:", result

# We add the callback (in this case it's an errback, for error)
d.addErrback(on_connect_fail)

# Run the twisted main loop to make everything go
reactor.run()

I still have to figure out how to then automatically resume the torrent.

Here are some helpful links:

UIClient Documentation

UIClient Example 

 

 

 

Tools for Disassembly and Reverse Engineering

2011 November 12
by Tedb0t

Following Trammell Hudson’s excellent introductory workshop on assembly and reverse engineering, here are my notes on what I had to do to get things up and running.

I was doing this on my Ubuntu 10.04 Linode instance, and we were targetting ARM processors, so first I had to install the appropriate gcc toolchain.  I didn’t have add-apt-repository, so I had to install python-software properties first.  The last install is to get libc (stdio, etc).

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:linaro-maintainers/toolchain
sudo apt-get install gcc-4.5-arm-linux-gnueabi
sudo apt-get install libc6-armel-cross libc6-dev-armel-cross

Then I used these commands for compiling, disassembling and looking for interesting strings:

arm-linux-gnueabi-gcc-4.5 -O3 -c helloWorld.c
arm-linux-gnueabi-objdump -D helloWorld.o | less
strings -t x helloWorld.o

Eagle Error: old version of device set is not present in the new version of this device set.

2011 November 10
by Tedb0t

Today I was attempting to paste parts of an Eagle schematic I found online into a new schematic, and I was getting the following error message:

Package variant PTH1 in the old version of device set RESISTOR is not present in the new version of this device set.

This is caused by a library in the original schematic having some different package definition than the library in the new schematic.  The fix is easy: In the original schematic, go to Library > Update All.  Then you can copy and paste without the error!

Arduino Serial.print sends numbers instead of letters

2011 October 11
tags: ,
by Tedb0t

Recently I experienced a somewhat baffling, unexpected problem. I was using a line like:

Serial.println('test');

And getting a series of numbers like 25536 instead of the expected text. It turned out the problem was just the use of the ‘ instead of a “. Sigh.

AVRdude Verification Error Solution

2011 October 11
by Tedb0t

If you’ve been getting an Arduino error like this:

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0007
         0xff != 0x7f
avrdude: verification error; content mismatch

It may be as simple a fix as moving your USB cable from a hub directly to your computer—that fixed it for me!

More information: I had also been getting errors like this from avrdude:

avrdude: 2 retries during SPI command

PureData Workshop this Sunday in Brooklyn

2011 October 11
by Tedb0t

For anyone in the NYC area, I’m running a workshop on PureData, the free, open-source sound synthesis software. Sign up here! Here’s the description:

Bored with ordinary instruments? Can’t figure out how to get just the right sound you’re looking for? Ever wanted to build your own virtual instruments from scratch, or make a physical interface for your music? Wondering how sound and synthesizers work in the first place?

PureData is a free, open-source tool for making noise that encourages experimentation and rapid prototyping, and it’s fun, too! I’ll walk you through the basics of both PureData and sound itself to enable you to explore a whole new field of sonic possibilities. No programming knowledge required—I’ll tailor the material to your experience levels, so come check it out and bring your ideas and questions!

Come check it out!

Deconspectrum

2011 August 28


We humans tend to treat our perceptions as holistic—as seeing things as things, instead of as an accumulation of parts, details and features. This is the great abstracting power of the 3-pound neural network in our heads, and is a major differentiating characteristic from other computational paradigms. read more…

Bash snippet: Remove text from filenames

2011 August 26
by Tedb0t

Today I had a directory full of mp3 files for a Flash game that each had the text “woman01″ in them.  Since I wanted to just keep the rest of the filename, I put together this Bash one-liner:

for f in *; do mv $f ${f/woman01/}; done

Simple and effective!  Bash has a surprising array of string-manipulation capabilities, which I learned about here.

Programming an ATMega With No Bootloader Using the USBtinyISP

2011 August 14

The title says it all: for my “Deconspectrum” installation, I am burning a program onto a bunch of ATMega328 chips using a USBtinyISP (In-System Programmer).  At first I was running into a perplexing problem: the program was running much slower than it should have been.  I could tell immediately because I had a short POST (Power-On Self Test) at the beginning of the program that flashes the LED Red-Green-Blue, and it was going far slower than it should have been. read more…

The Ultimate Cheap DIY Media Center Device

2011 August 10
by Tedb0t

You might be in the same situation I was in: a big collection of music and other media on one computer, but the big speakers/TV are in another room—how best to get that media out there?  Here’s a DIY solution that will cost you less than $200 (and a little elbow grease) and still get you more features than any other prepackaged device can possibly offer. read more…

Arduino: Compensating for a Logarithmic Curve

2011 August 4
by Tedb0t

Did you know that the scale of acoustic pitches is logarithmic?  This means that, even though we perceive the scale of notes as increasing or decreasing linearly, the actual frequencies are doubling or halving with each octave.

In my Deconspectrum installation, I’m mapping acoustic frequencies to color.  If I mapped them linearly, the colors would change very rapidly in the low frequencies, and then stop changing as obviously as the pitch gets higher.  This is not the effect you would expect, since you want each pitch to be represented by another color.

The solution is to map frequency to color (hue) logarithmically instead of linearly.  Thankfully, AVR C gives us a handy base-10 log function:

int hueFreq = log10(frequency - FREQ_MIN) * hueScale;

If we graph this, we get:

The ‘y’ scale is hue and the ‘x’ is frequency.  You can see that, with each octave, the change in color progresses more naturally, mimicking our linear perception of pitch.

Here’s the same graph with a logarithmic frequency axis:

The dotted line is the log10 function without the cutoff, so you can see the “simulated” linearity.

Handy, and highly effective!

Arduino: Controlling an RGB LED by Hue

2011 August 4
by Tedb0t

Hooking up an RGB LED to an Arduino isn’t hard by itself, but controlling it can be—if you know what color you want to display, how do you know what R, G and B values that is?

Here’s some Arduino code, adapted and simplified from Kasper Kamperman, that I am using in my Deconspectrum art installation to do just that: read more…

From Eagle to Printed Circuit Board—Easy Tips

2011 July 27
by Tedb0t

If you’ve never gotten a printed circuit board (PCB) manufactured, it’s pretty daunting at first, but well worth the trouble—it’s exciting to get a stack of fresh, neat circuit boards of your own design in the mail, and a whole lot more fun than hand-soldering perfboard!

I use EAGLE to design my schematics and boards, and now that I’ve gotten used to its seemingly inscrutable interface, it’s quite fast and effective.  Here are some tips I’ve learned: read more…

SoundcloudScraper: Download all of an artist’s Soundcloud tracks automatically

2011 July 19
by Tedb0t

Today I was listening to a great Soundcloud artist with 22 tracks, all available to freely download.  Since I didn’t see an option to download them all en masse, I wrote up a nifty script to do it, then added a bunch of features to make it shiny.

Download the SoundcloudScraper zip file here:  soundcloudScraper_v1  To use, you’ll need Python; I looked into making it a standalone binary but I’m afraid that’ll have to wait for another time.  Open up a terminal and go to the directory the script is in, and type:

./soundcloudScraper.py artistname

This will automatically download all the available tracks by that artist, meaning tracks with a ‘Download’ button.  You can also specify multiple artists:

./soundcloudScraper.py artist1 artist2 artist3

This script uses the fantastic Animated Terminal Progress Bar module by Nadia Alramli!  If you find any bugs or get some use out of the script, leave a comment! Enjoy!