Jan 15 2011

Playing with Arduino

I finally managed to start playing with the Arduino again – I’ve had one for a couple years, and played with it a bit as soon as I got it, but then it sat on my shelf of unfinished projects.

My collection actually has three Arduinos – one is a Freeduino with a USB interface, and the other two are intended for use on a breadboard (a Boarduino and a Bare Bones Board). For a while, I’ve been intending to use the Freeduino to program the chips on the other boards since I don’t have the right cable to connect them otherwise, but I hadn’t realized that on the arduino.cc site, they actually have instructions for doing that. In addition, they show the most minimal setup possible – which only requires an AVR, a resistor, a capacitor and a few wires if you use the internal oscillator. How much else you need depends on what you are using the Arduino for, but it certainly makes the idea of embedding the Arduino in a project more interesting since it drops the base cost under $10.

I’m currently playing with two projects – reading a SD card, and controlling a servo. The SD card is to see if a ‘dead’ card that a friend has can be accessed via SPI. I’m assuming that the typical USB readers use something other than SPI since that is a slower mode of access, and is optional on microSD cards. I’m going to set up a breadboard with a circuit to access my test card (a 32 Mb Canon card) until I get a chance to pick up a 74AHC125. The issue is that SD cards run at 3.3V, while the Arduino is at 5V. I can use a resistor divider setup to interface to SD cards, but if I want to support SDHC cards, I need to be able to meet the 10ns risetime requirements in the spec, which the 74AHC125 should manage.

The servo is going to be controlled by the Arduino via an IR remote. I have an IR receiver module that keeps things simple – feed it power and it spits out a clean signal that you can connect to the Arduino. From there you need to decode the pulses to figure out what key was pressed, and take appropriate action.

As far as the servo goes, I have never used one before, so when I hooked one up today, I wasn’t sure how difficult it was going to be. There is a sample sketch that is provided with the Arduino IDE that sweeps the servo back and forth, and I loaded it up on the Arduino and expected to see some motion. No such luck…. no motion at all. I checked with Google, and found some forums where other people were having trouble, but nothing that appeared to be my problem.

Then I did a check on my setup – power and ground hooked up? Check. Control signal? Check. Servo voltage of 5V enough to drive it? Yup. Control signal hooked up to the right Arduino pin? Uh-huh. I finally tracked the problem down to the jumper wires I had used to connect everything. I had soldered some pins to each end of some lengths of wire to make it easy to get a good connection with the stranded wire I was using – unfortunately, the control wire had a bit of extra solder on the one side. And wouldn’t you know it, that was the side that was facing the power connection. I had a short between 5V and the control signal, so as far as the servo was concerned, there was no control signal.

Once I fixed that little issue, the servo started turning back and forth as expected. Now all I have to do is remember how to decode the IR input and make it control the servo. That shouldn’t be very hard, should it? In any case, I’m going to play with it tomorrow and see where I get. I’ll try real hard to do a decent write-up if I manage to get it working – same for the SD card reader….


Dec 22 2007

Canon iP2200 – borderless printing under Linux

I picked up a Canon printer a while back – specifically a Pixma iP2200. Getting it to work properly under linux has turned out to be… somewhat challenging.

Since I run Ubuntu at home, the page at the Ubuntu wiki does a good job of getting the printer set up and working.

The only trouble is that printing photos turned out to be a problem – none of the programs I tried seemed to be able to print properly. Most of them seemed to use gutenprint (aka gimp-print) which had no driver for the iP2200 by default, and when I specified the ppd file from the Canon setup, I wound up with about 3/4 of an inch of the left side of the image on the far right of the paper. Even when I did manage to get a decent printout, I was stuck with a border on the print.

After looking into it for quite a while, I happened across a document for the iP2500 – it talked about a program (supplied with the Canon driver for the printer) called cifip2500. It supported command line options for borderless printing.

[EDIT: It turns out that if I had bothered to grab the manual Canon supplied, the information is there as well....]

Checking on my own system, I found a corresponding program called cifip2200. Running cifip2200 –help gave me this output:

Canon Inkjet Print Filter Ver.2.60 for Linux
Copyright CANON INC. 2001-2006
All Rights Reserved.

Usage: cifip2200 --gui (gui mode)
cifip2200 [switches] [file]

switches: [ --imageres 1 - 32767 ]
[ --cartridge cartridgetype ]
[ --media mediatype ]
[ --halftoning halftonetype ]
[ --quality 1 - 5 ]
[ --grayscale ]
[ --papersize size ]
[ --paperload position ]
[ --borderless ]
[ --extension 0 - 3 ]
[ --location position ]
[ --fit ]
[ --full ]
[ --percent 20 - 400 ]
[ --copies 1 - 999 ]
[ --renderintent intent ]
[ --gamma 1.4 / 1.8 /2.2 ]
[ --balance_c -50 - 50 ]
[ --balance_m -50 - 50 ]
[ --balance_y -50 - 50 ]
[ --balance_k -50 - 50 ]
[ --density -50 - 50 ]
[ --inkcartridgesettings cartridgetype ]
[ --bbox left,bottom,right,top ]

As you can see there is a –borderless option, and options to set lots of other things as well. During my first attempt, I was surprised to get lots of control characters scrolling across my screen – turns ou8-bit per color RGB/8-bit Gray/Index/8-bit per color α RGB/8-bit α Grayt that the program output is intended to be redirected to the printer (or a file). My print command looked like this:

cifip2200 –media glossypaper –papersize 4X6 –fit –picture.tif > /dev/usb/lp0

That generated a very nice picture (in this case of my dog with antlers, taken for Christmas), but didn’t work until I ran it as root, and shut down cups, since it complained that the printer was busy.

So, the full list of restrictions at the moment with this method:
1) Limited file formats based on documentation for the iP2500 version:
TIFF:Uncompressed mode only
BMP: Only 8-bit per color RGB
PPM: Only 8-bit per color RGB (binary format)
PNG: 8-bit per color RGB/8-bit Gray/Index/8-bit per color α RGB/8-bit α Gray

2) Must be run as root

3) Cups must be stopped to allow access to printer

Presumably the pstocanonij program used as the cupsFilter in the ppd file takes the postscript generated for cups, and converts it into a supported format which is then printed using cifip2200. This is supported by the fact that the bottom of the ppd file has options that match the above options very closely (except for –boderless not being present).

One thing that puzzles me is that no resolution is specified for cifip2200 – does it choose based on the quality setting, and the input file? If so, then resolution settings in the .ppd file are merely for the postscript file (and conversion to image). In any case, I have a solution for now and some more testing to do to determine how to get optimal quality. If I recall correctly, the pstocanonij code is available, so once I get everything figured out, it may be possible to add the borderless setting, either by default or as an option.

[edit: The documentation says that the default resolution is 120dpi, and gives an example of setting it to 60dpi. Seems strange considering the specs say 600-2400 dpi...]

-This is my first attempt at a post using the QTM blogging software-


May 10 2006

Getting organized

WordPress has categories… why don’t I use them?

I’ve been randomly posting comments about day to day life, alongside photos, alongside tech talk. The end result isn’t everything I’d hoped for. I’ve added categories for humdrum day to day stuff, and tech talk, and will probably add more as I go along. That means that photos will be in posts by themselves, with the only text being actually related to the photos.

On the home front, I’ve actually managed to remove one source of constant irritation – making the printer in my office let Jenn print correctly. My office is bigger than hers, so it makes sense that the printer in is mine, unfortunately I’m the geek in this relationship. My computer tends to be… unstable. I re-install software and operating systems frequently, and that means that the printer can go away randomly for unknown reasons (from her perspective, I know exactly why it went away). I’ve been using a SMC Barricade router for years, it worked, but only barely, and didn’t have support for anything fun like Dynamic DNS or SNMP. I just hadn’t been able to convince myself to spend around $100 to replace something that was working fine. Then I had the brainstorm – I could get a router that had a USB port on it to act as a print server. Since Jenn currently wasn’t able to print, it was an easy sell.

Off to the store we went, and a D-Link router came home with us. Installation was simple (expect for remembering my DSL account info), and in no time at all I’d upgrade the network to be 100Mbps throughout (the SMC was 10 Mbps), and get printing working.

Due to the location of my office in the house, running cables to anywhere else and keeping them hidden is a pain. I’ve only been able to run a single ethernet cable which limits connections since it is hooked up to a computer. Since the new router actually frees a 5-port switch as well, that lets me play around with the setup. I’m going to have to play around with positioning of the wireless access point, and see if I can improve the overall signal strength in the house. I also need to think about a computer or device by the TV since everybody needs a multimedia system, right?