Author:


DIY Homelite / Ryobi Carburetor adjustment pac-man tool

Posted by on April 14, 2012

I recently purchased a Homelite leaf blower, it seems to work fine except for the carburetor requiring some tuneup, so I decided to take a look at the needle screws just to find out they used a proprietary screw everyone calls “pac-man”, the tool costs $20 usd shipped from eBay and similar sources, the fun (or sad) thing is that the whole unit cost me about $100 usd — It’s not really an option to get the tool unless you do this for a living.

So I decided to make my own, first I tried to make a mould of the carb using oil and hotglue (the oil prevents the plastic from sticking to the metal) — The cast was fine, but it wasn’t deep enough, on hindsight I should’ve pre-heated the carburetor so the plastic would’ve run hot for a longer period of time, thus filling up the cavities of the adjustment section. The idea was to cast the tool out of 2 part epoxy, it may have worked if only I could’ve got a proper cast…

 

Since that was a complete failure, I went for plan b: I got a random piece of brass tubing. I filed it down to size and then I used a phillips screwdriver on a vise as the template for the pac-man groove, then I whacked it with an old chisel to leave the imprint. To further strengthen the groove I decided to use regular leaded solder (60/40) to cover up the groove from the outside. I also covered up the bottom portion of the tube (capped it) and I added a handle made out of wooden dowel.

 

What can I say, it simply works for what it is. I may not get tons of cycles out of it but as long as I can adjust the carb a few times, I’ll be happy.

Certainly worth the half an hour I spent doing this. Too bad it looks like crap!

 


In case you don’t like the idea of making your own tool, the other option is to simply grab the Dremel tool with a cutoff disk and just cut the slits on each screw, this will damage the carb as well though, I’m not too crazy about this option and certainly not crazy enough to spend 20 bucks on the real tool (which by the way I think its too long for this particular homelite product)

 

Either way, you don’t really have to bend over to Homelite! — Take that corporations and governments!

 

 

MSP430 Launchpad: Controlling a Servo with hardware PWM

Posted by on March 7, 2012

RC Servos are pretty useful devices, they allow us to move things in a mechanical manner. They are cheap and readily available, so it only makes sense to use them!

A quick intro:

Servos are actually rather simple to interface with, they merely require a pulse of a certain width to determine the next position.

Because of this, we can use hardware PWM to generate these pulses. The frequency is typically 50Hz, which means we’ll be able to obtain a great deal of granularity with regard to the duty cycle, given our clock speed of 1MHz. Which is required since we’ll be dealing with pulses ranging ~1mS to ~2mS (typically)

Different servos will require a different minimum and maximum duty cycle, however in general the given code should just-work, in case your servo goes off range simply find the best minimum and maximum values for it.

#include "msp430g2553.h" // make sure you change the header to suit your particular device.
 
// Connect the servo SIGNAL wire to P1.2 through a 1K resistor.
 
#define MCU_CLOCK			1000000
#define PWM_FREQUENCY		46		// In Hertz, ideally 50Hz.
 
#define SERVO_STEPS			180		// Maximum amount of steps in degrees (180 is common)
#define SERVO_MIN			650		// The minimum duty cycle for this servo
#define SERVO_MAX			2700	// The maximum duty cycle
 
unsigned int PWM_Period		= (MCU_CLOCK / PWM_FREQUENCY);	// PWM Period
unsigned int PWM_Duty		= 0;							// %
 
void main (void){
 
	unsigned int servo_stepval, servo_stepnow;
	unsigned int servo_lut[ SERVO_STEPS+1 ];
	unsigned int i;
 
	// Calculate the step value and define the current step, defaults to minimum.
	servo_stepval 	= ( (SERVO_MAX - SERVO_MIN) / SERVO_STEPS );
	servo_stepnow	= SERVO_MIN;
 
	// Fill up the LUT
	for (i = 0; i < SERVO_STEPS; i++) {
		servo_stepnow += servo_stepval;
		servo_lut[i] = servo_stepnow;
	}
 
	// Setup the PWM, etc.
	WDTCTL	= WDTPW + WDTHOLD;     // Kill watchdog timer
	TACCTL1	= OUTMOD_7;            // TACCR1 reset/set
	TACTL	= TASSEL_2 + MC_1;     // SMCLK, upmode
	TACCR0	= PWM_Period-1;        // PWM Period
	TACCR1	= PWM_Duty;            // TACCR1 PWM Duty Cycle
	P1DIR	|= BIT2;               // P1.2 = output
	P1SEL	|= BIT2;               // P1.2 = TA1 output
 
	// Main loop
	while (1){
 
		// Go to 0°
		TACCR1 = servo_lut[0];
		__delay_cycles(1000000);
 
		// Go to 45°
		TACCR1 = servo_lut[45];
		__delay_cycles(1000000);
 
		// Go to 90°
		TACCR1 = servo_lut[90];
		__delay_cycles(1000000);
 
		// Go to 180°
		TACCR1 = servo_lut[179];
		__delay_cycles(1000000);
 
		// Move forward toward the maximum step value
		for (i = 0; i < SERVO_STEPS; i++) { 			TACCR1 = servo_lut[i]; 			__delay_cycles(20000); 		} 		 		// Move backward toward the minimum step value 		for (i = SERVO_STEPS; i > 0; i--) {
			TACCR1 = servo_lut[i];
			__delay_cycles(20000);
		}
 
   }
 
}

The actual code was written for a quick and dirty servo testing unit I put together, however it could easily be expanded to other uses.

By using a LUT (Look-Up Table) we are able to position the servo on a per-degree basis, which makes the code a lot more intuitive and readable.

A bunch of notes and tips:

  1. Filter your servo power supply properly; servos are electrically noisy!
  2. Make sure your micro-controller is protected from external devices, such as the servos. For instance never connect the signal wire directly to the GPIO pins. Instead, use a buffer or at least a resistor. For this example we used a 1k Resistor, but since the “signal” interface is relatively high impedance, we could even use 4k7 or higher without much hassle.
  3. As long as you keep sending a signal to the servo, the servo will keep it’s position due to it’s internal feedback. However this consumes power so if you’ve got a very lightweight load or no load at all, you can always stop the PWM output for the periods of inactivity to save power.
  4. If you aren’t sure about your servo connections, here’s a small diagram to help you find the pinouts. In my case I had a couple cheap “Tower Pro” blue servos that use the JR pinout — These work fine at both 5v and 3.3v, however do not power them from the Launchpad power supply pins! — Servos consume a lot of current, always use an external PSU.
  5. Only one connection is required to interface the servo with the launchpad, find the pin P1.2 and connect it to the SIGNAL wire from your servo.

 

That’s it for now, enjoy!

(PB) Loading Assets, the simple way.

Posted by on January 23, 2012

Intro

Assets are an essential part of most games, how you manage them determines whether you spend more time working on them than dealing with them.

For small to medium games, loading an entire directory and having it referenced to a Map is the ideal solution. It’s both flexible and simple.

The following code allows you to do just this:

Prototype.i LOAD_DIRECTORY_CALLBACK( Map Assets.i(), directory.s, extension.s, name.s, userDefined.i = #Null )
 
Procedure.i LoadDirectory( Map assets.i(), directory.s, extension.s, *callback.LOAD_DIRECTORY_CALLBACK, userDefined.i = #Null )
 
	Define.i dir = ExamineDirectory( #PB_Any, directory, "*" + extension )
	If IsDirectory( dir )
 
		Define.i count = 0
		Define.s name = ""
 
		While NextDirectoryEntry( dir )
			If DirectoryEntryType( dir ) = #PB_DirectoryEntry_File
				name = DirectoryEntryName( dir );
				assets( ReplaceString( name, extension, "" ) ) = *callback( assets(), directory, extension, name, userDefined );LoadSound( #PB_Any, directory + "\" + name )
				count + 1
			EndIf
		Wend
 
		FinishDirectory( dir )
	EndIf
	ProcedureReturn count
 
EndProcedure

To use this code you must define a procedure of your own, this procedure is going to be called on each file to be loaded; you’ll have to load and process the file in this function.

Example use:

Global NewMap sprite.i()
Procedure.i callback_loadsprites( Map Assets.i(), directory.s, extension.s, name.s, userDefined.i = #Null )
	ProcedureReturn LoadSprite( #PB_Any, directory + "\" + name, userDefined )
EndProcedure
 
LoadDirectory( sprite(), "sprites", ".png", @callback_loadsprites() )

The example will attempt to scan through the directory “sprites”, it will execute your callback on each png file it finds inside the aforementioned directory, furthermore it’ll reference the filename (without extension) to the sprite() Map, so when you need a handle for the sprite called “fire.png” you’d just use sprite(“fire”) to obtain it.

Since the files are referenced to a Map by their actual name, you could easily implement a scripting system or any other dynamic management solution for your assets without much hassle.

An interesting part of the code is the return value, it’s actually the number of assets found (not the ones loaded, since your callback could choose not to load a certain file, for instance).

There are several limitations to this simple implementation, which is why I mentioned “small games” – There is no directory recursion, no advanced filtering options, no way to parallel the process on a separate thread and there’s no error handling at the moment.

However, it’s still very useful and I highly recommend you try it out, while it’s not a novel aproach, it’s always been the method I used to load my assets and it just works.

Have fun!

Well, This sucks.

Posted by on December 21, 2011

Technically homeless, in a hotel waiting to meet with the realtors in regard with the property I was going to acquire…

They keep BSing me about this and that with stupid constraints and whatnot, so I really need to get some lawyers down there first.

What also sucks is that they have to make sure the owner is available for the meeting otherwise it’ll be a futile exercise.

I’m trying to get this over with ASAP but it seems to be out of reach.

The biggest issues right now are having my pets living in a friggin’ vet store, which by the way they won’t be able to keep ‘em for longer than a few days, borderline Saturday. In fact, it took half a day of calls and walking half the damn town to find a place that would keep them in such a short notice (met with a clerk at night, they were closed but the guy opened anyway and told me to come back at the morning.

I had to get to downtown to seal the deal at 11AM, woke up at 7 or 8AM if I recall after going to sleep at 3-4AM — slept on the floor, wasn’t comfy but hey it helps with the back pain at least! — and I still had things to do at “home” before I left for good, however the pain from moving everything the day before was just too much to bare so I had to leave a few untied knots here and there; which I’ll have to deal with today or tomorrow.

Right now I’m using the shitty hotel’s WIFI, which is also shitty — obviously. The password is bosh780 by the way.

What really, really bothers me aside from all this crap is the price, they charge premium for an “apart hotel” room that I would never ever take if it wasn’t for the fact that every other place was fully booked.

I mean seriously, there are no facilities at all, the breakfast was a-ok but if I had to choose, I’d rather sleep in a car; which by the way is at the shop right now so yeah…

Anyway, f*** real estate agencies, in the arse with a machinegun.

See ya.

Off for a while…

Posted by on December 13, 2011

Well, it’s no secret to some — I’m moving out — And this means I’ll be away for a while. I’ll try to get online as soon as possible (not that any of you care!) and start posting some of my drafts right away; I have quite some interesting notes to share. However I’m not sure about the Internet providers and the quality of service at the new place, I may even have to resort to “stealing” WIFI while I figure out the ISPs.

It’s worth noting that right now the site has a low priority as well, I need to figure out how to get the massive amount of stuff I own moved from point A to point B without getting stuff damaged or stolen in the process. I also need to deal with a lot of paperwork and this requires a lot of time and dedication, so that’s where I’ll be focusing for the moment.

Hopefully I’ll be able to start with some nice weekly video entries as well once I’m half settled down.

There are lots of things that need to be done in the new house and I would like to share the process with everyone. Not everything is going to be electronics related, but I reckon some of it will be :)

Either way, have a good one!

Gus

PS: Shit this whole thing is stressful. But if it were easy it wouldn’t be worth it.