Making a 3d printed functional Half-Life 2 Turret Part 1

Edit: Youtube Series on the way! Check out my Channel.

After finally having gotten around to building a 3d printer of my own, and being inspired by youtube videos I thought about making a “real” HL2 turret/Sentry Gun. And by real I mean the turret body should rotate side to side about 90 degrees, the machine gun part should move up and down and be able to point the gun and body towards a face. The gun will only probably be an led or something safe like a pellet gun. Edit: Oh my God, not a pellet gun! I thought they’re something else. Definitely not a pellet gun.

Pepakura 3d view

I will be using a Raspberry Pi for the brains of the operation. The basic idea is to have the Pi connected to either a webcam or a Pi camera mounted in the body of the turret and with a little image recognition identify the height and angle of body rotation at which a face is found and then via the serial port command and arduino to move the servos, change LED colors and so on. Of course, it will be able to play the turret sound from the game.

But how does one get started on such a project anyway? Well I did some googling and I couldn’t find any 3d models which I could use as a basis for my 3d printable, functional model, and the pictures I could find online with the turret were all isometric views which I couldn’t exactly use as a reference.

After a bit more searching, I stumbled over a paper craft model. There are a lot of these models available. After downloading it (I can’t find the link but I’m hosting it on google drive), I saw it had a  *.pdo extension. What is that? Well, apparently it is a pepakura model and it can be opened with Pepakura Viewer which you can find here. I opened it, and guess what? It’s perfect for the scope of this project. On the left side of the screen you get a 3d view of the paper model and on the right you have the unfolded printable version of it. The 3d view will be perfect for taking snapshots of the model to insert onto sketching planes when creating the robotic version. Not only that, but you can click on the various parts and they’ll be isolated to increase visibility on that part.

Pepakura Viewer 3

So now I’ve got a good starting point. But what about scale? Well it sure won’t be 1:1 because that would be a bit too much to print, but what I did was to create a block shape the size of the raspberry pi, the brains of the operation and then scale the image of the turret until it fit into the body. Then, one by one I started sketching out the parts and assembling them. I started the project in Solidworks 2010 but I wanted to try out Autodesk Fusion 360 because it’s free so I transitioned to it by outputting the Solidworks assembly to a .STEP file and importing it into Fusion. It worked great.

assembly

One important issue with the functionality of the turret is that the panel on which the back leg is mounted interferes with the body when in search mode so it would be impossible for the turret to rotate when assembled. The front legs are a bit easier because they mount on a plate which is positioned directly under the body and would make a great axis of rotation. So for the back leg I decided it would be easiest to just extend the plate downwards until it can be solvent welded with acetone to the front legs plate.

pepa_outsideoutside

 

 

 

 

 

 

 

 

After some deliberation I decided to use two bearings on 8mm threaded rod to enable the body to rotate and then used a mini or micro servo as an actuator. I’m a bit worried about using a small servo for the rotation of the turret because the movement should be smooth and I’m not sure how much torque will be required once the entire thing is assembled. Although right now, the bearings seem to be really easy to rotate. I’ve also printed some servo “horns” and I used a 2mm steel wire to connect the two (not pictured). It should be enough for only 90 degrees of rotation. Another possibility I considered was using a small stepper motor and belt drive, but I’ll leave that as plan B in case I get issues with the servo.

The bearing holder will be solvent welded to one of the base halves and the other half has two recesses in order to support the turrets weight once both halves are mounted.

Also, to get the back leg plate to fit onto my print bed I cut it in half and It will be solvent welded during assembly.

I there is interest in this subject I will make the CAD available for free. I think a Youtube series would also be nice.

Advertisements
Making a 3d printed functional Half-Life 2 Turret Part 1

Stepper motor controller shield

If you need to control some stepper motors for a 3d printer or a CNC machine, you need a stepper motor driver. Usually, these come with parallel port connectivity and if you don’t have a parallel port on your PC or you want to drive your CNC machine from a Raspberry Pi, then you have the choice of either using a USB to parallel adapter, or you can use a microcontroller.

A friend purchased a chinese stepper driver based on the TB6560 and needed a way to run the steppers from an arduino, so I made a shield for this purpose.

 

 

The design is made in Eagle using the pinout information of the stepper driver from this website.

You can download the schematic and board here.

Stepper motor controller shield

Arduino powered quadruped update

Long time no see…

I should have written this a long time ago, but things have gotten in the way…

The arduino quad has come a long way since my last post, it’s built and it has gone through a couple of circuit revisions and software variants. I had a lot of problems on the way and I still haven’t fixed most of them.

Anyway, I decided to build it from FR4 which is PCB reinforced fiberglass. I love to build using this material because it’s very strong but still a bit flexible. The disadvantage of course, is the fact that you have to etch the copper off the board before you cut it and a lot of fiberglass dust is created when working with FR4 and that’s not really good for your health.

On to the build

Having a 3d model of the quad made in Solidworks, I made the drawings and printed them out to scale, then cut out the paper parts, marked them on the FR4 and used a coping saw and a dremel with a thin cutoff disc and abrasive cylinders to make and finish my parts. This took about half a day. I went through about 5 coping saw blades because the dremel made a lot of fine dust which made a mess but the saw made courser particles and they were easier to clean up, plus, there’s a smaller chance to screw up with the saw going slowly.

I assembled the servos on to the parts using the screws that came with them and the circular horns. No issues here.

Electronics

I designed the shield for the Arduino in Eagle and made a few mistakes, for example not taking into account the length of the servo wires. I just put all of the headers in a line and some of the wires were stretching a bit when the legs were fully extended.

Another mistake was the method used to supply 5v to the servos. I hadn’t expected them to need more than 1.5A. Biiig mistake. I only put a 7805 voltage regulator on the shield with a big heatsink and, obviously, it didn’t last more than a few seconds. After reading some posts online about supplying power to a lot of servos I found that due to their design, you can’t put more 7805s in parallel because one of them will take most of the load, so basically I had to choose between a UBEC, which is basically a switching regulator, and no regulator at all. The problem with the UBEC was that I didn’t have one and 6 amp UBECs are over my budget, but this would be the most efficient way to get the power down from the LiPo’s ~8V to the 5V I needed. So I decided to take a risk and go without a regulator hoping that 12 servos would cause a big enough voltage drop to not cause problems. Baaad idea! Apparently servos don’t run without smoke in them, and as soon as one of them let the magic smoke out, I decided that I needed another solution to my voltage problem.

After a couple of weeks of pondering whether or not to buy a UBEC, it dawned on me that it would be possible to use a voltage regulator for each of the four legs thus each regulator would have to supply only three servos. The second version of the shield included a header for a Sparkfun Bluesmirf Silver bluetooth module which would allow me to send commands to the quad from a phone or a PC. Naturally, I didn’t account for the thickness of the heatsinks that would be mounted on the 7805s and I had to unsolder two of them, mount them on a single heatsink and run wires to the board… oh well. At least now I have a good power supply (even though some decoupling capacitors would have been a good idea now that I think about it).

Moving on to the main problem of this quad.

The jitter

The jitter is strong in this one… Due to the fact that I’m not using PWM pins on the Arduino because there aren’t enough, after a lot of googling, it turns out that arduino can’t supply a constant signal to the servos and this results in twitching of the servos. Basically, every 20ms you send a high signal to the servo.  The time you hold the signal high determines what angle the servo goes to. The problem is that the arduino isn’t able to produce signals of consistent width. It’s either this or the cheap servos. Or both. If it’s the servos, I’m scrapping the project. Because of this, I haven’t really concentrated on the gait program, the only thing I did was the inverse kinematics.

 

After thinking things over, my conclusion is that dedicated servo hardware is needed. So i found the PCA9685 (datasheet) which is a I2C bus PWM LED driver with 16 channels and 12 bit resolution. This means that I only need two arduino pins to control all of the servos and I can add a few more for sensors or something. By the way, if this fixes the parkinsonian behaviour of my bastard four legged child then I will consider replacing the arduino with a Raspberry Pi which opens up a whole new world of possibilities.

I got the idea to use the PCA9685 seeing that adafruit made a servo driver with it. Because shipping would cost more for me than the board, I ordered the chip from Mouser and plan to use it in the third version of the quad shield using the schematic from the adafruit board. I found it only in a SMD package so this means the quad will get its first double sided PCB. I started designing the shield on circuits.io but before being able to complete it something went wrong and now I can’t edit it nor view it. Half a day down the drain I think.

The third version of the shield will have the PCA9685, two additional servo headers, the bluetooth module header, and if I have room, a voltage divider for measuring battery voltage.

Arduino powered quadruped update

Car alarm remote control repurposing

A while ago, I got hold of a car alarm unit and its two remote control fobs. When i hooked it up to 12V I realized that it didn’t  work, not responding to any of the commands from the two fobs even though their batteries were OK. Naturally, I opened up the unit to start harvesting parts and noticed the RF module within (the one that sticks out perpendicularly ) and I figured it shouldn’t be too hard to use the module with an Arduino.

Basically, my code uses pulse in to see whether incoming pulses are longer than 1000 microseconds and if a pulse is longer than that I consider it a ‘1’ and if it’s not, a ‘0’. So it constructs a string called ‘codein’ about 75 characters long and then it searches for 25 character pre-defined strings within it (using the substring command) , to see whether a button has been pushed on one of the remotes. If a button push has been recorded then it prints out which one over the serial connection. Oh, and I was lucky and discovered that each remote delivers different codes, meaning that I am able to remotely control 8 channels.

To figure out which codes you need to pre-define for your buttons you can un-comment the lines which display the incoming string. So here’s the code:

// RF module receiver code for Arduino.
// The module is connected to the Arduino havin 3 pins: +5, GND and data. The data pin is connected to
//digital pin 11 on the arduino.

int inpin = 11;
 int onoff = 0;
 int i=0;
 String codein="00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";

//there are about 100 zeros in the initial codein

unsigned long duration;
 void setup()
 {
 Serial.begin(9600);
 Serial.println("setup");
 }

void loop()
 {

for (i = 0; i < 100; i++) {

duration = pulseIn(inpin, HIGH);
 if (duration > 1000)
 {
 codein.setCharAt(i,'1');
 }
 else {
 codein.setCharAt(i,'0');
 }

}
 Serial.println(codein); //uncomment these two lines to figure out your remote codes
 delay(1000); // this is the second line
 for (i=0; i<75; i++){
 if (codein.substring(i,i+25)=="0010100111000110001010000") // substitute remote codes here
 { Serial.println("lock!!!"); if (onoff == 1){onoff = 0;} else {onoff = 1;} // LED toggle on/off
 break;
 }
 if (codein.substring(i,i+25)=="0010100111000110001001000") // and here
 { Serial.println("unlock!!!");
 break;
 }
 if (codein.substring(i,i+25)=="0010100111000110001000100") //and here
 { Serial.println("mute!!!");
 break;
 }
 if (codein.substring(i,i+25)=="0010100111000110001000010") // you get the idea 🙂
 { Serial.println("ring!!!");
 break;
 }

if (codein.substring(i,i+25)=="0010010110111101111001000")
 { Serial.println("lock2!!!");
 break;
 }
 if (codein.substring(i,i+25)=="0010010110111111111000100")
 { Serial.println("unlock2!!!");
 break;
 }
 if (codein.substring(i,i+25)=="0010001001011011111111100")
 { Serial.println("mute2!!!");
 break;
 }
 if (codein.substring(i,i+25)=="0010010010110111111111000")
 { Serial.println("ring2!!!");
 break;
 }
 }

// this toggles the 13 pin led on or off
 if (onoff == 1) {
 digitalWrite(13,HIGH);
 delay(1000);
 }
 else { digitalWrite(13,LOW);
 delay(1000);}
 }

 

Car alarm remote control repurposing

Arduino controlled motorcycle tachometer

I found a smashed Kawasaki dash in the dump. The speedometer was destroyed, but the tachometer was OK. The first thing I did was connect the tacho to 12v. It had three contact points marked IGN, GND and an unmarked one. I figured that IGN was +12V and the unmarked one was the signal input. So I powered up the tacho and flicked a 12V wire on the unmarked contact. Surprisingly it started indicating about 3000 revs.

I then Google’d a way to output a +12V square wave with the Arduino and I found this:

The next thing I did was hook everything up on a breadboard to test it out:

Using a potentiometer I varied the delay in microseconds for the off time of the signal used to drive the tacho.

I had to fiddle a lot with the Arduino program. I figured out that because I had inserted a Serial.println(val); to print out the value of the delay I was using to modify the signal was adding a bit of a delay. The next thing to be done is to receive some data over the serial port and display it on the tachometer.

Arduino controlled motorcycle tachometer