Saturday, August 24, 2019

Power-Up


I paid $3 for this drill at the local garage sale. The battery was dead (as you can expect from several years old NiCd battery) but the motor was OK.  I decided to fix it with an external power supply. The battery output was 14.4 V. It is hard to find any supply with such a voltage, but 12 V sources are ubiquitous.   Inside e-waste bin at my job I found one with 6 A current output. That should be enough to power the drill, right? So I removed the battery from the unit, dissembled terminals from it, attached barrel jack to terminals, and assembled unit back. Now time to test. Alas, the result of the test was not exactly   I expected.  Indeed drill worked, but only if I pull the trigger slowly. Make it fast and behavior of drill becomes strange. Its chack starts to rotate and then immediately stops. On the clip below you can see it with the voltmeter showing voltage applied to the drill.
This clip shows that voltage drops to zero unless I squeeze the trigger slow enough. Is there an explanation for such an effect? Could it be fixed?
I believe I have answers to both these questions. Two things influence the drill start. First, there is an inrush current, which is the maximal instantaneous input current drawn by an electric motor when it first turned on. While under normal load this drill needs 3-4 A of electrical current, at the moment of start it may draw twice or even thrice more. So for some time (till motor reaches stable rotation), current may exceed  6A for which supply is rated. And now the second thing comes into the picture:  power supply is sophisticated enough to protect itself from the overload. As a result of that protection, it shuts itself down. As soon trigger is released, voltage is restored. 
But why does it work if the trigger is pulled slowly? Modern drill trigger is a variable speed device. It not just switch but power regulator. If it is engaged partially only partial voltage is applied to the motor, so inrush current is not that big. While rotor speed increases created by the rotation back EMF (electromagnetic force) limits the current through the motor winding.
Here is the remedy to the fast start problem: limit electrical current at the initial stage. To test this statement I tried resistor with 0.3 Ohm resistance and 10 Watt power rate. Indeed fast start effect is gone but  I did not like how it worked. Under the normal load, when current reaches 3 A, more than one volt dropped on the resistor and less than eleven volts applied to the drill.  And the resistor becomes hot.
So It tried another approach: inductor.  Inductor possesses big resistance to variable current but small resistance to direct current. Means, during start when current jumps from zero, the inductance will limit current but it will have no effect during stable rotation. Here is Toroid Inductor I bought on Amazon (several pieces for $2 all).  You can see it next to a penny  (for size comparison).

This inductor is rated for 100 micro Henry of inductance and 6 A of current. Current is OK, sure,  but what about inductance? The test shows it works as needed: drill could be turned on fast enough and no voltage drops when the drill is up to the speed.


Some more details regarding this project and how I build it you can find on Instructables site .

Saturday, May 25, 2019

Lock & Unlock

This post again about Ford Taurus 2006 (as of today ~171000 miles). While officially it is still mine, my son mostly drives it nowadays. On one of his trips (either Berkeley or maybe Oakland), there was an unsuccessful attempt to burglarize the parked car. Nothing was stolen but the car door lock was irreparably broken.  At the photo below you can see it.

So there was the need to replace this lock. On eBay, I have found a lock service package which suites our car. That package allows assembling the lock so existing car key will fit. Assembling the lock and replacing the old lock with the new one was relatively an easy task but as usual with some caveats. On the photo below, you can see the kit and all the tools needed for the job.


Apart from the kit, there was a need in the next set:
  • Vernier Caliper (to measure existing key for recreating lock steps codes). Given the fact that steps differences are more than 1 mm, a good ruler may work as well.
  • The hook custom made out of inexpensive awl.
  • Philipps screwdriver.
  • Ratchet with 7mm socket and extender.
Assembling the lock and fitting the key was straightforward. I just need to follow enclosed instruction.
The package is universal: not all packed elements were needed, but instruction gives enough details to understand what to use and what not to for your model. 
Next step was replacing the old lock with the new one. First  I have found this video. As all videos from 1aauto.com it is excellent and all that you need to remove and install back Ford Taurus door panel. 

 

But, alas, that video tells nothing about lock replacement. So I have found another one:



While it is not well polished as the first,  it contains some very valuable tips. Based on that video I may describe next steps to replace the door look (assuming door panel already removed):

1. Unscrew with 7mm sockets two bolts holding the door handle. That will make handle loose but not enough to take out the lock.
2. The door handle has a metal rod attached. The bottom end of this rod is secured with plastic clip to the door wall. On the snapshot below (I made it out of the second video)  you can see that clip (left bottom part of the picture) opened up. To open it up I used the metal hook, which I showed early. 

After that, I moved the handle out far enough to get access to the lock.

3. Then there was the need to remove e-clip from the back of the lock cylinder and take out lock lever.
4. The last step was to move to the left metal clip, which secures lock on the door. The snapshot below ( from the second video: many thanks to its creator) shows exactly where it is.


The new lock installation is straightforward:
  1. Putting new lock into the place.
  2. Securing it with the metal clip.
  3. Putting the lock lever back to the lock cylinder.
  4. Securing lever on the cylinder with e-clip (either from the kit or old one).
  5.  Screwing back two bolts into the door handle.
  6. Putting the bottom end of the rod into the plastic clip and closing the clip.
  7. Installing the back door panel.

Job is done! 


Saturday, April 27, 2019

Steel and Plywood

I found this HDD rack in an e-waste bin. It supposed to be sent away and eventually destroyed. What was its destination? To be melted in the furnace? Or to end its days in the garbage collector?
I feel sorry for this well-made steel guy and wanted to prolong its life.  Can I find some use in it?
Wide opening (probably served for better air ventilation) on one of the sidewall reminded me of an open human mouth. So here came an idea: make office supply organizer and give it some humanoid like look. Below you can see the result.

This was an easy project.  In addition to the rack, I needed several pieces of plywood, a few screws, some glue: nothing special to buy. Overall it cost me nothing. But it serves its new purpose well.
  • It has two compartments to hold pens or pencils.
  • It has a panel to accommodate several push-pins.
  • Its rim can be used for keeping paper clips. 
  • It has a compartment for small items like SD card, thumb drive, or staplers.
  • There is even hook to hold penknife.
Given the fact that the project is very simple, I hesitated to publish it. But eventually, I submitted it to "Trash to Treasure" Instructables contest. To my surprise, it was "featured" by one of the site editors. It happened to be my tenth "featured" Instructables project.  Now I am the proud winner of site silver medal (10+ featured projects). Where is the medal? Actually, the medal is virtual and only site visitors can see it. Anyway, Hooray! 


Sunday, January 20, 2019

Through the Soratama Glass

There will be not much text in this post (mostly pictures). I recently acquired new toy: Soratama glass lens attachment. While it is relatively inexpensive (~$50), it provides a way to take non-standard pictures. I found it is even more interesting than a fisheye lens.   Here are some samples from the first session, which I  shot in our front yard:

Metal Butterfly 


 

Red Pot


 
The Rooster

The usage of this photo gear is simple.  First I needed to put the "soratama" in front of my digital camera macro lens. The distance between the lens and the glass ball should be big enough to allow the camera to focus on the ball. Soratama arrived with 20mm extension tube, I had attached it (by scotch) to the old Takumar hood which has approximately the same diameter (72 mm). Hood I had put on Pentax DA 35mm limited macro lens with help of 49mm-58mm step-up ring. Below is the picture of the whole setup:

  • Pentax K-01 mirrorless digital camera.
  • Pentax DA 35mm Limited Macro lens.
  • Polaroid 49-58mm step up ring. 
  • Old Takumar hood for telelenses (58mm mount size).
  • Soratama 72 mm with 72mm x 20 mm extensions tube.

Shooting itself was confusing at first: the image on the  LCD screen was seen upside down.  But eventually, it was not that hard to get used to.  I shot in raw and processed images (upside-down rotation,  exposure tweaking, some cropping) with Adobe Photoshop Elements 2018.

Update 11/28/2019: One more picture: Pentax Q-S1 + Pentax Q-K adapter + Sigma 24 MM Wide II Macro + 72mm Soratama
 

Saturday, July 14, 2018

Corrosion


Here is again my 2006 Ford Taurus (~161000 miles) with new problem.  Cabin fan stopped to  work at any speed apart of  maximal. For me it looked like very strange malfunctioning. While it is not that crucial  but still annoying. I shared my frustration with  co-worker, who owns and maintains himself Ford Taurus 1994 and he (without even looking) provided me with diagnostic: there is need to change motor blower resistor.


As you can see online estimate was not really encouraging. Price of repair is comparable with KBB trade-in value of my car. No way I am going to pay it. Some more online, search gave me this video:

Immediately after watching I ordered replacement  part (~$20 with delivery) and made the fix. Works like a charm. After that I decided to look at the broken part (photo of it you can see at the very beginning of this post). Why it stopped working? On the photo you can see how corroded  it is. But was it the actual reason? To answer the question one needs first to understand how device works. The schematic is fairly simple: three resistors and thermal fuse connected sequentially . Control switch selects how many resistors stays in the circuit, limiting the motor electrical current. Thermal fuse has to prevent overheating. It should blow-up when temperature exceeds allowed value (~ 121 degree of Fahrenheit). At the highest speed switch connects motor directly to the ground bypassing the resistors and fuse. That why motor works at maximal speed even if resistor circuit interrupted.

Visual inspection of resistors did not show any damage, so my guess was that indeed blown fuse caused the malfunctioning. I cleaned from rust some spots on contact plates and tested resistance of the circuit. If fuse is blown resistance should be infinite. But to my surprise I have found that it is not infinite, but rather small (several Ohms). That what you expect from the normal working device. The only reasonable conclusion would be: because of corrosion there was no electrical connectivity between device and socket contacts. As a result blower motor stopped working at any speed below maximal.



Sunday, January 14, 2018

Keep it Cool!


Last year my 2006 Ford Taurus (~157 000 miles) started to loose some coolant. Mechanic, while performing  regular maintenance service, told me it is due to replace water pump. Should I invest ~ 600$ in repair or save some money and do that myself? After some hesitation I decided to proceed myself. First of all I collected as mush information as possibly of what to do and how. Two YouTube clips came exceptionally useful. This one is about the whole process.


Second one is about changing serpentine belt tensioner. Even if there is no need to change it, one need to remove belt and all related components to get access to the water pump.

Both these clips are probably all what you need to know to replace water pump on the Ford Taurus 1996-2006 year. I myself cannot add much to that apart of telling some additional tips regarding tools used.
  •  From my experience set of metric wrenches 8,10,13,15 and the same set of sockets gives enough flexibility to unscrew and screw back all bolts of this project. Just pay an attention that 13 mm socket has to be deep. Regular short socket will be not good for some bolts mounting water pump.
  • To unscrew and then put back belt tensioner there is need in torx bit. Unfortunately second video mistakenly states that bit has to be T27 size. This is wrong.  For me size T50 worked well.
  • Second video shows nice tip of attaching bigger wrench to the 15 mm, making release of tensioner easy. Like this:
        
  •  That worked for me, apart of the fact that due to my inexperience 15 mm wrench slipped out of my hand and fell down. I had a trouble to get it back. To avoid such a mistake again I put some tape on the joint. Because of that the pair of wrenches worked as single tool. After the job done it was easy to remove tape and separate wrenches.
     
  • One of dis-assembling steps is to detach heater hose from the water pump. That sounds easy, but... I tried to pull hose as hard as I can without any success (later on I found that big buildup at the end of water pump pipe, as seen on first picture, was the cause) . Then I watched first video one more time and at 1:47 found the answer. Mechanic used special hook to separate hose form the water pump pipe. I made myself  similar out of inexpensive awl. That helped.
So here is the conclusion. It is doable to replace water pump even if you are inexperienced mechanic. You just need the garage, some inexpensive tools and online access to order parts and find proper info. 

Saturday, December 16, 2017

Ten Months Apart


This is photo of our front yard how it looks now (picture made on November 8 of 2017).

And this is the photo made on January 15 of 2017. As you can see it is quite a transformation.  This is the result of my biggest DIY project so far: conversion of lawn to garden. The are several reasons for our family to make that conversion:
  • First and most important: big water usage during summer months. It is usually hot  were we live and there are no any rains from May till October. Water bills easy could reach hundreds dollars. And in case state declares drought period, there could be charge for over-usage.
  • It is not that easy to maintain lawn in good shape. You see, even in the winter (rain season here) it is far from perfect, but I can assure you that during July or August  it is much worse. Brown spots her end there,  weeds in place of grass. 
  • I had to mow lawn two times per month and I did not like that. 
  • The last (but not least): to save the water our state willing to pay for lawn to garden replacement up two dollars per each square feet converted.
 So our family decided to proceed. The project started in January and ended in May. We did everything ourselves without any professional help. Here are project stages:

  1. Breaking the turf (grass) with garden shovel.
  2. Cultivating the soil with Tiller Joe electrical tiller/cultivator ( that step I repeated three times to fully destroy the grass).
  3. Fixing irrigation pipes, which were broken during steps 1 and 2. Replacing sprinklers with water pressure reducers.
  4. Planting drought tolerant shrubs and flowers.
  5. Covering soil with mulch,
  6. Installing dripping manifolds on top of water pressure reducers. Installing tubes with drip emitters.

I described this process in more details here: https://www.instructables.com/id/How-I-Made-Money-While-I-Worked-on-My-Front-Yard/ . In this post I would like to speak a little bit more about one topic which did not take enough attention yet. While converting irrigation from sprinkling to dripping I first tried Rain Bird Drip Emitter Conversion Kit which has everything:
  • raiser with pressure reducer.
  • Six port dripping manifold.
  • Fifty feet of dripping tube.
  • Six drip emitters.
  • Six stakes to hold emitters in place next to plant root.
It works OK, so I wanted to buy more of the same. But alas, my local Home Depot was out of stock. I decided to buy components separately. Raisers, tubes and emitters were not a problem. But there were no manifolds exactly the same as in the kit. So I had to try others.

At the picture above you can see everything I tried:

  1.  Raindrip Hydroport 4 Outlet Manifold 13400U (top left)
  2.  Orbit DripMaster 69005 4-Port Manifold (top right)
  3.  Raindrip QB10UB 10 GPH 4 Outlet Bubbler (bottom left)
  4.  Rain Bird EMT-6X Xeri 6-Outlet 1/2-Inch Drip Manifold (bottom right: the same as in conversion kit).

All manifolds but last one I did not like. While first three were more sophisticated compare to manifold in the kit (water consumption adjustment, changing of outlet angle position), they all suffer form the same disease: water leak at the foundation of outlets. One would say that such a leak is not important for outdoor devices, but I could not agree. Eventually I   ordered manifolds number four on Amazon and installed them.  No adjustment or changing of outlet angle, but no leak as well. I returned all manifolds but number four back to hardware stores.

Wednesday, November 8, 2017

Rumination of Uselessness


Let us return to the Useless Machine topic one more time.

Classical useless machine usually made out of four electrical components, namely:
  • Electrical battery.
  • Gear motor.
  • DPDT switch (usually toggle, sometimes rocker).
  • Micro-switch.
This is probably minimal set: it is hard to imagine anything more efficient. But once an idea came to my mind: maybe such a machine  is not absolutely perfect. Useless machine must cut itself out of power as soon as it returns to the original state. That achieved with help of the micro-switch.  Machine arm,while returning back, pushes switch, its normally closed contact becomes open,  machine fully stops and looks dead. But if tester tries to move an arm manually, micro-switch is released again, its closing contact provides power to the motor. That case is visible on the clip of Rocker Switch Useless Machine starting at second 19. So machine here actually is not dead, it just plays dead! That's  good opportunity for the new design : make the machine, which will allow manual rotation of the arm, when machine is turned off. In other words make the machine really dead at the end of its working cycle. To achieve that I decided to get rid of micro-switch and  use for backward movement an energy stored in the capacitor, charged while machine arm moves forward, . Below you can see circuit diagram of such a machine:
When switch connects motor to the battery and motor moves the arm forward, electrical current is flowing through  the circuit of diode and relay, mounted in parallel to the motor. Relay  is forced to close its normally opened contact. Through that contact (and small resistor) capacitor is connected to battery and receives some charge. 

When arm turns the switch back, motor is disconnected from battery, but connected to the capacitor in the opposite polarity. Motor rotates backward and returns arm to its original state.  Diode now stays in the opposite direction on the way of electrical current,  so relay contact stays open and capacitor is disconnected from the battery. Capacitor mostly is discharged providing the movement of the motor, the rest  will be discharged through the stopped motor winding. You see, in theory it looks simple. But I must tell you that this design is much more demanding on the spec of components, compare to classical schematic. After some trial and error iteration I came up to the next set component:
  • Solarobotics gear-motor GM17  ( I could not make it working reliably with GM2 or other motors with similar spec).    
  • Super capacitor 0.1 F. (I used NEC 5.5 V capacitor). Bigger capacitor would be fine but smaller probably not.
  • 5V relay. Here type is not that important. 
  • Schottky diode. Here type is not that important. 
  • Resistor 5 Ohm. It is optional but it keeps electrical current trough the battery under 1 Amp at the beginning, when the capacitor is fully discharged. Type does not matter here, but better to have 0.5 W.
  • Four 1.2 V rechargeable batteries. Type does not matter. 
As you can see on the video tester may manually  rotate the arm when machine is turned off.  Done!
I published more detailed description on instrcuctables site

Update 11/12/2017. fixed bug in diagrams: missing wire between switch terminals.



Saturday, December 31, 2016

In the Moonlight

This is the moon simulator with bat silhouette which I made as a decor for this  Halloween.


The core part of the project is twelve backlight white LED modules ( I bought them from the adafruit). LEDs are controlled by Atmega328 micro controller. The schematic of the project is fairly simple:




Adm here you can see project assembly with some internals visible:




Twelve LED modules put in the middle of sandwich made out of two Plexiglas  sheets attached with the help of Velcro strips.  Paper Bat attached to the front of the moon with Velcro as well as front and back cardboard shields .

 Program to control the device is short enough to be present entirely in this blog:

/*
 * moon.c
 * Created: 10/22/2016 1:14:19 PM
 *  Author: jumbleview
 */ 
#include <avr/io.h>
#include <avr/interrupt.h>
#include "./pt-1.4/pt.h" // http://dunkels.com/adam/pt/

typedef enum {OUT_LOW, OUT_HIGH} OutputLevel;
volatile uint16_t pulses;

#define pinOut(port, bit, outLevel) \
(DDR##port |= (1 << ( DD##port##bit)));\
switch(outLevel) \
{\
 case OUT_LOW: (PORT##port &= ~(1 << (PORT##port##bit))); break;\
 case OUT_HIGH: (PORT##port |= (1 << (PORT##port##bit))); break;\
}
void clearAll()
{ // set all outputs low
 DDRB = 0xFF; PORTB = 0;
 DDRC = 0xFF; PORTC = 0;
 DDRD = 0xFF; PORTD = 0;
}
void activateTimer0()
{
 cli();
 pulses = 0;
 TCCR0A=0; // Normal operation
 TCCR0B=2; // f divider 64  : about 2 ms for interrupt ...
 TIMSK0 = 1; // for system clock f= 1Mhz (CKDIV8 set)
 sei();
}
struct pt wpt; // protothread descriptor

int moonlight(struct pt* mlpt)
{
 PT_BEGIN(mlpt);  // New Moon 
  PT_YIELD(mlpt); 
   pinOut(C,5,OUT_HIGH); pinOut(B,1,OUT_HIGH);
  PT_YIELD(mlpt);
   pinOut(D,0,OUT_HIGH); pinOut(B,2,OUT_HIGH);
  PT_YIELD(mlpt);
   pinOut(D,1,OUT_HIGH); pinOut(B,0,OUT_HIGH);
  PT_YIELD(mlpt); // First Quarter   
   pinOut(D,2,OUT_HIGH); pinOut(D,7,OUT_HIGH);
  PT_YIELD(mlpt);
   pinOut(D,3,OUT_HIGH); pinOut(D,6,OUT_HIGH);
  PT_YIELD(mlpt);
   pinOut(D,4,OUT_HIGH); pinOut(D,5,OUT_HIGH);
   pinOut(C,0,OUT_HIGH); pinOut(C,1,OUT_HIGH);
  PT_YIELD(mlpt);  // Full Moon + Red Eyes
  PT_YIELD(mlpt); 
   pinOut(C,0,OUT_LOW); pinOut(C,1,OUT_LOW);
   pinOut(C,5,OUT_LOW); pinOut(B,1,OUT_LOW);
  PT_YIELD(mlpt);
   pinOut(D,0,OUT_LOW); pinOut(B,2,OUT_LOW);
  PT_YIELD(mlpt);
   pinOut(D,1,OUT_LOW); pinOut(B,0,OUT_LOW);
  PT_YIELD(mlpt);  // Third Quarter
   pinOut(D,2,OUT_LOW); pinOut(D,7,OUT_LOW);
  PT_YIELD(mlpt);
   pinOut(D,3,OUT_LOW); pinOut(D,6,OUT_LOW);
  PT_YIELD(mlpt);
   pinOut(D,4,OUT_LOW); pinOut(D,5,OUT_LOW);
  PT_RESTART(mlpt); // New Moon
 PT_END(mlpt);
}
ISR(TIMER0_OVF_vect)
{
 pulses++;
 uint16_t mod =pulses%750;
 if (mod == 0){
  moonlight(&wpt);  
 }
}
int main(void)
{
 PT_INIT(&wpt); // initiate protothread structure...
 clearAll();
 activateTimer0();
    while(1) { }
}

To  compile and load program into the controller memory I used Atmel Studio 6.1. Code includes three header files.

  • File "io.h" contains definitions to work with input/output (comes with Studio installation)
  • File "interrupt.h" is defining interrupt vectors (comes with Studio installation)
  • File "pt.h" is Adam Dunkels implementation of protothread library.
Protothred library deserves some additional notes. I included it to my programming  tool box recently and nowadays use it any time I need to program embedded devices in "C ". It provides multitasking framework and allows to code device states efficiently and conveniently.  I highly recommend to try it for any programmer  who works with micro-controllers in "C".

As you can see device is simple to made and program. Some additional details you can find in my "Instructables" project.

The only problem I see is relatively high project price. Mostly it is the price of LED modules ($2.50 for each). Nothing could be done here. To gain some additional benefits I decided to substitute  Bat with Reindeer so the device is quite usable  as winter decor:


Saturday, September 3, 2016

Windows Console on Demand in Go

There are two kinds of Windows programs: Windows GUI or Console Application. There could be third case:  process, which does not have any visual representation at all and needs to be running in the background. For that case program maybe be built as Windows GUI, but it should not have any code, which creates Windows objects.  But what if  you want from application sometimes  to be silent and sometimes  to be verbose and to have a console. Possible use cases are:
  • Printing version of the utility if started with special flag (like -V)
  • Program needs complicated tune up through the  command line arguments or configuration file, but normally is  running on the background. It would be beneficially to have a choice either run it with console or run it quietly.
That could be achieved by compiling application as Windows GUI and allocating  or attaching console to the process during run-time if needed. There are a lot of examples how to do that in C/C++. When I myself looked for the solution several years ago I have found this link  helpful. Fragment of the code, which creates console may look like this.

 // taken from: http://www.codeproject.com/KB/dialog/ConsoleAdapter.aspx

 AllocConsole();
 int fdout = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
 FILE* fout = _fdopen(fdout, "w");
 *stdout = *fout;

 int fdin = _open_osfhandle((long)GetStdHandle(STD_INPUT_HANDLE), _O_TEXT);
 FILE* fin = _fdopen(fdin, "r");
 *stdin = *fin;


Nowadays I found myself  programming more and more in Go. While initially Go compiler was intended for Linux only,  that is not the case anymore. Windows now is the first class citizen in the Go world. Recently I needed to create application, which may open the console if that demanded by  command line argument, but work invisibly  otherwise . To my surprise there were not that many online information how to do that in Go. I did find one answered question in StackOverflow. Alas, proposed solution did not work for me out of the box. But using it as starting point and after some googling I have found workable solution. Here is sample of Go application, which will allocate console, print some prompt, wait for keyboard input and quit.

// go build -ldflags -H=windowsgui
package main

import "fmt"
import "os"
import "syscall"

func main() {
 modkernel32 := syscall.NewLazyDLL("kernel32.dll")
 procAllocConsole := modkernel32.NewProc("AllocConsole")
 r0, r1, err0 := syscall.Syscall(procAllocConsole.Addr(), 0, 0, 0, 0)
 if r0 == 0 { // Allocation failed, probably process already has a console
  fmt.Printf("Could not allocate console: %s. Check build flags..", err0)
  os.Exit(1)
 }
 hout, err1 := syscall.GetStdHandle(syscall.STD_OUTPUT_HANDLE)
 hin, err2 := syscall.GetStdHandle(syscall.STD_INPUT_HANDLE)
 if err1 != nil || err2 != nil { // nowhere to print the error
  os.Exit(2)
 }
 os.Stdout = os.NewFile(uintptr(hout), "/dev/stdout")
 os.Stdin = os.NewFile(uintptr(hin), "/dev/stdin")
 fmt.Printf("Hello!\nResult of console allocation: ")
 fmt.Printf("r0=%d,r1=%d,err=%s\nFor Goodbye press Enter..", r0, r1, err0)
 var s string
 fmt.Scanln(&s)
 os.Exit(0)
}
I would like to point some details about syscall.Syscall invocation for AllocConsole :
  • This function  has five arguments. It is different of what you will find in the online Go Doc . Looks like doc references Linux definition, which is not the same as Windows.
  • Second parameter here is number of arguments in dll function. For our case it is 0.
  • Function returns three variables, but only first is really meaningful. It is the result returned by AllocConsole function. Second variables always 0. Third variables  is an  error, but in cannot be analyzed in the regular Go way as far as it is never nil.  Still it could be useful: in case of success its value is different from value on failure (for example if application was build with no windowsgui flag and already has the console ) .


Saturday, April 9, 2016

Not for Insulation Only

Hobbyist and DYI makers very often extend usage of elements and components beyond its usual assignments.  I would like to share with you one such a case. 
Whenever you drill through the wooden or plastic sheet you has to be really careful not to drill through. The common well know method to prevent that is to use tape or scotch wrapped around the drill bit. Once I was out of tape and had to look for substitution. Piece of  heat shrink tube came in handy. It fitted drill bit exactly, I just needed to cut proper length of it. That was very lucky finding. I entirely stopped using tape for this task and switched to heat shrink or straw tubing. Especially convenient it becomes  for projects which  needed drilling with the same drill size but with different depth. Switching between tubes can be done in a second.  
The best result is achieved when tube sits tight  on the drill bit. In case you does not have exact heat shrink size, you may cut tube, which is too narrow,  alone. It will still work.  But you need to be more careful to stop drilling right at the moment when tube touches the surface. Otherwise it may be torn away by drill rotation.

Heat shrink actually suited for various tasks. I even   published blog, picturing some of  them : http://www.instructables.com/id/Not-for-Insulation-Only/,  Here is list from that blog in a short:
  • Controlling depth of drilling (that idea you actually see here).
  • Using heat shrink while hanging picture  on sheet rock wall
  • Protecting awl tip
  • Keeping tweezers tips together. 
  • Making paper clip to work better. 

That topic got some attention and was even featured by one of the site editor.  Author Phil B told me about one more usage of heat shrink:  fixing claps on kindle reader case. I am sure there are many more cases which extends usage of heat shrink tubes.

Updated: 11/28/2017. Today I read about one more very useful usage of heat shrink: as thread locker.
Author Left-filed Designs published this blog https://www.instructables.com/id/DIY-Self-Locking-Nut/ . Very good. Will use myself for sure.

Sunday, January 11, 2015

Computer Desk Hutch with Sit or Stand Option

This project is a remake of the DIY project "Sit-n-Stand monitor station" described in the my old post: How did I join the Uprising. Recently my family moved into the new house and a lot of old stuff including some of DIY things did not survive the moving. I have to make the  station again. This time it  looks less DIY and more furniture like  (I hope). The basic principle is the same: desk with monitor moves up and down within sides sliders. Pulley system with counter weight compensates gravity force making moving easy. But there are some  differences:
  • Instead of single pulley line in the middle of the desk there are two lines on both sides of the desk.
  • I made desk as light as possible (but without any sacrifice of sturdiness).  
  • Light desk allowed me to switch from 3-times advantage pulley system to 2-times advantage system. As a result of that counterweight moves withing the boundaries of the hutch.
  •  I mounted  two shelves in the inner side of the hutch making some use of hutch volume.
Detailed steps of this project is published on the "Instructables" site right here: Sit&Stand Computer Desk Hutch . I even submitted it to couple of "Instructables" contests.  I cannot tell that submission made the big splash but project got some attention. While it does not win first prize it reached one contest final and here is my award: "Instrcutables" robot t-shirt.