CNC Coil Winder / Cam Grinder

Help Support HMEM:

74Sprint

Well-Known Member
HMEM Supporter
Joined
Apr 21, 2013
Messages
128
Reaction score
34
Location
Winnipeg, Canada
Well it took me about 2.5 months to learn C# and to program an Arduino Nano but, I have Version 1 of my codes completed. I learned a lot about the Arduino IDE coding, it's a combination of C and C++ in their own flavour. They say necessity is the mother of invention. Shipping costs and some manufacturing costs from China was killing me so this seemed to be my answer. I need to make charge and pickup coils for the Krober ignition I'm making. Now I just need to make some room in the garage to build the actual machine.

So what can one do with this code? Because I'm using TB6600 stepper controllers, either Nema 17 or 23 motors (must be 200 step 1.8 degree), and 10-32 rod for the wire feed carriage, the resolution can be on the order of 0.0000048 " or 0.05 of a degree at 6400 steps per rev. Another thing is that the Nano only has the parameters passed to it from the PC. This frees up a lot of memory space on the Nano and the number of clock cycles needed to run the Arduino code. Using a PC to do most of the calculations, pretty much all the calculations, and having different specs/jobs stored on the PC allows for me to quickly switch from one job to another and recall jobs. The motors are synchronized to each other but, I need to verify this which, I'll be doing today along with the degrees accuracy. So far I have just bench tested the motors. The program is able to use 20 predefined popular wire sizes or one can enter in the the wire size in either AWG or measured inch. One can also enter in their bobbin size and number of windings needed. The PC will calculate the number of layers needed, number of feet of wire needed beforehand so you can tell if your bobbin is big enough and you have enough wire. It will also calculate the resistance of the wire and max amps it can handle. Also right now one can only make single segment coils like ignition coils that have multiple layers, just use a laminated iron core instead of a bobbin. I will later change this to multi-segment coils like CCFL or switching power supply step-up/step-down coils.

Computer programming which, includes programming the Arduino stuff is not for everyone. Programming is learning a new language/s but and this is a big BUT, it is not normal for humans to think in pure logic or ladder programming. Ladder programming is the same as programming a PLC or smart relays. When programming, one not only needs to use the correct commands but, one also has to put them in the right order. For example have someone walk from your front door to your back door or from the kitchen to the bathroom by taking only one step at a time that you tell them. So you have to tell them to take each and every step, telling them how big each step is and in which direction and which foot to move. I'm only supplying the source code the the Nano and not the C# because unless someone wants to lean C# I think the Arduino is enough. I put lots of comments in the code and I also used different code to do the same job, which is good for learning. I deliberately did not optimize the code for this reason. I also tried to keep the code as simple as I could so learning it would be easier and the same for modifying it.

Future possibilities: I've been trying for 5 years now to get a combo lathe/mill but, something always keeps coming up to stop me, so I'm going to concentrate on my CNC stuff for now. As I mentioned I want to expand this project so it can do multi-segment coils. From this I plan on turning it into a cam grinder using 1/4" wide grinding wheels or smaller if I can find them. All I need to do is turn the carriage 90 degrees so it feeds in and out from the camshaft. Of course I need to come up with code to handle making the lobes and feed rates. It's a good thing that I made my code modular to help with the modifying. I'm pretty sure that when I make my 36" x 24" CNC router I'm going to use either 3/8" or 1/2" threaded rod for the lead screws to give me greater accuracy without using gearing of some sort. I still want to check out GBRL and g-code programs and how I might implement them.

If you decide to check out my project and have problems please let me know.

Thanks
Ray
 

Attachments

Last edited:

74Sprint

Well-Known Member
HMEM Supporter
Joined
Apr 21, 2013
Messages
128
Reaction score
34
Location
Winnipeg, Canada
I forgot to mention a couple of things. First the picture of the coil winder is not mine, I'll update that once I have mine built. Second is that there is an option to use different carriage drive rod (lead screw) so long as you know the threads per inch. The program will calculate the number of steps necessary to do per inch, and resolution based on the TPI and number of steps per rev based on what you have selected. So 1/(TPI x steps per rev) = res or for example; 1" divided by (32 x 6,400) = 0.0000048828125" per step. Or in degrees it would be 360/6,400 = 0.05625 degrees per step or better if a reduction gear drive is used. The use of a 10-32 drive rod and the TB6600 makes for excellent resolution. I also forgot to say that I'm using the AccelStepper library for the Arduino code. This is not a straight forward library, it has it's faults but, they are manageable. I also want to try out the AccelStepper With Distance. My PC code has built into it but not used, stepper steps to distance so I want to see how they match up.

Cheers
Ray
 

74Sprint

Well-Known Member
HMEM Supporter
Joined
Apr 21, 2013
Messages
128
Reaction score
34
Location
Winnipeg, Canada
Well I found some bugs that I need to fix. I also quickly checked out GRBL and I don't see any reason why I can't use it to make my cam grinder using 'G' code. I'll test it with my QCAD that makes 'G' code and see if I can grind a cam but, that will be awhile. I might have to ask someone on this forum to make me a blank cam.

Cheers
Ray
 

retailer

Junior Member
Joined
Oct 13, 2011
Messages
163
Reaction score
59
Just wondering how a coil winder could be used as a cam grinder, a cam grinder would be handy, I can't quite picture turning the carriage 90 deg, here is a short video of the coil winder I built a few years back, uses 2 of 18 pin picaxe chips one for the wire traverse stepper and another to do the motor stop/start turns count etc.

 

awake

Well-Known Member
HMEM Supporter
Joined
Sep 4, 2019
Messages
1,248
Reaction score
526
Location
North Carolina
Ray, an interesting project. The 8-bit Arduino continues to be an excellent choice for a lot of projects of this nature - yes, 32-bit is sexy, but when you get down to it, it is better to let a PC run the interface and have a dedicated microcontroller (with deterministic real time) running the hardware than it is to try to do both in a single chip. Or at least, that's my story, and I'm sticking to it ...

AccelStepper is an interesting library, but it suffers from the fact that it depends on calling the library repeatedly in the main loop. Up to a certain point, this works just fine ... beyond that point, it can't keep up. GRBL can go quite a bit further than AccelStepper, since it uses timers and interrupts rather than depending on the main loop. I would guess that you could use GRBL to run the coil winder as well - just need to set the "steps per unit" settings appropriately. But a big advantage in using AccelStepper (or your own interrupt-driven code, should you decide to go that far) is that you can still include a simple interface using a 2 or 4 line LCD screen, rotary and/or button inputs, etc. With GRBL, you would not have enough room on a Nano to add any sort of interface.

One quibble - the Arduino IDE uses C/C++, not C#. Admittedly, it is C/C++ with some limitations (especially for data sizes, e.g., only single-precision floating point), but C/C++ all the same. Under the hood it uses the gcc compiler, if I recall correctly. The key is that is compiles directly to machine code. Meanwhile, while C# superficially resembles C/C++, it is a very different animal; it produces an intermediate code (CLR) that has to run on the Microsoft NET framework - way too much overhead for a Nano to handle, I suspect.
 

74Sprint

Well-Known Member
HMEM Supporter
Joined
Apr 21, 2013
Messages
128
Reaction score
34
Location
Winnipeg, Canada
Just wondering how a coil winder could be used as a cam grinder, a cam grinder would be handy, I can't quite picture turning the carriage 90 deg, here is a short video of the coil winder I built a few years back, uses 2 of 18 pin picaxe chips one for the wire traverse stepper and another to do the motor stop/start turns count etc.

Well first, a lot of the calculations would be the same. Using micro-stepping and the 10-32 rod, instead of the carriage moving back & forth you turn it sides 90 degrees so the carriage feeds in and out. So I would zero the carriage against the cam blank. Zero the winder part as an indexer. The PC program would have all the calculations for intake & exhaust lobe centre lines, lobe separation, lobe height, lobe duration , and feed rate, just like in a regular cam manufacturer. All this info would be sent to the Arduino which would control the stepper motors. In my case I would use my QCAD to design the cam profile, save as a 'G' code file, import that into my program, combine everything to get what needs to be sent to the GRBL firmware on the Arduino.

Ray
 

74Sprint

Well-Known Member
HMEM Supporter
Joined
Apr 21, 2013
Messages
128
Reaction score
34
Location
Winnipeg, Canada
Ray, an interesting project. The 8-bit Arduino continues to be an excellent choice for a lot of projects of this nature - yes, 32-bit is sexy, but when you get down to it, it is better to let a PC run the interface and have a dedicated microcontroller (with deterministic real time) running the hardware than it is to try to do both in a single chip. Or at least, that's my story, and I'm sticking to it ...

AccelStepper is an interesting library, but it suffers from the fact that it depends on calling the library repeatedly in the main loop. Up to a certain point, this works just fine ... beyond that point, it can't keep up. GRBL can go quite a bit further than AccelStepper, since it uses timers and interrupts rather than depending on the main loop. I would guess that you could use GRBL to run the coil winder as well - just need to set the "steps per unit" settings appropriately. But a big advantage in using AccelStepper (or your own interrupt-driven code, should you decide to go that far) is that you can still include a simple interface using a 2 or 4 line LCD screen, rotary and/or button inputs, etc. With GRBL, you would not have enough room on a Nano to add any sort of interface.

One quibble - the Arduino IDE uses C/C++, not C#. Admittedly, it is C/C++ with some limitations (especially for data sizes, e.g., only single-precision floating point), but C/C++ all the same. Under the hood it uses the gcc compiler, if I recall correctly. The key is that is compiles directly to machine code. Meanwhile, while C# superficially resembles C/C++, it is a very different animal; it produces an intermediate code (CLR) that has to run on the Microsoft NET framework - way too much overhead for a Nano to handle, I suspect.
The C# code only runs on the PC. It is only the settings and commands that are sent to the Nano. The Nano can not handle real time updates back to the PC, the serial USB is just too slow, so updates/status returns are done at the end of a task. I might try just the serial port and skip the USB and it's layers. Currently my Nano code is only using 71% of the avail memory on the 328p (not optimized). I could use the AccelStepper or I could just write my own code but, writing my own code would not be best for others that don't code. As I mentioned in my post above QCAD can output 'G' code so that would make my life easier and I think for others also. Oh remember I went with a PC interface rather than a hardware one because I have many different coils to make which, makes my life easier.

Ray
 

awake

Well-Known Member
HMEM Supporter
Joined
Sep 4, 2019
Messages
1,248
Reaction score
526
Location
North Carolina
Ah, I think I see - C# is used for the PC interface. Presumably you are using the standard Arduino IDE (C/C++) on the Arduino itself.

I agree that there is no need to write your own code for the steppers if you can get the performance you need from AccelStepper. But one thing you mention might be worth exploring further - sending real-time updates back to the PC. If you were to use GRBL, I think you would have access to real-time updates; the difference is, again, that GRBL is interrupt-based, so the real-time demands of driving the steppers can interrupt the serial code sending updates. (I think - I haven't done enough with GRBL to be absolutely certain, but I know Marlin works this way, and IIRC, Marlin was built from GRBL.)
 

74Sprint

Well-Known Member
HMEM Supporter
Joined
Apr 21, 2013
Messages
128
Reaction score
34
Location
Winnipeg, Canada
I haven't tried the GRBL yet I'm still trying to find time to read all the literature but, it does sound like I should be able to do real-time stuff with it, I hope so or I might have to go to a faster processor like the Due but, that would be a waste of resources. According to the marlinfw.org they do real-time with a variant of GRBL on a Mega2560 which has the same clock speed as the Nano. The biggest problem with using USB as a serial port is all the software and firmware that the communications has to go through to talk to one another, really slows things down. With the AccelStepper one has to be careful not use blocking commands unless it is necessary, also things like using moveTo() and move() are not the same and one needs to know when to use them. In my main loop I only have checking the serial port and running the motors to keep the motor speed up. What I like about AccelStepper is that it allows me to define a speed ratio for the motors including using Float values. No need to gear the motors. I wrote both codes as modular as possible so that they can be used for other projects. I just wish this damn covid-19 would go away so I can make enough money to buy a decent lathe/mill. My ultimate goal is to make a scale GM-EMD 645-16 engine and a SD40-2 locomotive. Oh well time will tell. Thanks for the info about the Marlin code.

Ray
 

retailer

Junior Member
Joined
Oct 13, 2011
Messages
163
Reaction score
59
74Sprint- thanks for the explanation, my homebuilt coil winder isn't suitable to use your idea, my main drive spindle is driven by a speed controlled DC motor, rather than a stepper, your idea has merit - food for thought, good luck with your project.
 

74Sprint

Well-Known Member
HMEM Supporter
Joined
Apr 21, 2013
Messages
128
Reaction score
34
Location
Winnipeg, Canada
74Sprint- thanks for the explanation, my homebuilt coil winder isn't suitable to use your idea, my main drive spindle is driven by a speed controlled DC motor, rather than a stepper, your idea has merit - food for thought, good luck with your project.
Thank you

Ray
 

bluejets

Well-Known Member
Joined
Apr 22, 2014
Messages
337
Reaction score
116
74Sprint- thanks for the explanation, my homebuilt coil winder isn't suitable to use your idea, my main drive spindle is driven by a speed controlled DC motor, rather than a stepper, your idea has merit - food for thought, good luck with your project.
All one has to do there is fit an optical counter on the shaft if the mechanics are already in place.

Having said that, currently working on an Arduino winder and decided on stepper to enable the use of the accel library for the 44 gauge wire.

My existing cam grinder is mechanical feeder using optical cut out which is initially set to the cut out point and then backed out to start the grind.
Crankshaft grinder I built uses similar cut out detection only the operation there is via my own design PLC.
Accuracy of the optical units are repeatedly within 1/2 thou ".
 
Last edited:

SmithDoor

Well-Known Member
Staff member
Global Moderator
Joined
Feb 12, 2009
Messages
1,021
Reaction score
144
Location
Clovis Ca
I just use as counter and lathe . It has work for me over 50 years.

It simple way ,I have lathe and today any can use a padmeter you buy one at dollar store

Dave

FYI
I have built a cut to length machine for cos of steel using computer back in the 1980's but was for work and was used ever day.
 
Last edited:

retailer

Junior Member
Joined
Oct 13, 2011
Messages
163
Reaction score
59
All one has to do there is fit an optical counter on the shaft if the mechanics are already in place.
I was thinking of a a rotary encoder on the main spindle, but my machine is now built and working with a few dozen transformers under it's belt, so if I was going to make a cam grinder I'd probably do it from scratch.

The step distance on my winder is set with a 3 digit thumb wheel switch in increments of .02mm, I always measure the wire diam with calipers as wire tables don't always give the total diam inc. varnish so to wind .25mm diam wire the thumb wheel switch is set to either 012 or 013, both settings work equally well, the thinnest wire I have is No 42, to wind that wire I set the thumb wheel switch to 003, at that setting it winds perfectly with the turns side by side, I haven't yet had to make use of micro stepping.
I was going to make an all singing all dancing coil winder - just enter all parameters - bobbin width, wire size, number of turns etc and set it going, but in practice I found that is not needed, I can set the winder to count up to a certain number of turns and stop but I have yet to use that feature, if I was making another I wouldn't bother including that. The things I do use are - (1) foot switch for stop start, (2) auto stop at the end of each layer - if winding 1000 turns with 200 turns per layer, then auto stop at the end of each 200 turns so a layer of insulation can be added.
 

74Sprint

Well-Known Member
HMEM Supporter
Joined
Apr 21, 2013
Messages
128
Reaction score
34
Location
Winnipeg, Canada
All one has to do there is fit an optical counter on the shaft if the mechanics are already in place.

Having said that, currently working on an Arduino winder and decided on stepper to enable the use of the accel library for the 44 gauge wire.

My existing cam grinder is mechanical feeder using optical cut out which is initially set to the cut out point and then backed out to start the grind.
Crankshaft grinder I built uses similar cut out detection only the operation there is via my own design PLC.
Accuracy of the optical units are repeatedly within 1/2 thou ".
Cool, you always were a handy kind of guy.
 

74Sprint

Well-Known Member
HMEM Supporter
Joined
Apr 21, 2013
Messages
128
Reaction score
34
Location
Winnipeg, Canada
I just use as counter and lathe . It has work for me over 50 years.

It simple way ,I have lathe and today any can use a padmeter you buy one at dollar store

Dave

FYI
I have built a cut to length machine for cos of steel using computer back in the 1980's but was for work and was used ever day.
I never thought of using a pedometer. My original winder was going to be mostly mechanical, I even bought a cheap calculator to use as a winding counter. But I decided to give this way a try first.

Ray
 

74Sprint

Well-Known Member
HMEM Supporter
Joined
Apr 21, 2013
Messages
128
Reaction score
34
Location
Winnipeg, Canada
I was thinking of a a rotary encoder on the main spindle, but my machine is now built and working with a few dozen transformers under it's belt, so if I was going to make a cam grinder I'd probably do it from scratch.

The step distance on my winder is set with a 3 digit thumb wheel switch in increments of .02mm, I always measure the wire diam with calipers as wire tables don't always give the total diam inc. varnish so to wind .25mm diam wire the thumb wheel switch is set to either 012 or 013, both settings work equally well, the thinnest wire I have is No 42, to wind that wire I set the thumb wheel switch to 003, at that setting it winds perfectly with the turns side by side, I haven't yet had to make use of micro stepping.
I was going to make an all singing all dancing coil winder - just enter all parameters - bobbin width, wire size, number of turns etc and set it going, but in practice I found that is not needed, I can set the winder to count up to a certain number of turns and stop but I have yet to use that feature, if I was making another I wouldn't bother including that. The things I do use are - (1) foot switch for stop start, (2) auto stop at the end of each layer - if winding 1000 turns with 200 turns per layer, then auto stop at the end of each 200 turns so a layer of insulation can be added.
They say there is more than 1 way to skin a cat. I find all if not most DIY'ers are good at coming up with something to get the job at hand done. Necessity is the mother of invention. :)

Ray
 

SmithDoor

Well-Known Member
Staff member
Global Moderator
Joined
Feb 12, 2009
Messages
1,021
Reaction score
144
Location
Clovis Ca
A pedometer is electronic too.
It is not that avoid computers it just why make it so hard for simple project.
I just finished writing a program for Paint Yahtzee add in 3 of kind and small straight. Now it uploaded to internet for all

Dave

I never thought of using a pedometer. My original winder was going to be mostly mechanical, I even bought a cheap calculator to use as a winding counter. But I decided to give this way a try first.

Ray
 

davidyat

Well-Known Member
HMEM Lifetime Supporter
Joined
Dec 29, 2012
Messages
320
Reaction score
82
Location
Indianapolis, Indiana
This thread reminds me of the time I needed a charging coil for my 1974 Yamaha 175 off road motorcycle. My mentor, a master machinist, fixed up a wooden jig to hold the wire and I made a jig for the empty coil support for my lathe. After figuring out the size of the wire and how long, Ray figured out what screw thread setting for the lathe and we wound it up. I then mixed up some epoxy and coated the wire, turned on the lathe at the slowest setting and let it run till the epoxy set up. Installed it on the bike and it ran like a champ.
Grasshopper
 

74Sprint

Well-Known Member
HMEM Supporter
Joined
Apr 21, 2013
Messages
128
Reaction score
34
Location
Winnipeg, Canada
This thread reminds me of the time I needed a charging coil for my 1974 Yamaha 175 off road motorcycle. My mentor, a master machinist, fixed up a wooden jig to hold the wire and I made a jig for the empty coil support for my lathe. After figuring out the size of the wire and how long, Ray figured out what screw thread setting for the lathe and we wound it up. I then mixed up some epoxy and coated the wire, turned on the lathe at the slowest setting and let it run till the epoxy set up. Installed it on the bike and it ran like a champ.
Grasshopper
Funny you should mentioned the charging coil. My current project is a updated Krober ignition system that is fully programmable and uses no battery. So I need to make high voltage coils for the CDI part both charging and ignition and low voltage trigger coils. I have everything designed and/or built but, the coils and a dyno/test stand for the ignition. Trying to make it a direct replacement for the original Krober system. Which is why I want to use the PC for calculating and storing the different coils.
 
Top