Tuesday, 11 February 2025

Arduino time?

Thought process:

I seem to have concluded that I want the following features for my motorised torch head ("Motorhead"):

  • Variable speed of travel
  • Variable "spot welding" time
  • Control of the welder (to achieve the repetitive "stitch" welding behaviour)
  • Reasonably good speed control
This seems to confirm the direction I was heading last time, namely:
  • Use a stepper motor to achieve precise, variable speed control and "4WD"
  • Allow variable on time of the welder for the spot / stitch welding mode
Which pretty much means:
  • Arduino Nano for the microcontroller
  • A4988 stepper driver for the motor
  • NEMA17 motor with dual shafts (for the "4WD")
Let's get started:

So I got myself an Arduino Nano ESP32 - why not? 


Rather than simply have an add-on ESP32 for wifi and Bluetooth, "the Nano ESP32 features the ESP32-S3 system on a chip (SoC) from Espressif, which is embedded in the NORA-W106 module. The ESP32-S3 has a dual-core microprocessor Xtensa® 32-bit LX7".

The downside of this exciting feature set is evident when you compile even the simplest code. The first attempt took almost 5 minutes, leaving me wondering WTF was wrong with my laptop. It appears that there's nothing much you can do to speed it up - it's something to do with the much larger libraries that come with the SoC. Sod that - I've now ordered the more common or garden version of the Nano, aka Nano Every, which features a more conventional ATmega4809 processor.

I have an Arduino Uno R4 Wifi which also incorporates the ESP32 - but only as a peripheral. The microcontroller is a Renesas RA4M1, which is hopefully closer to the Atmel family and sure enough, it compiles much quicker (~20s, as opposed to ~5 minutes). I'm hopeful (hoping) that the Nano Every is similarly quick to compile for.

Also arrived today, what looks like a Chinese clone of the Pololu A4988 driver:


Program elements:

Timer:
Rather than use delays to implement on and off time, it's far better to run an endless loop and evaluate / toggle outputs against the required on and off times. This is referred to as "blink without delay" in the documentation. The issue with using delay is that it actually causes the program to stop execution until the delay has ended. If you wanted to do anything else during that time, you'd be out of luck. By running tasks in a loop, you can run multiple tasks independently and simultaneously. 

This is a common approach, one I seem to recall implementing over 40 years ago when I developed a 16 channel self tuning PID controller for my final year project at uni. That was written in Pascal (!) but to my mind it's actually quite similar to C. In contrast, my old, addled brain struggles with Pascal, which pretty much rules out using a Raspberry Pi.


void loop()

{
  // capture the current time
  currentMillis = millis();
  manageRedLed();
  manageGreenLed();
}

void manageRedLed() {  //check if it's time to change the Red LED yet
  if(currentMillis - previousMillisRed > redLedInterval) {
    //store the time of this change
    previousMillisRed = currentMillis;
    redLedState = (redLedState == HIGH) ? LOW : HIGH;
    digitalWrite(redLedPin, redLedState);
  }
}

void manageGreenLed() {
  //check if it's time to change the green LED yet 
  if(currentMillis - previousMillisGreen > greenLedInterval) {
    //store the time of this change
    previousMillisGreen = currentMillis;
    greenLedState = (greenLedState == HIGH) ? LOW : HIGH;
    digitalWrite(greenLedPin, greenLedState);
  }


I'll bugger about with this and perhaps evolve it into a pulse (stitch) control for the arc control.

Variable frequency pulse generator:

Here's some content that produces a variable frequency output. With some buggerage, I will aim to create a variable frequency output for the A4988 driver.

#include <TimerOne.h>


const int pulsePin = 9;
int inputFreq = 20;//Hz
unsigned long period;//microseconds

void setup(void)
{
  //Freq = (1/inputFreq)*1000000;
  period = 1000000/inputFreq;
  Timer1.initialize(period); 
  Serial.begin(9600);
}

void loop(void)
{
  Serial.println(period);
  Timer1.pwm(pulsePin, 40);//gives duty cycle of 3.9%
}

Analogue input for frequency and duty cycle control:


int sensorPin = A0;   // select the input pin for the potentiometer
int ledPin = 13;      // select the pin for the LED
int sensorValue = 0;  // variable to store the value coming from the sensor

void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);
  // turn the ledPin on
  digitalWrite(ledPin, HIGH);
  // stop the program for <sensorValue> milliseconds:
  delay(sensorValue);
  // turn the ledPin off:
  digitalWrite(ledPin, LOW);
  // stop the program for <sensorValue> milliseconds:
  delay(sensorValue);
}


I will bugger about with that and implement it as the input(s) to control the speed and duty cycle.

Trigger input:

I'm looking for a high / low switch status rather than an analogue signal. Here's some example code.

void setup() {
  //start serial connection
  Serial.begin(9600);
  //configure pin 2 as an input and enable the internal pull-up resistor
  pinMode(2, INPUT_PULLUP);
  pinMode(13, OUTPUT);
}

void loop() {
  //read the pushbutton value into a variable
  int sensorVal = digitalRead(2);
  //print out the value of the pushbutton
  Serial.println(sensorVal);

  // Keep in mind the pull-up means the pushbutton's logic is inverted. It goes
  // HIGH when it's open, and LOW when it's pressed. Turn on pin 13 when the
  // button's pressed, and off when it's not:
  if (sensorVal == HIGH) {
    digitalWrite(13, LOW);
  } else {
    digitalWrite(13, HIGH);
  }
}

That's my starting point.

Some quick sums:
  • Motor drive pulses: With a 25mm dia / 75mm circumference wheel and weld spots 5mm apart, fired once per second, I'd want @15 seconds per rev of the wheel. Ignoring the gear ratio between the motor and wheel and assuming 200 steps per rev, I would need a pulse frequency of ~13 pulses per second. Allowing for some adjustment, that might result in 5-25Hz. If I implement microstepping at x16 (to minimise noise etc), that would translate to 80-400Hz.
  • Duty cycle: I'm guessing ~1Hz or so hard coded pulse frequency and 10-100% duty cycle to give good control over the pulse duration.
Releasing the trigger shouldn't result in immediately killing the arc. I'd want the pulse to finish ie not to be followed by another.

Similarly, the trigger should initiate a complete pulse, not a fraction of the steady state output.

Motorhead?

What??

Just got these motor-gearbox thingies from Amazon, along with some PWM drivers for brushed DC motors.


Nothing special. They have interchangeable gears, providing a wide range of reduction ratios. 


Being a nosey b4stard, The Stupid Fat Bloke took the smaller one apart and managed to drop the guts on the bench by opening it upside down. There's a load of different gears and spacers that have to be assembled in the correct positions before the lid will go back on, so I had to figure that all out for him.





What's going on now, Fatty?
10 years ago, I made this little powered trolley thingy. Little stepper motor with (high temperature!) O-rings and a small stepper motor.





The stepper is driven by an MSP430 eval board aka "Launchpad", fitted with an "Easydriver" stepper driver board


The Linbin is simply a means of avoiding accidental short circuits and blowing the thing up.


The Schmalzhaus stepper driver is an Allegro A3967 that takes a step/dir signal and drives the motor. The MSP430 is simply being used as a pulse generator. I don't recall why I went this route but certainly there are simpler means of generating pulses and ideally it would be possible to change the frequency (speed) of the drive.

Then there's also this thing:


Inside there's a PP3 9V battery and a brushed DC motor driver.


After 10 years, the battery still has some electrons to spare, although not enough to actually turn the motor.



This DC motor driver seems to be from Canakit. This is a very simple PWM generator with a FET and flywheel diode, driven by a 555 timer. Hardly the height of sophistication.


It simply drives the large wheel (also sporting a high temperature O-ring)


What's the point of all this?

Perhaps this will help. 


Yes, it's a motorised head for driving a MIG welding torch. It was originally aimed at helping me to weld exhaust pipes, where consistent welding conditions are critical if you want to avoid blowthroughs. 

It was showing some promise when I had to pack it all away (something to do with moving the workshop, house and family back to the UK from Canada). It was showing promise:





And the bits I just acquired are intended to be another attempt at making one of these.


There are a couple of other bits and pieces I bought back then of varying appropriateness, including this thing. The least said the better...


Another escapade with Chinese connectors:

Yes, I'm thinking how I might make a useable version of the above, with a view to integrating it with the MIG welder.

How would I get the welder and the motorised head to operate together? Ideally the motor would come on when the torch trigger is pressed - and would be powered by the welder.

Battery power is all very well but the MIG has a connector on the front for powering the spool gun, so it makes sense to see if I could use that to power any such device. Here's the plug on the spool gun - China's finest:


It looks like this one. It seems to be described as another "aero connector", although I'd be concerned if any aircraft I travelled on sported these things. Either way, here's the socket on the front of the MIG machine:


And here's what's shown in the manual. No voltage specified:


This is what turned up from Amazon. Close - but no cigar. Can you see the problem?


Yes, the welder has female contacts and the Amazon product also has female contacts. Doh.


I bought 2 sets of these male/female connectors, so I can butcher one of them if necessary. Obvs I'd rather not but at £4 each, it wouldn't be the end of the world if I can come out of it with only one surviving connector that mates with the welder.


The central body is a slight rattle fit in the outer body and the rear has a larger diameter than the front, so clearly it's been push fitted in from the back with some form of ramp / latch to retain it. 

Sure enough, it's a simple matter to press the central body back out of the outer housing.


I was then able to push the alternative central guts back into the outer body.


Bottom line- yes, it works.


I now have 2 sets of connectors of each polarity. I can swap the remaining pair over if I find I need a second set.


How does the spool gun operate with the MIG welder?

The trigger switch on the spool gun operates a NO switch which energises the welding power to the torch. If the spool gun mode is selected from the front panel, the main feed motor is disabled and instead, the power for the feed motor is diverted to that 4 position connector (pins 1 and 2). The voltage measures as 22Vdc with no load connected. That's pretty much as you might expect.

So if you wanted to power a torch motor (to move the torch along the weld line), you might want to use that front connector - but unfortunately it will only work when the spool gun is being sued ie no use when you are using the main wire feed.

I guess I could modify the main unit so that 22V is fed to the 2 spare pins on the connector - or use a battery. Not what I would consider ideal.

What's the plan then, Fatty?

Looking at the various artefacts and having a play with them, I've concluded the following:
  • "One wheel drive" on a 4 wheeled bogie isn't a great concept. Unless you apply constant pressure to the one driven wheel, the "cart" version doesn't have any traction.
  • The "square tube with the big wheel" thingy isn't a serious option, apart from being obviously fragile in its current state. I quite like the idea of a single wheel adjacent to the torch head but to begin with I feel more interested in pursuing the 4 wheeler concept. I might come back to this later.
  • The 4 wheeled bogie would be greatly improved if both wheels on each side were driven. This could be achieved by fitting a longer o-ring (drive belt) that goes around the motor and both wheels. I might refer to this as the "tracked" concept.
  • Changing to a "dual shaft" motor (where the output shaft comes out both ends of the motor) would allow both sides to be driven.
  • Trying to use the tracked concept on an inside corner might be tricky. I could imagine it being possible but TBH, this isn't really the target application, which is more sheet metal and thin pipe.
So, if I implemented this scheme on both sides of the motor, using a dual/double shaft motor, I'd achieve a sort of "all wheel drive" scheme, almost akin to a tracked vehicle. It would also be suited to running around the outside of a pipe.


The o-ring would ideally be rated for a fairly high temperature. Viton (FKM or "fluorinated") is suitable over 200C, whereas the default nitrile isn't much use above 120C or so. FFKM is rated even higher but is much more expensive - I can always get some later if / when I conclude this concept has legs. Silicone rubber would survive high temps but it's far too elastic (soft) to work as a traction element.

This motor is 42x42x34mm ie same size as previous but with dual shafts. At a tenner each plus postage, that doesn't seem like a bad deal, assuming they are a genuine outfit.

How to interface with the welder?

Unlike the old CEA MIG I have just jettisoned, the Arc Captain MIG200 doesn't have a pulsed "stitch" welding mode. It has a "spot welding" mode which energises the arc for a fixed on time after the trigger is pressed.

I'm thinking that I'd probably use an Arduino Nano to drive the Schmalzhaus stepper motor shield (or similar). It could also control the distance between "spots" (aka "dimes" to the Youtube warriors), independent of the speed of the torch. The number of step pulses to the motor and the distance between spots would be ratiometrically fixed - so I'd have one pot for speed and another for spot distance. The welder would be triggered by the Arduino to produce each spot weld.

Friday, 31 January 2025

Changing a MIG welder to run flux cored wire

I'm going to get shot of my old 180A MIG and SIP 140A stick welders, as they are now surplus to requirements due to the presence of various inverter machines.

Here's the MIG. It's an ancient CEA (Italian) machine that I bought from a dealer near Cambridge back in the noughties. Sometimes a bit intermittent but mostly it's been pretty good and has been good for welds up to perhaps 8mm or more.


It has a perch for a gas bottle, large enough for the Y size (303mm dia) bottles I have from BOC.


It takes reels from 5kg to perhaps 15kg, judging by the space in the wire feeder zone:



This is a "Micro CAR 180" with stich and spot welding timers. Requires 25Arms when running at full chat although the duty cycle is going to be rather limited at that output, so it's unlikely we'd ever need to fit a proper 16A or 32A plug. I've always used a std 13A jobbie which has never got particularly hot and is notoriously overdesigned anyway, in terms of current rating. As for the ring mains, the wiring and circuit breaker are designed to deliver 30A


Back in the Noughties when I acquired this machine, I contacted the factory in Italy and was lucky enough to be able to get a PDF of the manual. Even then it was regarded as an old, obsolete machine. However, the schematic shows the simplicity of such a mains powered welder:



And the construction is pretty simple:

The most sophisticated (technically risky) part is the PCBA which contains the timers for the stich / spot welding function and the variable speed drive for the wire feed.

The plan is to convert it to run on flux cored / gasless wire. That way it won't be necessary for the new owner to get involved with hiring bottles of argon / CO2 mix. In essence, it requires a change in polarity from DCEP to DCEN ie the torch should be changed to negative polarity from its default of positive. Hopefully won't be difficult to do but let's find out....

Anyway, off with the cover. Yes, it's pretty old. I didn't look for date codes on the compts but I would guess 80s or so.


The black and red wires running along the bottom of the tray are the ground and torch connections. I'll want to swap those over in order to run FCW. 

Bizarrely, the red wire is actually the -ve polarity and the black is +ve. Go figure. You can see this when you trace the connections back to the blue electrolytic cap. I powered it up and checked the voltage on the cap and it is indeed as marked.


The transformer is bottom left and there's an output inductor (the vertically wound cylinder), although it can't have much inductance as it looks to be air cored.


You can see the wire feeder at the top of the pic here. Interestingly, it is insulated from the chassis by those plastic mounts. However, note the protective earth connection at the middle left of the pic.

Looking carefully, you can see that the TO-220 devices have date code "8206", which perhaps dates the welder to 1982, assuming that both devices haven't been replaced. That looks and feels about right, given the general construction and appearance of the internals.



Here's the (output) electrolytic cap. As you can see, the black wire is connected to the +ve terminal. I suspect this may have been replaced at some point, although I didn't bother looking for a date code on it to confirm:



Polarity confirmed with the DVM:


I've swapped the wires across. I haven't reformed the red wire into a rectilinear path, as it may need to be put back later. It's aluminium, so won't take kindly to repeated bending. This was "the path of least bend", rather than "the path of greatest aesthetics".


And yes, it's now reverse polarity ("DCEN").

Covers back on, quick clean up with some Elbow Grease degreaser / cleaner.




All I need now is some flux cored wire. I won some 0.5kg reels of 0.6mm and 0.8mm in LIDL last week but discovered that the reel carrier in this machine won't accept anything less than 5kg. Doh.

Vevor sell 4.5kg reels of E71T-GS flux cored wire for £20, which is considerably less than most places - but how about paying £150 for something very similar? I should have a reel of the Vevor stuff here tomorrow....

Apart from testing its operation as a flux cored / gasless machine, that looks like a success for now. Bargain buckets!

Update 3rd Feb: Vevor wire arrived as promised.

0.8mm (0.03") flux cored "gasless" wire in 10lb / 4.5kg reel.

Loaded onto the machine with the aid of a spacer - I think this machine expects a 10kg or15kg reel. Managed to thread the wire through the feeder without it "escaping" from the reel

Without any thought or planning, I wopped the machine on to setting #8 (fairly high current, second highest setting). No idea what the voltage / current or wire speed was but it seems to have worked OK:

And of course it requires the slag to be cleaned off, despite being a MIG process. It looks almost credible.

I think I can now call this a success.

Arduino time?

Thought process: I seem to have concluded that I want the following features for my motorised torch head ("Motorhead"): Variable s...