- Posts: 12160
- Thank you received: 0
Useful Plasma Thread
Anyway, a couple of things.
Mesa THCAD-10 calibration
You don't need to worry about calibrating the Mesa THCAD as PCW has already done it for you for each individual board and applied a label to each board.
This earlier post is a component to decode the THCAD-10 data using that calibration data and has a pin to output the current volts. forum.linuxcnc.org/plasma-laser/32585-scalethcad-component .
Its tested and works well on my config.
I'm still not sure why we use the raw voltage (maybe only for display purposes) as the encoder frequency could be used without conversion.
If you grab a couple say of 48v power supplies and connect them in series, you have 96 volts and you can apply that as the input to your plasma cutters voltage divider board to check functioning. I found this useful.
Corner Lock
This thread includes a corner lock component that I have used for a long time so its proven and working. It outputs a signal to say hold the THC function forum.linuxcnc.org/plasma-laser/32658-thc-cornerlock-component
So this simply looks at the current velocity adjusted for speed override and asserts a hold signal when it falls below a set threshold say 80% of the commanded velocity.
Kerf Crossing
The attached chart shows what happens to torch voltage when crossing a kerf (data from a hal plot at 200 Mhz sample time:
Attachment not found
So if we use a moving average, we can compare the change in voltage over this time period with the average over the last 100 readings and if it differs significantly, we hold THC behaviour. In practice however, I think a single servo period is too short to be doing the comparison with as normal hysteresis around the torch voltage set point might be enough to trigger the component from one period to the next.
Torch Sampling using Moving Average
I have not published this before so the man page might be wrong but this component calculates a moving average for BUFFSIZE readings (currently 100 but can be changed in the code) and samples the Average Torch volts when a signal from a delay component after ArcOK goes true. Its been tested enough to know it works (I think, at least I know the buffer does not overwrite other memory).
Attachment not found
Conceptually, a moving average is very simple using a loop but in the servo thread we cannot use loops so we do some tricks separated into a separate procedure avgarcvolts().
We use pointers to read the readings into the buffer but if we sum the values and allow the buffer to fill (during the THC time delay), we subtract the oldest reading in the buffer and add the newest buffer reading. With this in mind, in a circular buffer, the oldest reading is the one in front of the current pointer position (assuming the buffer logic wraps the pointer from the last buffer position to the first automagically).
Its worth mentioning that the torch should not be sampled unless its near (say 95%) of programmed cut velocity as its possible that the trajectory planner may have reduced the cut velocity below what has been requested for a given line segment at the time you sample the volts. So that is the reason for the Case statement and the component will sit patiently in an ARMED state until this occurs.
Next Steps
My next step was to separate out the moving average into its own component so it can be used for both Kerf Crossing and Torch sampling. I think I should include the ability to create multiple instances with a different buffer size as it might be useful to have a long average and a short average (of say 5-10 readings) for different comparisons.
I also think that the THC component should be kept totally separate from the touchoff component. I'm not tested it yet, but I suspect that there would be merit in moving the THC component onto a separate slower thread (maybe at 200 Hz?) to allow time for the motor to reach its commanded position on a given adjustment before moving it again. This is just based on a lot of reading I have done about PID control and some comments from Hypertherm shared on my Spaceship Plasma Build thread.
I hope this helps.
Please Log in to join the conversation.
tommylight wrote: On the other side, the THCAD with any Mesa board can measure the torch voltage 1000 times per second, and that is to much for what it needs to do,\.
Tommy posted while I was writing my last post. I think he confirms my thinking about keeping the actual THC component on a seperate thread where it can be running at a slower time frame (or it skips a few servo thread cycles between actions). Thanks Tommy!
Please Log in to join the conversation.
Russian Anonimouses. :woohoo: Are they into the bios ? They will eat your desktop pc in one day....I just tried to boot into Linux on my desk PC but it failed for some reason and left me at the command prompt.
Thanks for your post Rod. I will investegate your diagram carefully.
I have made a short example of code for logging the program for 5 seconds with 0.1 seconds interval time.
Here off we can make multiple calculations for making the best choice for the machine by itself. User's can select type of calculation.
@Tommy,
the 5 second's or longer can display your cutting charts. After cutting, the chart's can say if you was a good cutter or a bad cutter.
The ultimate line stay's stady. But fluctuence's have to be avoid. Kerf crossing and corner lock is one of them.
At the logging every 0.1 second. The machine can make a desicion on the past logging. Will i go this way, or wil i go for improvement? Users can select a cutting chart. I think there will be 3 charts. 3 types of calculating. I think logaritme i will also try to use for fun, if possible.
Please Log in to join the conversation.
fperiod is not guaranteed to be exact if the thread is early or late so testing for equality is not going to work every time. you need to do a if... else if... else if ... and test for > T1, T2 etc. Steal The buffer approach using pointers I shared and see how you go. Just change the BUFFSIZE to 5000.
Please Log in to join the conversation.
Was it a linux mint desktop environment? :whistle:
Attachment not found
So yes, why not switch to debian? :side:
Still having russian anonimouses, switch to Kali and strike back. :woohoo:
I also think that the THC component should be kept totally separate from the touchoff component.
First i thought also to build in blocks, i agree.
But now i think, if the component stay's structurized, it's easy to implement. Some guy's have 1000 lines of C code. :woohoo:
From what i know now, the touch off procedure takes about a max of 20-25 line's of C code. This is easely to implement in the same component. When i got it finished, i will show it to you coming day's. It's hot on my to do llst.
I agree when it has no probe function included (touch off)I think he confirms my thinking about keeping the actual THC component on a seperate thread where it can be running at a slower time frame
Hmm 200 Mhz.. This diagram looks to fast to make a conclusion for me. I can't figur out what the scaling value's are, sorry.The attached chart shows what happens to torch voltage when crossing a kerf (data from a hal plot at 200 Mhz sample time:
If i can see a chart of a periode of time T versus volts V, i can imagine how the arc is responding.
Torchsample.3 is a nice piece of code. I must get a lession of c code to get as good as you !!
I will remind this, nice info. This week i will get some time to program and learn of your code examples, hopely i don't have to cook indonesian hot chicken. :laugh:Steal The buffer approach using pointers I shared and see how you go. Just change the BUFFSIZE to 5000.
Please Log in to join the conversation.
And there is no need to buy a data logger. You can use the Halsampler and sample components and log data to a file every servo thread cycle for further analysis in a spreadsheet. I captured 16000 readings of torch voltage using this method.
So I want to recapture the dV/dT data using Halsampler.
An alternative to a seperate thread is to skip a number of servo thread cycles. This is easy to do using a counter and modulo division something like
Please Log in to join the conversation.
This example helps me :
Then this one : return 1;
Sometimes is see return 0;
And when to use static variables.
Please Log in to join the conversation.
By default variables defined in a procedure are thrown away and the memory released when you exit the function so the memory can be reused. The static modifier defines the variable in static memory so it is not thrown away and retains its value when the function is next called. You can use global variables but that is a bit messy if a procedure is the only one that needs the variable.
Procedures can optionally return a value and the type is defined in the prototype. heres a simple example that returns the sum of 2 values:
so you might write
Butt often the return value is used to denote an error occurred.. Generally 1 for an error or 0 for valid result
say it was an error if a or be was > 100, we might return the answer by reference like this
and you might call it like this:
Through the magic of pointers, if valid values are passed, answer will still have the correct answer!
Finally, often we don't bother with the intermediate value (retval in the example) and would often write it like this:
Its up to you to decide what the error numbers are. Sometimes -1 is used. Often there will be a whole host of equates defined so different errors can be identified.
Please Log in to join the conversation.
I have made some progress the last day's with up's and down's in C code.
Thanks, Rod, for your e-mail examples.
For example, i made 2 brand clean configurations. Started with zero code, just to be sure.
One without external offsets. This was hard to program. It's just not made
for thc function's. After spending a lot of time in that, i switched to external offset's. This was much easyer to write C code for.
The difficulty in the standard linuxcnc distibution is that making offset's and stay them in line is a little bit of hard to do with a few lines of code for a new C programmer. Maybe over a few years i will say, yes i missed something in that time, now it's easy. :laugh:
Today cutted a sample for my wife with the new C code. After tuning a few gui parameters, it cut's better then Mach3 windows.
But it's a long way to the top. At the picture my nozzle was damaged, so i am not satisfied about the holes.
I would like to make contact coming time with the Russian cnc forum that has made the Inkscape plugin.
My investegation is import a dxf right into the gremlin screen as g-code with inkscape only loaded as blockchain.
My C code language is improved a little bit, With compiling i get less errors, because you know how to use the language.
Here a example code that i used with succes, it's still basic in the eye of the C-coder,
The code is only related to the probe function :
Attachment not found
Attachment not found
The C code example is only for using the Probe function. This was the most difficult function to make. So i started with a
working probe function in C. The normal code without probe i made and is much easer to write.
So we are at the good way. I need to save the linux screen parameters automaticly. Maybe someone has an idea?
Yes, A difficult item when coding:
If you want to go to zero, check zero, and current z axis height value is : 0.0025
You have a big problem if you are using float variables.
So at the moment i map the z axis value at zero or a certain point. I used an integer value wich is : 0 or 1 or 2.
This solves many issues. For example. Are we on pierce height? Are we on cutheight? If we almost get there the integer will say
okey it's true. But solving little axis feedback and command values differences are in C coded hard to make straight.
Please Log in to join the conversation.
