Archive for January, 2009

Noise Puking Benitos — The devil in the details.

Wednesday, January 28th, 2009

A few people including myself have had some issues with their Benito’s where the programmer sets one light on constantly and the next thing that happens is the the mac will go comatose (or to the beach if you like spinney ball metaphores). Not a very confidence inspiring behavior. To make matters worse the behavior was completely inconsistent.

For the last batch of programmers I forced myself to upgrade the original source code to the current version of Dean Camera’s LUFA library (the library formerly known as MyUSB) and went about trying to figure it out. The first thing I “fixed” in the new code was to make the leds ping pong when the device was enumerating so I could tell the difference between enumeration and data.

Previously I had thought that the issue was at the host somewhere between the deadended rxtx library used by the arduino ide to talk to the devices and the equally deadended libusb used to find them.

Once I made this work I was seeing that in some cases the RX LED was constantly on (to verify this I swapped the led pins). Then I realized that when the arduino isn’t actually talking to the system the rx pin on the benito is tristated in other words it “float”s and whatever noise comes along is then data to be transmitted. In addition to leaving the lights on this flood of data gets sent to the usb subsystem to be read by the serial device when it it opened (I haven’t verified this completely but it certainly explains what the spinney ball is about).

There are a couple of things that could be done here. You could not transmit data unless dtr was present. Or you could enable the internal pullup which solves the issue. I filed this as a bug with Dean and the next rev of the USBtoSerial demo will have a pullup on the tx pin as well.

I suppose I need to show people how to upgrade their benitos. The new firmware and source are attached. (http://www.dorkbotpdx.org/files/Benito7g0109.tgz) If you have a troublesome Benito I will be happy to upgrade it at any of the upcoming meetings.

Embedding Quartz Compositions in Cocoa Applications.

Wednesday, January 28th, 2009

Yesterday I asked Greg Borenstein what he was using to do his really cool Arduino presentations to show the hardware alongside the code being used to program it. His answer suprised me. It was a simple Quartz Composition run using Composer. He used it to flip the views put out by his web cam so that they made sense from the users viewpoint. I have been seeing a lot of people using quartz composer to do testing and other cool graphic things.

An example I have been working with takes a camera that I had on a pole with a motor that moved it around like a periscope. The camera is sideways so the view has to be rotated. I did this by hand using Core Image this summer using filters and transforms but wanted to do it in Quartz Composer. The composition looks like this.

And the resulting image like this.

On the way down to UCSF last month I experimented with some code that embeds a quartz composition into an application.

You can download it from our svn repository ( https://ssl.tempusdictum.com/pubsvn/trunks/QuartzSnap/ add this url to your x-code scm repositories) and play with it. It builds into a standalone application.

Most all of the work is done by adding your composition to the xcode project and then placing a Quartz Composer View (QCView) from the objects library in your window using Interface builder. The only code I needed to make my application usable (to take pictures) was the action to save the view to a file.

——————————– CameraViewController.h —————————-


#import <Cocoa/Cocoa.h>
#import <Quartz/Quartz.h>

@interface CameraViewController : NSObject {

IBOutlet NSButton *SnapButton;
IBOutlet QCView *CameraView;
NSImage    *TheSnapShot;
NSData *theSnapData;

}
- (IBAction)DoSnapShot:(id)sender;
@end

——————————– CameraViewController.m —————————-


#import "CameraViewController.h"

@implementation CameraViewController

- (IBAction)DoSnapShot:(id)sender {
   theSnapData = [[CameraView snapshotImage] TIFFRepresentation];
   int runResult;
   NSSavePanel *sp = [NSSavePanel savePanel];
   [sp setCanSelectHiddenExtension:YES];
   [sp setRequiredFileType:@"tif"];
   runResult = [sp runModalForDirectory:nil file:nil];
   if (runResult == NSOKButton) {
     if (![theSnapData writeToFile:[sp filename] atomically:YES])
       NSLog(@”Well that didn’t work!”);
   }
}

@end

And that is pretty much it.

Compared to the several pages of code it took to get the same results using Core Image this was a snap.

January Induction Followup.

Monday, January 26th, 2009

I recently fixed some issues with the benito arduino programmer and upgraded it to the latest version of the LUFA library. I hadnt noticed that there was a miss match between the .inf and the library supplied descriptors. My appoligies to the two xp users. As this is the only batch with this issue I will reprogram the boards that I currently have. In the mean time this can be fixed by changing the following line in the current driver file from:

[ManufName]
%Modem3% = Modem3, USB\VID_03EB&PID_204B

To:

[ManufName]
%Modem3% = Modem3, USB\VID_03EB&PID_2044


Or copy the following into a new file.

;  Windows MyUSB USB to Serial Setup File
; Copyright (c) 2000 Microsoft Corporation

[Version]
Signature="$Windows NT$"
Class=Ports
ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
Provider=%COMPANY%
LayoutFile=layout.inf
DriverVer=06/06/2006,1.0.0.0

[Manufacturer]
%MFGNAME% = ManufName

[DestinationDirs]
DefaultDestDir=12

[ManufName]
%Modem3% = Modem3, USB\VID_03EB&PID_2044

;------------------------------------------------------------------------------
;  Windows 2000/XP Sections
;------------------------------------------------------------------------------

[Modem3.nt]
CopyFiles=USBModemCopyFileSection
AddReg=Modem3.nt.AddReg

[USBModemCopyFileSection]
usbser.sys,,,0x20

[Modem3.nt.AddReg]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,usbser.sys
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"

[Modem3.nt.Services]
AddService=usbser, 0x00000002, DriverService

[DriverService]
DisplayName=%SERVICE%
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\usbser.sys

;------------------------------------------------------------------------------
;  String Definitions
;------------------------------------------------------------------------------

[Strings]
COMPANY="Tempus Dictum, Inc"
MFGNAME="Donald Delmar Davis"
Modem3="USB Virtual Serial Port"
SERVICE="USB Virtual Serial Port CDC Driver"

Arduino Cult Induciton: Second Session Feb 8th.

Friday, January 23rd, 2009

The Second session of the induction is getting close to 20 prepayed people so if you havent rsvpd please do so soon (either bring check/money to the meeting monday or paypal $25 to cult /at/ tempusdictum.com)

Don.

PS There will be another induction in late april.

3 Ways to 3 Volts.

Wednesday, January 21st, 2009

copied from: http://blog.tempusdictum.com/index.php/don/electronics/3-ways-to-3-volts
I have a few devices that I need to interface to either the benito or another avr board that run at 3.3v. one is an ethernet interface, one is a bluetooth modem and then there are the x-bees.

One Way: Simple Voltage Divider.

When looking for interface examples for the xbee I found a site that started out with a circuit from maxstream and then once everything was working tried a resistor based voltage divider. This is how I got my first set of x-bees running via the ftdi chips.

One thing that this circuit didn’t do for me was to provide a decent pull-down for the reset. The 2 transistors on the right of this circuit are an attempt to do just that.

Another Way: Run everything at 3.3v

If you look at the datasheet for the atmega168 you will find the following diagram.

Looking at this you can see that 16mhz may or may not be in the operating range at 3.3v. But if you drop the crystal down to 8mhz you are good for sure. You may have to change a few things but it is doable.

The Ever Illusive Third: Buffers.

The idea of adding another layer at each intervace between boards can have you asking for some Tzatziki and falafel to go with the PITA. There are buffers which are designed specifcally for this. Many of the odd, many of them expensive. But there are also many families of buffer which are “tolerant” of a range of voltages outside of their supply. One of the buffers I checked out was the 74abt126 which is a tri state buffer. (I was looking at that because with the tristate buffers you can actually do a two way buffer by selecting the direction). I am not entirely certain that the 5v recieve side is kosher with these.

The other buffers I am looking at with 5v tolerant i/o are the 74lvc125 and 74lvc126. These are 3.6v native parts with 5v “tolerant” io.

Since I ordered the wrong series of parts last group order I will have to wait a week to check this out.

See Also.

3 ways to 3 volts

Wednesday, January 21st, 2009

I have a few devices that I need to interface to either the benito or another avr board that run at 3.3v. one is an ethernet interface, one is a bluetooth modem and then there are the x-bees.

One Way: Simple Voltage Divider.

When looking for interface examples for the xbee I found a site that started out with a circuit from maxstream and then once everything was working tried a resistor based voltage divider. This is how I got my first set of x-bees running via the ftdi chips.

One thing that this circuit didn’t do for me was to provide a decent pull-down for the reset. The 2 transistors on the right of this circuit are an attempt to do just that.

Another Way: Run everything at 3.3v

If you look at the datasheet for the atmega168 you will find the following diagram.

Looking at this you can see that 16mhz may or may not be in the operating range at 3.3v. But if you drop the crystal down to 8mhz you are good for sure. You may have to change a few things but it is doable.

The Ever Illusive Third: Buffers.

The idea of adding another layer at each interface between boards can have you asking for some Tzatziki and falafel to go with the PITA. There are buffers which are designed specifically for this. Many of the odd, many of them expensive. But there are also many families of buffer which are “tolerant” of a range of voltages outside of their supply. One of the buffers I checked out was the 74abt126 which is a tri state buffer. (I was looking at that because with the tristate buffers you can actually do a two way buffer by selecting the direction). I am not entirely certain that the 5v receive side is kosher with these.

The other buffers I am looking at with 5v tolerant i/o are the 74lvc125 and 74lvc126. These are 3.6v native parts with 5v “tolerant” io.

Since I ordered the wrong series of parts last group order I will have to wait a week to check this out.

See Also.

Glen's "Cellular Automata Video Synthesizer"

Thursday, January 8th, 2009

http://blog.tempusdictum.com/index.php/gepr/uncategorized/cellular-automata-video-synthesizer