![]() |
| Merry Christmas from our house to your's! |
Some posts about my random techo projects at home - some Arduino, Atari, 3D printing, RPi, etc ....
Friday, December 23, 2016
3D Christmas 2016 - The Print
The model described in my last post was printed and nickel plated by my friend who suggested the idea for the ornament. He also asked me to put a 3/4" hole in the bottom - this makes it possible to rest the ornament on a tree branch with a tree light poking inside. Here's the final outcome:
Sunday, December 11, 2016
3D Christmas 2016 - The Model
This year's Christmas ornament is a 3D model of our house. My 3D-printing friend at church suggested the idea and offered to print and plate it. That's cool. In this post I describe creating this 3D model in SketchUp. I put up an OBJ file over at Thingiverse.
Finally, I usually use Solid Inspector in SketchUp to fix it, but always have to run my models through this cloud repair tool. I stumbled upon Windows 10's new 3D Builder - it did a great job of making the model manifold.
I've used SketchUp occasionally for several years and decided to start there because it's easy to enter accurate dimensions. I stumbled upon the match photo feature, which is exactly what I needed but didn't know it. This feature allowed me to import photos of my house and match the coordinate system to the picture by determining the origin, rotation, scale, and perspective. I followed the directions here. Then I traced the outline with the line tool starting with major lines on the principal axes. I drew some construction lines to allow me to locate the apex and trace the A-frame of the roof. I simplified the overhang because the print will be quite small. I'm not going for accurate construction drawings here, just something that looks nice and representative. This picture shows my starting photo with the nearly finished model:
I used the long gutter and siding seams to align the vanishing point lines, which set the coordinate system perspective and rotation. The origin is moved to the far corner of the garage because it seemed easy to put there. Once the model is started, more photos of the other corners are brought in. For each photo, I set the vanishing lines, origin, and then the scale to visually match up the existing model with the photo as best I can. Here's the other front corner:
I drew the chimney after completing all four sides of the house. The windows and doors are last. Since it's not possible to print detailed lattices in the windows because they are too small, I was advised to put in what I could with about an 0.8mm thickness. The windows are recessed and the shutters are extruded out. I did end up putting the panel details on the garage doors. I don't include any of the utility features, for example the power meter or chimney cover used for keeping the critters out.
Finally, I usually use Solid Inspector in SketchUp to fix it, but always have to run my models through this cloud repair tool. I stumbled upon Windows 10's new 3D Builder - it did a great job of making the model manifold.
Saturday, November 5, 2016
Calculator Games
Last year over Tvacation, my nephew was grounded from his XBox. I broke out my girl's TI 84-Plus CSE calculator and learned TI Calculator BASIC. Reminded me of my Tandy PC-4 pocket computer that I programmed in BASIC to multiply matrices (Algebra II homework). I wrote four games worth mentioning:
- BOUNCE - a single player Pong/Breakout type game
- INVADERS - a Space Invaders variant
- SCROLL - a driving game (it scrolls vertically, thus the name)
- SNAKE - eat Pi's to grow, but don't run into yourself
The BASIC listings and upload files are over on GitHub. I guess the old adage "any port in a storm" goes without saying - the nephew ate these up for lack of his fancy 3D FPS.
Here's a game play video of all four programs.
Notes
Bounce
The BOUNCE game is pretty basic. The ball only moves at 45 degree angles, and the angle is determined by where it is bounced off the paddle. Thus, it's possible to get it in an infinite loop and to rack up the score. The primary reason to write this game was training in TI Calculator BASIC.
Invaders
This is a fun one - a single row of space aliens animated by alternating "M" and "W" characters. There's no way in BASIC to look at the screen memory, so I had to keep track of the aliens in an array.
Scroll
Unimaginative name. I wrote the beginnings of a game like this in 6th grade on an Atari 400, but didn't understand enough to add the car logic. In this version, it took a little experimentation, but decided to only do collision detection on the nose of the car. Again, I had to keep track of the location of the track in an array. TI Calculator BASIC has list data types convenient for that.
Snake
The list datatype was extremely important for this game. In fact, I think it made it easy to program because the list length can grow just as the snake grows. There are two lists used to keep track of the row and column locations of each segment of the snake. When the snake head eats a PI symbol, one segment is added to the snake. Without lists, one would need to preallocate arrays and keep track of the tail. Maybe not that big of a deal, but there's a certain elegance in the TI Calculator BASIC solution.
Monday, October 31, 2016
Pumpkin Pi
Pumpkin with PI symbol and Arduino-controlled Neopixel LEDs
Neopixels are individually addressable RGB LEDs. I bought an 8x1 array to try them out and decided they would make a good pumpkin light. Add an Arduino Nano, 4 AA's, a capacitor and a resistor and voila. Turns out you could see them from the street quite well.
The capacitor and resistor were added per Adafruit's Best Practices page for Neopixels.
Friday, August 26, 2016
Vintage Atari CX22 Trak-Ball with USB interface.
The trackball, or Trak-Ball as Atari dubbed it, was a fascinating controller to me in the arcades. There was a mystery at work under the controller panel transferring the rolling motion of the ball to the character on the screen. They were too expensive to own for my Atari computer, so I played Centipede (not very well) at the arcade. I didn't really understand how trackballs worked until college. That's when I found out the mouse was just an upside down trackball with the optical encoder wheels and all. I recently picked up an Atari CX22 Trak-Ball at a vintage gaming show and turned it into a USB device. I plan on taking it to work to control my Mac just for the sake of irony. In the meantime, it's great for a mean game of Missile Command on the emulator.
Thank-you Dan Kramer for designing this awesome piece of hardware!
Atari made a few Trak-Ball models: the CX22 (for the 2600 and 8-bits) in the classic brown and beige colors, the CX80 with the mid-80's XL motif, and the CX53 for the 5200. The original CX22 only worked as a joystick simulator and a revision included a selector switch to allow true trackball control. This true trackball mode can be used to play Missile Command on the 8-bit computers by pressing control-T. Totally different and much closer to the arcade experience than the joystick. I put some links to trackball history and documentation at the bottom of this post - make sure you check out the concept drawings at the online Atari museum in the last link.
Thanks for stopping by!
Thank-you Dan Kramer for designing this awesome piece of hardware!
Atari made a few Trak-Ball models: the CX22 (for the 2600 and 8-bits) in the classic brown and beige colors, the CX80 with the mid-80's XL motif, and the CX53 for the 5200. The original CX22 only worked as a joystick simulator and a revision included a selector switch to allow true trackball control. This true trackball mode can be used to play Missile Command on the 8-bit computers by pressing control-T. Totally different and much closer to the arcade experience than the joystick. I put some links to trackball history and documentation at the bottom of this post - make sure you check out the concept drawings at the online Atari museum in the last link.
Decoding the Trak-Ball
The CX22 service manual gives a nice theory of operation for the trackball. The ball spins two rollers which rotate optical encoder wheels in each axis. The encoders have two signals in quadrature phase (like a sine and a cosine waves) used to determine the speed and direction. The direction is determine by finding which signal leads the other. To have a joystick mode, the CX22 does this with discrete CMOS logic chips. The quadrature square waves are fed to a CD4013B D-type Flip Flop - one signal acts as clock and the other data. When the data lags the clock, a logic 1 is latched in at the falling clock edge. When the data leads, the result is logic 0. In trackball mode, the clock and direction out are selected by the switch and sent to the controller port. In joystick mode, the clock triggers a one-shot 4538B chip configured for a 9-ms pulse width. The one-shot output gates the direction signal sent to the output. Thus, there's at least one 9-ms joystick direction pulse that is extended for each encoder wheel clock tick occurring before the 9-ms is up.USB Device
Using the HID-Project library for the Arduino, I configured my Leonardo board to act like a USB mouse. The code is incredibly simple because the direction decoding is already performed by the CX22 hardware. (The Arduino could certainly decode the signals if the clocks were sent directly - here's a tutorial with multiple software approaches to quadrature decoding. Good to keep in your back pocket for building a spinner controller.) The code polls the clock signals and sends incremental mouse movements over USB to the OS. It also polls the digital input for the fire button(s) and sends mouse clicks. For some visual feedback, I blink the on board LED every time motion is detected.
Here's my sketch:
#include <HID-Project.h>
#include <HID-Settings.h>
const int XINC = 6;
const int YINC = 6;
int xdir = LOW;
int xmot = LOW;
int ydir = LOW;
int ymot = LOW;
void setup() {
// put your setup code here, to run once:
for (int i=0; i<6; i++) {
pinMode(i,INPUT_PULLUP);
}
pinMode(13,OUTPUT);
Mouse.begin();
}
void loop() {
// poll the xmot and ymot looking for state changes
// when state change, increment mouse movement
int xold=xmot;
int yold=ymot;
ydir=digitalRead(0)*2-1;
ymot=digitalRead(1);
xdir=digitalRead(2)*2-1;
xmot=digitalRead(3);
if (xmot!=xold) {
Mouse.move(xdir*XINC,0);
digitalWrite(13,1);
}
if (ymot!=yold) {
Mouse.move(0,ydir*YINC);
digitalWrite(13,1);
}
int f=!digitalRead(4);
if (f) {
Mouse.press();
digitalWrite(13,1);
} else {
Mouse.release();
digitalWrite(13,0);
}
//Serial.println(x);
}
#include <HID-Settings.h>
const int XINC = 6;
const int YINC = 6;
int xdir = LOW;
int xmot = LOW;
int ydir = LOW;
int ymot = LOW;
void setup() {
// put your setup code here, to run once:
for (int i=0; i<6; i++) {
pinMode(i,INPUT_PULLUP);
}
pinMode(13,OUTPUT);
Mouse.begin();
}
void loop() {
// poll the xmot and ymot looking for state changes
// when state change, increment mouse movement
int xold=xmot;
int yold=ymot;
ydir=digitalRead(0)*2-1;
ymot=digitalRead(1);
xdir=digitalRead(2)*2-1;
xmot=digitalRead(3);
if (xmot!=xold) {
Mouse.move(xdir*XINC,0);
digitalWrite(13,1);
}
if (ymot!=yold) {
Mouse.move(0,ydir*YINC);
digitalWrite(13,1);
}
int f=!digitalRead(4);
if (f) {
Mouse.press();
digitalWrite(13,1);
} else {
Mouse.release();
digitalWrite(13,0);
}
//Serial.println(x);
}
Thanks for stopping by!
Trackball Links
Owner's Manual: http://www.trailingedge.com/atari8/AtariTrakBallom.pdf
Really cool concept drawings: http://www.atarimuseum.com/videogames/consoles/2600/trakconcept.html
Tuesday, August 9, 2016
Playing Kaboom! on an Atari 8-bit Emulator with Real Paddle Controllers
I'm on a quest to educate the Boy about the history of video games with the hope he'll want to learn something about computers other than downloading iOS apps or playing FPS's on Xbox. Potentiometer controllers (paddles) showed up on the earliest home systems like the Odyssey and Pong. We got to play an original Magnavox Odyssey at a Smithsonian event. That was an interesting system with multiple pot's for each player - one for moving the player and one for adding "english" for directing a shot. At another show, we played an original coin-op Pong machine - those controls are sensitive!
I'm pretty happy with the results. My code uses the full range of the paddles, butI've read the 2600 used only a limit motion range. I need to ask the 8-bit community about that. I need to trim it down to act more like the real hardware which uses only about 2/3 of the range. (Thanks to the guys over on the Atari 8-bit Computers FB group!)
I picked up a pair of Atari-style Gemini paddles for $5 at that gaming show and hooked them up to my Windows machine using an Arduino Leonardo running a gamepad HID library. The boy was intrigued because they are so different from an Xbox controller or a mouse; and I got him to play Kaboom! on an Atari 800XL emulator. Definitely different from Breakout or Pong:
Tell me that's not at least as fun as many casual iOS games. I really like the reveal of the 1812 Overture as one advances in the game. Other paddle games are discussed over at AtariAge.
My $5 deal:
My $5 deal:
Technical Details
The paddles are 1-megaohm linear potentiometers tied to 5V. To measure the resistance, the original Atari system would measure how long it took to charge a capacitor. It actually counted the number of TV scan lines. The higher the resistance, the longer it took. This was a straightforward way to do it with a purely digital readout system and the 8-bits have a custom POKEY chip that does the work. (The POKEY designer Doug Neubauer tells a couple entertaining stories.) This is called an analog-to-digital converter by many - it is, but not in the sense of modern ADC's. It's a current-measuring ADC (with the current source being the potentiometer series resistance biased by +5V) vs. a typical voltage-measuring ADC. Many modern microcontrollers have voltage ADC's built in, so my implementation uses a voltage divider instead of an RC charging circuit. Despite some erroneous circuit diagrams found on the interwebs, the pot in the paddle has one end floating. Thus, the readout circuit needs an external drop resistor to make up the voltage divider. Here's my circuit:
The microcontoller is a Leonardo because it runs an ATmega 32u4 microcontroller with an on board USB interface. Two ADC channels are used to read the voltages from the dividers. Digital inputs D0 and D1 are used to read the trigger buttons. The software relies on the HID Project. I started using the absolute mouse device, but switched to the 16-bit axes on the gamepad device. My method isn't new; however, I added some integer math to compute the resistance value from the voltage that I haven't seen elsewhere. Otherwise, the reading will be highly nonlinear. Atari went out of their way to use linear potentiometers in the design (vs. logarithmic which are used in audio volume controls), so it's only fitting to keep the system linear. The code also includes a startup calibration to find the minimum voltage when the paddle is turned completely counter-clockwise.
Here's my sketch:
#include <HID-Project.h>
#include <HID-Settings.h>
int oldx;
int x=0;
int calx=0;
int oldy;
int y=0;
int caly=0;
int readpaddle(int p) {
int a=0;
for (int x=0; x<32; x++) {
a+=analogRead(p);
}
return a;
}
int paddlemap(int a) {
return 65535-uint32_t(uint32_t(1072693248)/uint32_t(a));
}
void setup() {
// put your setup code here, to run once:
pinMode(0,INPUT_PULLUP);
pinMode(1,INPUT_PULLUP);
delay(2000);
Serial.begin(9600);
Serial.println("calibrating");
for (int i=0; i<10; i++) {
int temp=paddlemap(readpaddle(0));
calx=max(temp,calx);
Serial.println(calx);
temp=paddlemap(readpaddle(1));
caly=max(temp,caly);
Serial.println(caly); }
Gamepad.begin();
}
void loop() {
boolean changed=false;
oldx=x;
oldy=y;
int tempx=paddlemap(readpaddle(0));
tempx=max(tempx,calx);
x=map(tempx,calx,32767,-32768,32767);
delay(7); //need to clear residual from ADC and limit update rate
int tempy=paddlemap(readpaddle(1));
tempy=max(tempy,caly);
y=map(tempy,caly,32767,-32768,32767);
if (abs(x-oldx)>63 || abs(y-oldy)>63){
changed=true;
}
Gamepad.releaseAll();
if (!digitalRead(0)){
Gamepad.press(1);
changed=true;
}
if (!digitalRead(1)){
Gamepad.press(2);
changed=true;
}
if (changed){
Gamepad.xAxis(x);
Gamepad.yAxis(y);
Gamepad.write();
}
//Serial.println(x);
}
I'm pretty happy with the results. My code uses the full range of the paddles, but
Thursday, July 21, 2016
Summer Retro Game and Movie List - An Abridged Armada Chronology
While more cerebral types publish summer reading lists (you know who you are), I'm opting for an easier way out. Summer is half over and there's not enough time to squeeze in all that reading if you haven't started yet! Instead I offer a list of retro video games and 80's and 90's movies based on a list found in Ernst Cline's Armada, which was compiled by the protagonist's lost father under the heading of "Chronology." In the story, the Chronology is provided as circumstantial evidence pointing to a vast government-entertainment complex conspiracy to covertly prepare and train the populace to fight in a coming alien invasion. Sounds plausible. But even if you don't subscribe, that's no excuse to avoid this historical retrospective in the last few remaining weeks of summer.
I'm updating the list with my thoughts, experiences and links as I work my way through it. If you play along, please leave me a comment on the list page.
I'm updating the list with my thoughts, experiences and links as I work my way through it. If you play along, please leave me a comment on the list page.
Subscribe to:
Posts (Atom)







