True's beaked whale.jpg

Western spotted skunk

Hooded skunk

Yellow-throated Marten

Wolverine

Archive for the ‘hobbies’ Category

Another App Idea

Saturday, February 16th, 2013

Have a game of electronic (or just electric) circuits. Give the player a few parts, as many wires as needed, and a goal. The player attaches the parts until the goal is achieved. The simplest case would be a battery and a light bulb, with the goal being to light the bulb.

Other basic components can be added, resistors, caps, diodes, LEDs, etc. The game would involve only simple circuits, to make it easier and to make modeling the results from the circuits the users make easier.

App game idea

Friday, February 15th, 2013

Flip it

This game board is an array of tiles. The tiles have letters. The game play involves flipping a pair of letters, as if the two tiles can move through the screen on the axis that connects them. In any case, they move switches them. The goal is to rearrange the tiles to spell words.
Move:

cat --flip c:a--> act
dog ------------> dog

cat --flip c:d--> dat
dog ------------> cog

The game can be played different sized boards, and with boards with cutouts.
Variation 1: Have the tiles have both color and a letter, to distinguish common letters.
Variation 2: Have the tiles be two sided, so that flipping them exposes the other sides.

What is interesting about this is that it is a class of games easy to implement in the computer but which is hard or impossible to implement as a physical game. There is a whole class of variations on pen and pencil or board games that haven’t been tried because of this!

Added Google Analytics to my first app

Sunday, January 6th, 2013

Added Google Analytics to my first app!

Needed V2, PhoneGap code athttps://github.com/DoersGuild/Cordova-Android-Analytics.

App analytics

Usbpicprog

Sunday, January 8th, 2012

Built a USB PIC microcontroller programmer, the usbpicprog. I used Marcelo Maggi’s version with daughter boards for the USB and ZIF. The boards had some narrow traces–I had two small defects after eteching, and lost a few more pads soldering the components on. Small wires fixed things up and it worked first time.

The instructions aren’t very clear. The bootloader .hex gets burned using a JDM programmer using the self programmer header. Then place a jumper on the self programming header Vpp and Vdd, plug it into the USB port, run usbpicprog. These messages appear on the command line:
Bootloader Devid: 11240
Autodetected PIC ID: 0x11240

Then open the firmware .hex and burn it. The program said it completed OK. Then quit the program, remove the USB cord, and add a second jumper on the self programming header from the Clk pin to Gnd.

After this it I connected my PIC18F46K20 to the ICSP header (on a breadboard), plugged in the USB cable, and ran usbpicprog again. I opened my .hex and burned it. It said the code burned OK but gave an error for the configuration bits (like I was getting from the JDM programmers). Then I tried erasing it followed by running blank check. Both of these completed OK. I re-burned my program, and this time it worked! Configuration bits were programmed and verified!

So far I’ve only finished the main board. I made the USB board but haven’t populated it yet. I intend this mainly for ICSP programming, so I haven’t decided on whether to make the ZIF board. I do need to make an enclosure.

usbpicprog top side
usbpicprog bottom side
You can see some of the trace repairs.

JDM programmer

Sunday, January 8th, 2012

Here’s a JDM programmer for PIC microprocessors that works for me.

circuit board
circuit
docs

I used it to put the bootloader on a usbpicprog PIC programmer I am building. It also programmed my PIC18F46K20. It worked with picpgm and picprog on Linux. Picprog still gave me config bit errors.

I have tried other JDM programmers–simpler ones using no transistors like Simple JDM programmer (though with not-quite-right zeners). It worked intermittently for a while, then stopped working altogether on my PIC18F46K20.

Here’s a JDM programmer that usbpicprog recommends. I haven’t tried it.

JDM prog breadboard

Etching circuit boards

Friday, December 16th, 2011

Note to self: on my HP LaserJet6L, board traces printed from Eagle using the PS device need to be printed out at 110%.

PIC microprocessor USB

Wednesday, October 13th, 2010

How to connect a PIC microprocessor to a computer’s USB interface.

Links:
Microchip forums
a PIC USB project
a PIC USB library
Microchip forum on a Nuts ‘n Volts article on PIC USB using the SDCC compiler
PUF: PIC USB Framework
Nuts ‘n Volts HID demo Rebuilt
SDCC – Small Device C Compiler

Postscript site

Friday, August 27th, 2010

Here’s a site with a good Postscript library for drawing variable width lines.

To add a rounded end I added an arc command after the bolt function:
20 setlinewidth
newpath 0 0 moveto
0 -50 200 -150 200 0 rcurveto
currentpoint
reversepath bolt
5 0 179 arc
fill

I used two of these curves to draw a stylized pear.

L-system Iterator

Monday, January 11th, 2010

I’ve put up a web site for exploring L-system images, L-system Iterator.

Well known L-systems

The snowflake shape is only one example of the pictures that can be drawn this way.

L-systems are simple iterated drawing rules. Simple rules for turning and drawing put together in this way make quite interesting and complicated patterns. The ones shown above are well known. From the the left, the Koch snowflake, the Sierpinski triangle, a kolam-like image, and a plant-like image. On the second row, the Heighway dragon, the Hilbert curve, and another plant.

The Heighway dragon has many interesting properties–for example, it can be tiled over the plane.

Some iterated objects are fractals–the Koch snowflake, Sierpinski triangle, and Hilbert curve are famous simple fractals.

L-systems can be quite complicated. The systems modeled on my web site use a single rotation angle and only one line width. More complicated models can make surprisingly realistic plants. Prusinkiewicz and Lindenmayer (the L in L-system) have developed detailed plant models.

The web site is based on the Perl code I wrote for my Biomorph evolution/selection web site. The images are generated using Postscript to draw the L-system, and then the ImageMagick convert program to change it to a PNG image. Images are given a file name that describes the L-system, effectively caching the image. The Prototype Javascript library is used to assist in making the popup boxes.

Each L-system variant has two changes from the current L-system. Some logic is used to keep the L-system in the same family–if there’s no Y equation, one isn’t added. Existing equations are grown or shrunk but not dropped. These images can take much longer to generate than the Biomorph images, so a number of limits are placed to keep the L-system from getting too complicated or taking too much CPU time.

The hardest part of the Postscript was getting the images scaled and centered appropriately. The images can extend in any direction and some are large, others small. The centering code generates the image twice, once to find out its dimensions and then a second time scaled and centered. Here’s the code to record the dimensions of each part of the image. It gets called before each stroke operation.

/max_path {
gsave initmatrix pathbbox grestore


ur_y false eq { /ur_y exch store } { dup ur_y gt { /ur_y exch store } { pop } ifelse } ifelse
ur_x false eq { /ur_x exch store } { dup ur_x gt { /ur_x exch store } { pop } ifelse } ifelse
ll_y false eq { /ll_y exch store } { dup ll_y lt { /ll_y exch store } { pop } ifelse } ifelse
ll_x false eq { /ll_x exch store } { dup ll_x lt { /ll_x exch store } { pop } ifelse } ifelse
} def

The ‘initmatrix’ command is required to reset things because of all the rotation operations.

The code for the site is linked on the L-system iterator home page.

Update: Added color variation as an option. And a reverse direction primitive.

Also, the code now runs under mod_perl.

Note for mod_perl users–mod_perl 2.0 has no way of handling alarms. select() doesn’t work either as a way of timing out pipes. The only usable method is prepending commands with ‘ulimit -t secs’ and letting the shell limit the system process.

To make the split color B&W images I used these ImageMagick commands:
convert -size 150x150 tile:color.png tile:bw.png ../temp/mask.png -composite split.png
using a half black, half white split image as the mask.

Then added the split line using:
convert -size 150x150 -fill white -stroke black -draw "line 0,0 150,150" split.png split_line.png

PIC servo pot controlled

Saturday, November 21st, 2009

Third PIC program, this one moves a hobby servo motor using a 10kΩ pot. The pot is read using the A/D converter function on the PIC. The four high bits of the value are used to control the servo to sixteen positions over its range. Two more bits could easily be added to give finer control.

It has a light that flips on/off with each jump of the servo, another light that is always on and a third that switches the servo on/off.

PIC12F683 servo motor movie:

Here are the code files: p12_servo2.asm and p12_servo2.hex.

It is wired as shown in the video.