Post navigation

The next phase is to arrange all the electronics and design some new parts. The existing parts I am using from the original controller will just be the Spindle controller, stepper drivers and parallel port breakout board (BoB for short). The new parts will be a bigger 24v supply, mini ITX motherboard, 2.5″ SSD and a flex ATX PSU. (I decided on the SSD purely because there may be some vibration to upset a normal HD, mine is 64GB but 32GB would be big enough). Once again I used Sketchup to get a rough layout, before the parts arrived. I decided to keep all mains voltage parts in the bottom left corner and put the PC in the top right. The PC backplate is not going to be on the back panel as the BoB plugs in directly via a DB25 gender changer, and I probably only want access to a couple of USB ports. The plan is to run the mains down the left hand side (cyan in image below), the 24v stepper motor wire down the right (red) and then decide which is best for the spindle (yellow). In the end as I placed the spindle motor connector on the right hand side of the back panel (top left in pictures below) I decided to run the spindle wires down the left hand side, keeping the mains at the bottom and the spindle/other wires at the top. Fixing it all in place was pretty straight forward as I just used paper templates and taped them in place. I then drilled M3 clearance holes for everything except the motherboard standoffs, which I drilled 3.2mm and then just self tapped them into the soft aluminium. I used an old 2.5″ to 3.5″ HD adapter plate I had laying about, which again is fixed using a couple of motherboard standoffs.

Sketchup Layout

Final Layout

Wiring Routes

Trying make the machine safer is another consideration. I don’t want to just rely on the Estop switch sending a signal to Mach3, which is OK all the time that Mach3 is running but not good if Mach3 or the PC crashes. Mach3 has the ability to output a charge pump signal, all the time it is running and I want to use this signal to activate the 24v motor supply and the spindle. The following is based off the 2nd circuit by Mariss Freimanis in the support document found on the Mach3 site. When the charge pump signal is active and the Estop switch is off, the relay is energised and the 24v supply is fed to the stepper motor boards. and the BoB (which converts it to 5v, see later schematic), if either the Estop is pressed or the signal stops then the relay turns off, stopping all motors. I am also sending the switched ground from the Mosfet to the IO board which will activate the spindle. (This will be discussed later) I decided to power the board from one of the PC PSU molex connectors as there were plenty spare, and in reality I am not going to use the CNC without the PC on.

Schematic

PCB layout

I need to get access to the unused parallel port pins from the Tonsen 4 Axis BoB, so the first job is to try and make a schematic of the circuit. After spending some time with the multimeter and magnifying glass I came up with the following circuit.

Tonsen Schematic

Tonsen BoB

A few things to note…

The Q817 Opto-isolators, RN2 and Input header are not actually fitted as you can see from the board picture.(Top right)

The power input is marked as 24v AC but it is DC.

The caps are marked on the PCB 1000/35 for C1, 470/25 for C2 & 220/16 for C3 but the values in the schematic are fitted.

The moto (spindle) header is on the board but it doesn’t connect back to the spindle controller.

In summary output pins 2,3,4,5,6,7,16,17 are buffered through the HC244, while pins 1,8,9,14 are connected directly to the parallel port. Pins 10,11,12,13 & 15 could easily be converted to opto-isolated inputs with some extra components. I can’t use pin 14 as it’s also the enable for the X Axis. This means that I can use pins 1,2 and 3 for outputs. I want one for the charge pump and one for spindle control, which leaves another output spare. For inputs I want one for limit switches, home switches, probe, and Estop. This again leaves one spare.

Next up is the addon IO board and here is the schematic and PCB layout.

Schematic Part 1

Schematic Part 2

Board Layout

The circuit is pretty simple, it is just opto-isolating the inputs and outputs from the parallel port and providing suitable connection points to me to wire up connectors to the back panel and BoB. On top of that there is a LED indicator to show the state of the inputs, and a 3 second timer with buzzer for the spindle control. When PP Pin3 goes high, it switches power to the 555 timer and buzzer through Q1, this is configured as a one shot 3 second timer. While the output is high the buzzer sounds through the NC contacts of the relay. Once the output of the 555 goes low, it turns on Q2 which switches the relay (but only if the charge pump is active, as it supplies the switched ground for Q2), this disables the buzzer and switches on the spindle via the NO relay contacts. There is also another LED to show the spindle relay status.

JP2 supplies the 5 volts need to power the board, the Estop signal and the switched ground from the charge pump PCB. It also sends the opto-isolated charge pump signal from PP pin 1 to the charge pump board.

In the next part I will design the back panel and fit the cooling fans to the side panels.

For those that don’t know there is a close season for coarse fishing on rivers and canals between March 15th and June 15th inclusive. This meant that last Friday was the last day of the season and having been kept away from the rivers by the floods for the last 3 months, I was determined to make the most of the last week of the season.

It didn’t start off so good, I blanked on Monday and Tuesday and then completely wasted a day by leaving my cars MOT until the last minute. DOH!

Things improved slightly on Thursday when I had a 3lb Chub and lost another, I was particularly pleased, as it was from a stretch of river I have blanked at all season. and it was nice to finally bank a fish there.

On the last day, we arrived at the river at about 8am and walked about a mile downstream. I fished a few spots where I had caught fish before and managed to miss bite after bite. They always seemed to know when I was pouring a cup of coffee or was on the phone! My mate managed a couple of brown trout and by midday I decided to move back upstream. I decided to give a big wide bend a try on the way back towards the car, and proceeded to find a snag and lose all my end tackle. By now I was beginning to think this wasn’t going to be a great end to the season.

About a hour later I decided to move further upstream and fish the other side of the bridge. I had already decided the spot where I wanted to end the season, a nice wide bend with a shallow slack water pool on the opposite bank. Just to the left of this pool are some overhanging trees and my plan was to have a nice lump of cheese paste just off the tree, and a nice juicy lob worm out in the slack pool, just on the crease of the main river. By 5pm nothing had happened and my fishing buddy decided to go home. I had already decided to stick it out until 8pm which would give me a couple of hours after dark. About 5.30pm I missed a clonking bite on the worm, and I decided it was a good time to put the night tips on and re-bait. I put the last piece of cheese paste on the left rod and cast it just off the tree, and a nice fresh lob worm on the right rod out in the pool again.

At just on 6pm there was a couple of small taps on the left rod which gave me time to get my hand on the rod before the tip pulled round. There was a solid thump, and then everything locked up tight. Damn! It appeared the fish had swam straight back into a snag. With my Drennan Avon rod bent double I pulled as hard as I dared, finally there was another solid thump and the fish came free. It was a hard fight in the fast flowing current, she just laid on the surface with her mouth open, but I couldn’t get her to move. I also knew by this time that it was going to beat my current PB of 4lb 1oz, that made it all the more nerve jangling. In the end I extended my Drennan 3m landing net handle right out and moved downstream a few yards and netted her. It wasn’t until she was in the net that I realized how big she was. Still shaking I managed to weigh her and she went 6lb 2ozs, what a beauty! Unfortunately I only had my old camera and nobody to take the picture, so all I have is this picture of her in the net.

6lb 2oz Chub

It’s difficult to get a sense of scale from that picture but that is my 30″ Korum folding net, which is 26″ from side to side. I think the fish is about 20″ long, but you can’t see from the picture just how fat she was. To some a fish this size might be common place but for me it’s the fish of a lifetime.

I managed to grab another Chub of 4lb before I finished and all in all it was a cracking way to end the river season. Having already had 4 personal bests this season, including a common carp of 31lb 12ozs, it has been a season to remember. My local lakes end of the pike season is on 31st March. This gives me two more sessions (as I only fish over there on Mondays) and next week is going to be an all nighter. All I need is to get that elusive 1st 20lb pike and it will be a season to remember for sure.

As mentioned before, my idea was to build an enclosure for my Chinese 3020 CNC machine, that I had purchased from Ebay. The top part of the enclosure will house all of the electronics and PC and it will simply sit over the actual CNC machine. The framework will be made from aluminium profile with perspex side panels and aluminium panels for the top box and back. I have an old 17″ touch screen LCD monitor, which will sit on top of the enclosure.

CNC Enclosure Sketch

For the time being I am going to reuse most of the control electronics, but I have built an opto-isolated IO board, to allow me to connect limit/home switches and a probe, as well as control the spindle from within Mach3. I also plan to have a custom HID controller to allow me to have basic control from the front panel. Lastly I will add some form of led lighting to light up the working area. I won’t go into too much detail about building the frame as it’s pretty straight forward, I’ll just give a quick overview.

After pricing everything up I decided to go with the cheapest 4 slot 30mm aluminium profile, as this was my first time of working with aluminium profile, I wasn’t sure how easy it would be to work with. All the profile came cut to the correct sizes, which meant no messing about my end and nice straight ends.

I went for one of the cheapest profile connection methods, and I bought the self-tapping screws. It’s just a question of drilling a clearance hole in the correct place, sliding the screw into the slot and then tightening it up with a Torx bit through the clearance hole. The recommended size hole was 7mm but I drilled them 8mm instead, this would give me a little extra room to move things to square them up if needed. Although I bought the self-tapping screws, I ended up tapping them anyway and just used the screws to get the thread started. Once everything was drilled and tapped, it was simply a case of bolting it all together. I ordered the perspex online, and I managed to find a local company to cut the other panels from 3mm thick aluminium. The cover and reduction profile said it was for panels 4mm to 6mm but in reality a 3mm panel is a nice tight fit, and apart from the cost, thicker aluminium obviously becomes heavier and harder to work with. It would probably have caused problems with things like the front panel switches and buttons too.

Lastly I got some of the black plastic cover to fill in the slots, and some uniblocks to mount the top panels. Here’s some pics of the enclosure assembled.

While experimenting with making my own controllers recently, I needed a nice visual way of testing them in Windows. For some reason the ‘Game Controller Settings->Properties’ panel doesn’t always work, especially for joysticks with lots of axes and buttons.

6 Axis 32 Button Joystick

4 Axis 11 Button Gamepad

As you can see it’s pretty simple and just shows a visual representation of each axis, POV and button. Currently it supports Joysticks with 8 axes, 4 POV and up to 128 buttons. I haven’t had a chance to test it with over 32 buttons so I would be interested to here from anyone who has such a device.

It’s currently only alpha software, so there will probably be the odd bug, please post feedback here or drop me a email. It should work on XP upwards but I have only tested it on Windows 7 64 bit. You just need Net framework 3 and DirectX 9 to run it.

Over the last year I have been using the CNC 3020 machine I got from Ebay and I have been quite pleased with it. It has done what I expected it to do for the price I paid for it. I have however made quite a few additions and tweaks, which I will hopefully document on this blog soon.

I have been building a aluminium enclosure and I am hoping to integrate all the electronics and laptop in this enclosure. Here’s a picture of the simple Sketchup model I made.

CNC Enclosure Sketch

The front panel will also have a couple of joysticks and a bunch of buttons for controlling the Mach3 software. With the exception of the screen, it will pretty much be a self contained unit. (I only plan to a dozen or so buttons to operate the things I use most in Mach3)

This is partly why I have been experimenting with the Teensy USB development boards and having managed to get the controller part working, I thought it would be cool if I could replicate some of the Mach3 software LEDs with real ones. This involved writing a plugin for Mach3 to communicate with the USB controller. Fortunately there are some nice people out there, that are will to make tutorials and templates that make this much easier. I used the Plugin Wizard from Joshua 1 Systems, which although was designed for Visual Studio 2008, I was able to get it working with Visual C++ 2010 Express. I was then able to integrate Simon Inns USB Hid Library. Now I am no C++ coder, and I felt like it was a major achievement to get this working. As sad as it sounds, it was really satisfying to see that LED go on and off by clicking a button in Mach3.

So all that is left, is to try and put the whole lot together. I have the software designed, along with most of the hardware. I just need to finalize what buttons and LEDs to use for Mach3 and design the PCB for the controller. I am also waiting on some hardware parts to finish off the enclosure frame. I hope to post some more details and pictures soon, in the meantime if you need any aluminium profile I can highly recommend KB Aluminium and Motedis who have been extremely helpful in the building of this project.

The Teesny series of USB development boards are fantastic for making your own gaming controllers. If you don’t want to get your hands dirty then Generic HID is a great GUI tool for the Teensy++ 2.0. If you have a Teensy 3, then this guide by Kenton Hamaluik is a good starting point. If you want complete control over your Teensy++ 2.0 joystick then read on…

First you will need the Arduino and Teesnyduino software installed. I would also suggest you make a backup of the arduino/teensy folder just in case. Next I would seriously recommend a decent text editor, especially if you intend on doing lots of editing, while you can obviously do it in notepad, things like custom syntax highlighting make life much easier. I have personally been using Editpad Pro for many years and wouldn’t be without it now. Lastly if you are running Windows Vista upwards, you either need to turn off UAC (not recommended), run your editor as administrator or work on the files outside of the program files directory and then copy them back after.

Ok lets get stuck in…

Add A New USB Type To The Tools Menu

We are going to add a new USB type for our new joystick and we will call it Gamepad. First open up the ‘boards.txt‘ file found in a ‘arduino install folder\hardware\teensy‘. We want to add the new USB type for the Teensy++ 2.0. (This should work for the Teensy++ 1.0 and the Teensy 2.0, just change accordingly) Look for the ‘teensypp2.menu.usb‘ entries. After the last one (teensypp2.menu.usb.flightsim.fake_serial=teensy_gateway) add the following lines.

The first line is setting the text that the menu item is going to show. The second line is setting a preprocessor directive, which is basically telling the software to use our USB code for this device. The last line is used for creating a serial port emulator. After saving the file, if you open the Arduino software, you should have Gamepad Controller listed under the Tools, USB Type: menu. (I have included the ‘boards.txt‘ in the download file for those lazy people out there)

Adding The New Includes

If you look under ‘arduino install folder\hardware\teensy\cores‘, you will see there are several folders, in fact one for each USB type and a global teensy folder. (Ignore the teensy3 folder as the code is completely different) We need to create a folder for our new USB type here. Lets make a folder called ‘usb_gamepad‘.

Now you may be wondering how does the compiler know what files to use? When we compile our sketch, it looks in the global teensy folder and reads the relevant USB files, it then checks the preprocessor directive to see what USB type is defined, and then includes the files defined by that directive.

So in the ‘arduino install folder\hardware\teensy\cores\teensy’ folder we need to edit the following files.

‘core_id.h’, ‘usb.c’, ‘usb_api.cpp’, ‘usb_api.h’ & ‘usb_private.h’

For each file we need to add a couple of lines, after the last #include to tell it where our files are, so ‘core_id.h‘ becomes…

There is an excellent guide here on the descriptors, but the key thing is to make sure the data is byte aligned. Our gamepad has 11 x 1 bit buttons and 4 x 10 bit axis, this is a total of 51 bits. 51 is not evenly divisible by 8 so we need to pad it out to 56 bits. The following part is the 5 byte padding.

The order in the hid descriptor is also very important, as this is the order the data must be laid out in the packet sent from the controller to the host. You shouldn’t have to edit anything else in this file unless you decide to change the variable names.

usb_api.h

This is the heart of the gamepad class, and is where we configure the controller data to be sent over the USB. Earlier I said the order was important, the following picture shows how the host is expecting the gamepad data to be formatted.

Gamepad USB Packet

This is the order from right to left that the buttons and axis are defined in the gamepad hid descriptor. You can see the first 11 bits are the buttons, followed by 5 bits of padding, 10 bits for the X axis, 10 bits for the Y axis, 10 bits for the RX axis and 10 bits for the RY axis.

core_id.h

I don’t think this file is even needed, as I couldn’t find out where other core defines were referenced. In fact I took it out completely and the gamepad worked fine, but I have included it here just for completeness.

The Gamepad Sketch

Here’s the actual Arduino sketch code. This is the part you will need to edit to suit your controller. You need to adjust the button and axis pins to match you physical connections to the Teensy++ 2.0. I am using pins 0 to 5 and 7 to 11 for my buttons. Pin 6 is the LED pin, which is actually flashing at 100 times per second in the code. You can’t see the individual flashes but at least you know the code is running all the time the LED is on. I am then using A0 to A3 as the analog input for the axis. I am using a MMA7361 Triple Axis Accelerometer for 2 of my axis, so you can ignore that part of the code if you want. I have included it in case anyone else wants do do something similar.

A recent project required me to print a lot of info to the immediate window via the Debug.Print command. A quick search came up with a few suggestions for clearing the output in my program but nothing that worked for me. They did point me in the right direction and I came up with the following code that seems to work in Microsoft Visual Basic 2010 Express.

The code itself is simple, find the VB window, focus it, and then send some keystrokes. The key thing is the name of the window, this must be an exact match, so you will need to adjust it for other versions of VB. It also relies on the keyboard shortcut for the immediate window, which in VB Express 2010 is Ctrl+Alt+I.

The last part of the alarm is the actual drop off arm. The first thing to consider is the tilt switch and 3.5mm connector. I found some tiny tilt switches that are just over 6mm long and just under 2mm in diameter, along with a good quality right angled gold plated connector. The only problem is that these 2 components alone are 1/4 of the budget. The tilt switch is small enough to fit inside the connector, which means that spare arms could be used, with different lengths, weights and line clips, without having to purchase multiple, expensive tilt switches. I glued a M3 nut inside the screw on barrel of the 3.5mm plug to allow me to connect the metal arm.

Tiny Tilt Switch

Tilt Switch In Place

M3 Nut Glued In Place

Assembled Plug

Having sorted that part out, the next major design choice was the line clip. Solar Tackle make some great clips, starting from the cheap micro adjustable plastic ones up to the more expensive PTFE and stainless type. The line clip is such an important part of the alarm, it needs to be adjustable to suit different fishing situations. For dead baiting on still waters, the clip wants to be set light, so that the slightest movement of the line pulls out of the clip. (Obviously taking the wind into account) When fishing strong river flows the clip will need to be done up tighter, to compensate for the drag of the flow and small bits of weed or leaves catching the line. Finally when live baiting the clip need to be wound up tight to stop the bait from pulling the line out.

From a bit of googling and testing it seems that the Solar line clips (and a lot of other manufacturers) use a 2BA thread, so I need to go from a 2BA thread to a 3mm rod. As I had decided to use a 40mm foam ball as the sight bobbin, it was out of the question to use this as the means of joining the two. (For my initial test prototype I simply drilled a small hole in bottom of the plastic clip and glued the rod in place) As 2BA thread needs a 4mm hole I sourced some 6mm plastic tubing with an internal diameter of 4mm, as luck would have it 4mm is also the required hole size for the M3 brass inserts I found. I cut a 30mm length of the 6mm plastic tube, then tapped a 2BA thread into one end, and pushed the M3 insert into the other end. A 6mm diameter hole is then drilled 30mm into the foam ball. The plastic tube is then glued in place inside the foam ball. The whole thing is sprayed florescent orange and then we have a sight bobbin with removable line clip and M3 thread for joining the arm.

M3 Insert

Tube With Insert

Foam Ball With Tube

Sprayed Orange

The last part of the arm is the metal rod, this is just a 3mm RC pushrod with an M3 thread at one end. The picture below shows a single metal rod of 300mm, an alternative arm could be made by joining smaller rods together. With the latter the arm can be broken into smaller segments which makes it’s easier to store.

The first stage was to choose a suitable box, the one pictured below measures 50 x 28.5 x 74mm, which is comparable in size to the Micron P and is also cheap.. Next up is the latching circuit, a simple 2 transistor latch is put together and tested on the breadboard with a 8mm blue LED and small 85db piezo sounder. You can see in the picture below that the 2.5mm output socket has been included to test the mute functionality. I had also decided that I wanted to use a 3.5mm socket to connect the drop off arm, I found some tiny tilt switches that i was hoping I could mount directly inside the 3.5mm right angled plug. This would mean I could keep the arm modular as I wouldn’t have to run a cable to the end.(Most tilt switch alarms seem to put the tilt switch inside the sight bobbin)

ABS Box

Circuit Testing

Having decided on the components and box it was time to design the PCB. My initial idea of mounting the battery on the back of the PCB didn’t work out as the box was not deep enough. I also couldn’t mount it on the component side as I needed easy access from the rear of the box. I decided the best way was to mount the battery on a separate PCB and connect it to the main PCB via wires. With the battery position decided, I now had the dimensions for the L shaped area that was left, to design the main PCB in. I wanted to try and evenly space the switch, sounder hole and LED, I was also hoping that the switch cover nut and 3.5mm socket nut would hold the PCB secure so that no other fixings would be needed. Below you can see the PCB being milled, the finished PCB and the assembled prototype, with 2.5mm output socket and battery board.

PCB Milling

Finished PCB

Assembled PCB

The first design of the PCB worked ok, which was lucky seeing as I managed to mirror the design. (I forgot which side of the board I was working from) Fortunately I noticed before milling and was able to alter the design in Eagle. The first real problem I had was fitting the board inside the case. The 8mm LED clip I had was too deep so I had to trim it down. It was also very optimistic to think I could slide the board into place with the switch, 3.5mm socket, LED and sounder mounted. After I enlarged the switch hole it made it easier, but I have since decided it would be better to detach the sounder and LED from the board and connect them via wires are suitable connectors. The 2.5mm socket just about fitted perfectly on the bottom and also holds the PCB in place.

Box Drilled

Assembled - Rear View

Assembled - Front View

The usual way of connecting the alarm to a bank stick is via 2 terry clips, I found these nice clips, pictured below, that have a back plate and are longer than a standard clip. Only one is required for a firm grip and as it is secured by 2 screws there is no twist. I have chosen the 6mm clip as generally I would be using a telescopic bank stick and clipping the alarm onto the inner part. Afterthought – Maybe a bigger one could be used with some form of clip on sleeving to allow it to be used on smaller diameter tubing.

Bank Stick Clip

Clipped On Bank Stick

For the first prototype it turned out pretty good. The box is a nice size, the location of switch, sounder. LED and 2.5mm socket were spot on. The battery is easy to get to, and the PCB is mounted securely. The only minor niggle was the 3.5mm socket, it could just do with moving 1-2mm towards the back of the box.

Fishing, especially on a river can be very rewarding but also very frustrating. You begin to doubt your methods, bait and skill after a couple of blank sessions. Today I managed to catch two 3lb+ chub and a 3lb+ trout and lost a couple of fish, on a beautiful but chilly day. What did I do different from the last 3 blank sessions on the same bit of river? Nothing! Same baits, same rigs, same swims. So if at first you don’t succeed, go drown some more worms, the law of averages says you must find some fish eventually!