Friday, 10 May 2019

Pen Plotter Part 2 - Electronics and Software


This is the second part of my pen plotter build - part 1, covering the physical structure of the build, is here.

Printing Hello World!


Electronics and Software 

The stepper motors are driven by EasyDriver controllers which were recycled from an old, abandoned project.

Everything else is pulled together and controlled using an Arduino Duemilamove which provide the G-Code interpretation using the GRBL library.

Because GRBL is designed with 3-axis CNC machines in mind, it requires some alterations to work with the servo pen-plotter mechanism.

Thankfully I'm not the first person in the world to have attempted this, and this instructable provided a good head start on how to do this.

The main takeaways are to download the regular GRBL library, but swap out the spindle_control.c file with the one from the instructable. In that file there are two lines:

#define PEN_SERVO_DOWN 
#define PEN_SERVO_UP

Change the servo values if necessary - after experimenting with changing them, I found that I got the best results setting the down value to 255 and the up value to zero.

Inkscape GCode Conversion
The GCode plugins for Inkscape seem to be included with a standard installation - I didn't have to do anything special for them to appear.

Whatever your source image is (in the video below it was a text object), it needs to be converted to paths.

If you're using objects within Inkscape, such as text, use Path, Object to Path.


If you're starting with a bitmap image then use Path, Trace Bitmap, and use the Edge Detection method.


Post-processing
 
The next step is to run the generated GCode through a post-processor to add the instructions to raise/lower the servo. The post-processor linked in the Instructable didn't work for me, so I ended up making my own - the code is on GitHub.



To run the machine, I use the Universal G-Code Sender.

Troubleshooting

There were a few issues homing the plotter as near the extremities of the carriages travel it would struggle to move smoothly, and would not reach close enough for the limit switches to be triggered, resulting in it stalling. To overcome this I added screws to the structure in such a way that the limit switches would be triggered when stalling began to occur.


The pen holder that I designed in the previous post did work, but there were a few issues with the overly simplistic design:
  • The fact it rotated the marker off the page created 'flick' marks where the pen was raised/lowered.
  • As it was secured entirely on the servo, it had too much flexibility which resulted in it being dragged incorrectly on the page.


To fix this I redesigned the pen mount, factoring in what had already been created so as to make use of what was already created as much as possible.


The new design relies on supporting rails mounted to the existing carriage, which would allow the servo to push the pen mount directly down onto the paper. When lifting the servo returns to its initial position, letting springs added to the rails lift the pen back up.

This new nozzle is on github here.












Wednesday, 3 April 2019

Pen Plotter Part 1 - The Structure

I had two new years resolutions this year - start posting here on a more regular schedule, and to start whittling down the pile of electronic junk that I'd accumulated over the years.

I've obviously failed the first one already, but to aid the second one I've set myself the challenge of using as much of the junk pile into projects as possible.

A pen plotter works kind of like a printer, but allows for any flat material to be printed on, and uses vectors to draw images - like a person drawing by hand, instead of rasters like a traditional printer.

The principle is simple, a basic 2-axis structure with a tool-end that allows for a marker/pen/pencil to be simply placed on or lifted off the paper.

The stepper motors, gears and drive belts, along with the steel structural rods and bushing were taken from a variety of old ink-jet printers and scanners. The limit switches and servo were either just in my components library or salvaged from old projects.

The supporting structure was 3D printed, having been designed in OpenSCAD - the SCAD source code can be found on GitHub. I'm not putting the files on Thingiverse as they're created to fit the random motors that I scavenged, so anyone else using the design would most likely need to alter the dimensions for their own motors.

The chipboard base has been up-cycled from an old flat-pack desk.


The structure
The 4 main components of the first axis
(Rods not 3D printed)


The first axis consists of two end mounts - one being a simple shape to support the ends of the steel bars (a wheel for the pulley was added manually after printing.)
The other end is a larger mount which contains a mounting point to secure the first stepper motor - obviously this was created bespoke to the stepper that I salvaged, but could easily be adapted in the SCAD file.

In the middle are two pieces which will form the carriage for the second axis. - they're similar to the first end piece, but also contain mounting points to secure the pulley.

The second axis builds off of the first, fitting between the two runners created as part of the first axis:

The second axis
and how it fits with the first axis carriage.
The two holes are the front are for the steel guide rods. The gap in the middle is a space for the limit switches to be attached to the carriage and the cutaway at the top is for the second axis' motor.
The two runners and this carriage are fixed together by plastic friction welding.


The motor/gear assembly that I'll be using for the second axis lifts the belt over the top of the first axis' rods, so the height of the end piece is made to match. The notch at the top accommodates the spring-loaded tensioner for the belt.

The carriage for the second axis is a simple block which contains the two limit switches for the axis, a servo and a bracket to mount the pulley to.

The carriage on the second axis

The pen holder

The final structural piece is a simple pen holder which connects to the arm of the servo.

A post shared by Anthony (@darkmidnight_diy) on

The next part will cover the electronics and software.

Wednesday, 2 January 2019

Editing game saves with a Hex Editor

If it wasn't for videogames, I'd probably never have got into the career path I have, and a lot of that also comes from my other habit of taking stuff apart to see how it works.

Back in the days of the original Playstation, I had one of these Xplorer cheat cartridges.

This allowed the use of game cheats that weren't necessarily part of the actual game code.

In addition, the cartridge allowed the user to create new codes, by essentially searching for values in an existing game.

My understanding of it is that it effectively was a memory scanner, that would find values in the systems RAM, and allowed values to be rewritten (constantly rewriting the memory location of the health variable to read 100% would effectively be an infinite health cheat, for example).

Similar application shave been released for PC games, but to be honest, they went to involve running unchecked code and tend to have an air of shadiness about them.

Plus they tend to just be a very directed tool for a specific game title, so blinding running one might help you out with a game, but you're not getting anything useful from it.

This project is to demonstrate that similar results can be produced using standard tools, which have uses beyond games, so while cheating at the game won't make you any good at the game, you might instead learn something that is useful in the real world.

Tools
The tool being used is a Hex Editor (wikipedia). I'm using GHex, but the most commonly known editor is WinHex for windows.

Process

There are several approaches that can be taken, there are some who will painstakingly sit and work out the whole format of the file.

While this is probably the most technically sound approach, it's incredibly time consuming and laborious, particularly if you're only looking to change one or two values.

Another approach is to load a game, make a note of some key values in the game you'd like to amend - ammo, health, cash, etc. The more unique the value, then in theory the easier it will be to find in the file.

For this example we're using Saints Row 3, and in particular we're looking at ammo.

Note that there the process does involve a certain amount of trial and error, so for conciseness I'm not going to cover all of the missteps along the way, just what I did right. Of course it goes without saying making backups of the save before editing is worth doing just in case.

These are the ammo balances of the save I'm using:

The first thing to do is to convert some of these values to hexadecimal so that we know what to look for in the hex editor.

So starting with 265 - this converts to 109 in hex, or in the notation used with most hex editors, this will appear as "01 09", so use the find function in the hex editor to look for all instances of that. There are two likely outcomes, either:
  • You'll find multiple instances, so the next step becomes figuring out which one is the one you want to change.
  • You'll find nothing. In which case the endian ordering of the file could be an issue - this refers to the order in which the bytes are used to create the actual number. In layman's terms, you can think of it as reading from left-to-right or right-to-left. Simply reverse the order of the bytes above - e.g. "01 09" becomes "09 01" and search for that. If you continue to find nothing, it could well be there's some additional encoding or perhaps simple encryption on the file. There's ways around that but it's a bit of of scope for this project - I might do a follow up post later dealing with those things.
As it happened, with the pistol ammo amount I lucked out, there was only the one instance.:

The bytes representing the pistol ammo highlighted in red (click to enlarge)

So, let's change these two bytes to FF (the largest 2-character hexadecimal value - like 99 is in decimal), reload the game, and see what happens.

The pistol ammo is now 65535
(which is the decimal equivalent of hex value FFFF)

So, where to go from here? We can repeat the above exercise with the other values to find them, but we can help to deduce the whereabouts by adding some logic to what we already know - in this instance, we're looking for ammo values, we've found one, and we can reason that it's quite likely that these values will be grouped together.

For example, the SMG ammo value (70 00) was found nearby

The 2 values (pistol value in blue, SMG value in red). Click to enlarge.

From there we can deduce further - The pistol value starts at byte 19104. The SMG value starts at 19132 - 28 bytes apart.

So what if we look forward another 28 bytes at 19160? We find "30 00" - decimal value 48, the value of shotgun ammo. And again, another 28 bytes later we get hex "77 00" - decimal 119, the rifle ammo.


The other ammo values. Click to enlarge

So lets test it and change all of those to "FF FF"
So did it work?


Yes.

SR3 save file 'cheat flag'
Although it's not really in the spirit of this post, if you're here to just cheat at this one particular game, there's a byte in the save file that identifies if cheats were used in the game. It's the byte at 0x000000C8. You can play with cheats, then just change this flag to zero and it'll be as if you hadn't.


A final note on using cheats in games
Using cheats in games is obviously a polarising subject. I am very much opposed to using cheats in multiplayer games where doing so will affect the experience of others.
I am also generally opposed to using them in single player games - whether they're keycodes put in deliberately by the games developers or third party tools that you've just downloaded and ran.
In my opinion you should at least do a playthrough 'as the developers intended', however, they can be a good way of extending the re-playability of the game and getting more life out of your purchase afterwards, and by instead using techniques that I've covered in this post, you can learn and practise techniques that can be useful in the real world, and in my opinion the benefits of that outweigh the drawbacks.

Saturday, 10 November 2018

Metro 2033 inspired "Trench" lighter pt 2

In my last post I got the design and cap sorted for the trench lighter.

Sneak preview of the finished lighter

A post shared by Anthony (@darkmidnight_diy) on


Wick & Fuelling

Most refillable lighters such as the Zippo refill from the bottom, but I didn't want to make unnecessary modifications to the case itself, so I decided to create a removable wick mechanism that would allow the neck to also be used for fuelling.

To do this I needed to create a screw thread in the neck.

I started with this, and using a grinder rounded off the outside diameter until it sit snug in the neck. Finally added some solder to secure it in place.

Then I took this F-F coaxial (satellite cable) adapter, and drilled out the plastic middle, leaving a hollow tube with threads on the outside that fit the lighter.
Some wool strands twisted together to create a wick and pulled through this creates the removable wick.


Also at this point I filled the lighter with some wool padding to for the lighter fuel to soak into.


This just leaves the ignition source.

Ignition

I still have the inner components of the lighter that I used for the screwdriver bit holder. The flint is long gone, but the wheel could still be useful, so I pulled it apart and took that. There was also a spring that is used to press the flint to the wheel, so I scavenged that too.


The assembly was constructed from a piece of a picture hook, which was widened to accept the width of the flint wheel.

A small hole was drilled and a hollow copper tube attached to the bottom, where the flint and spring was placed, and held in place with a small screw. (see below GIF for clearer explanation)


This assembly was fixed in place using another plumbing olive around the neck of the cartridge and secured again with epoxy.

The lighter in action




Monday, 5 November 2018

Metro 2033 inspired "Trench" lighter

In Metro 2033 the main character, Artyom, carries a lighter fashioned from a bullet that can be used to light the way in dark areas and burn away obstacles such as cobwebs:



At a local country show I found an army surplus stand selling brass cartridge cases and saw an opportunity to make Artyoms lighter for real.

There is some real world history to this style of lighter. Known as a Trench lighter, items like this were quite common amongst troops in the trenches of the first World War, and relates to a wider concept of "Trench Art".

The case, I'm not sure what it's from.
It's approx .50" diameter at the neck,
but has stamp "SB 13"
 It seems too short to be a
standard .50 calibre round.

So with the case sorted, the next things to consider are:

  • Cap/means of extinguishing the flame
  • Wick
  • Fuelling & refuelling.
  • Ignition
Cap

I wanted to keep the lid of the lighter as a bullet style like in the game, but firearms law and lead content make the idea of using a real one infeasible and undesirable.

Instead I opted to grind the end of a copper bar down to a bullet shape, and hollow the inside slightly to make a cap.
The rounded copper bar.









Creating a hinge for the cap
The next stage is to create a hinge. A copper pipe clip was wrapped around the base of the cap, and secured with Araldite.

A second pipe clip was bent into a 'P' Shape and a bolt used to create the hinge (see gif below)



To attach this to the case, a brass olive from a pipe compression fitting (see pic.) was placed around the neck of the case, and the bottom half of the hinge was squeezed between it can the case to provide a frictional fit for now - it would later be further secured with epoxy.



Part two continues here

Thursday, 11 October 2018

Leatherworking Punch Press

Following on from the stitching pony I built a while back, this is another leather-working tool build.

A post shared by Anthony (@darkmidnight_diy) on

Living in a flat I am a bit limited on what I can do DIY-wise due to noise, particularly in the evening. Even simply using a mallet with stitching chisels to punch holes in the leather can be a bit too much.

The aim of this project is to create a press-like tool that is sturdy enough for me to just push the chisels through the material, allowing me to work more quietly.

I opted for some hardwoods for this project as although the original plan for a very utilitarian tool, testing found a lot of flex and give in the cheaper pallet wood I'd originally planned to use.

The base and back are iroko, with oak providing the corner piece and the uprights that connect the lever, which is maple.

All the pieces are simply screwed together, with a bolt passing through the oak and maple to create the pivot.

The levers handle was rounded with a notch cut into it's underside to support the chisels, and a cheap cutting board was used to create a working surface.

Finally, a small scrap of leather was attached to the back with upholstery nails, which creates 4 loops, to store the chisels.

In time I intend to give the handle a leather wrap, but that can wait until I've got a suitably sized scrap to spare.

It works great, not only in reducing the noise, but is actually a lot faster to use than the mallet, so I'm a lot more productive as well.

Wednesday, 12 September 2018

3 Panel Oak Picture/Poster Frame


A few years ago I bought a set of three Hotline Miami posters from the Eurogamer Expo. As much as I liked them I never round to hanging them - I kept telling myself I'd get a good frame, but never did.


This frame was made from a single piece of oak, and consists of dovetail-like joints in for the middle of the structure with half-lap miters for the corners.

The glass was upcycled from 3 individual picture frames from the local scrapyard - The existing frames were completely mismatched and in a bad state, but they all happened to have the same size glass, which cleaned up easily for this new frame.

Pic of the finished frame below, with sketch/build video below.
A post shared by Anthony (@darkmidnight_diy) on