Python for welding.

IT Programming for welding

Programming languages ​​are actually commands "easily" understandable by humans and which once recorded are interpreted or compiled (I will explain the differences later) by a program which takes care of translating the lines of code into language binary.

Bonjour in binary language

01000010011011110110111001101010011011110111010101110010



First

In the first case, we need a python interpreter and an IDE (Integrated Development Environment). So I recommend PyCharm open license (free ~_^)

I recommend, once you have downloaded the two programs to start by installing Python (32 or 64 bits depending on your operating system) and then installing« Pycharm ».

When the installation is complete, open Pycharm, then started a new project « file » > « New project »
Once the project creation window is open, you have to start by linking the python interpreter to Pycharm.

To find the interpreter made « windows + R ». next step %APPDATA% to get here.
Return to the Appdata folder, then « local » > « programs » and for finish « python » and find the interpreter.
Copy the interpreter adress then return to Pycharm selected « Existing interpreter » then paste the address of python and « Create ».

de Python à Pycharm

Here is our project created with success! to start the code, create a new file in python.
« file » > « new… » > « python file »

For start this tutorial, make:


print("Hello World")


Then click on the small green arrow at the top right.
de Python à Pycharm

Hello World is displayed in this window, good this is your first code !
Python is very easy to use. With this programming language , it is possible to do basic operations. (open your python interpreter with a Windows search)
For example simple calculations.


5*5

(* corresponding to a multiplication)

5623145 * 5115454)


the booleans (who returns «True» or «False» according to the result)


5 > 1
5 < 1
de Python à Pycharm

Now let's tackle the variables . These are extremely useful. They allow us to store values ​​in a box (the cat = value, the box = variable).


de Python à Pycharm

Values ​​can be strings of characters, numbers, and even operations ! But be careful to declare the "nature" of the variable . For example, for an integer, we will declare (int), for a decimal number (float) and for a character string (str).

Next, a variable cannot contain spaces. (an "underscore" _ can obviously be used as a space) Let's start by writing a variable "test" to which we will assign the sequence of characters " Steel Technics " in this way

test = ("Steel Technics")

Then « print » to display our variable.

test = ("Steel Technics")
print(test)

Let's run our code with the green arrow to see that our code returns the value registered in the variable «test».

de Python à Pycharm

Our code returns to us:

de Python à Pycharm

Second

In this second and last part, we will create a small program in python, thanks to it,
we will be able to carry out simple calculations in order to adjust our welding machine in process 111.
With python, we are going to create a control capable of directing us to the post amperage according to the coated electrode that we will choose for our weld.
The basic operation is: 50 x (thickness of the electrode - 1) = theoretical amperage for our weld.
So, to begin with, let's declare a variable this way.


electrode = int(input(« enter the thickness of your electrode.»))


Here, "int" means that we designate a whole number and the input command allows us to enter a value in our variable.
If you weld with a 2.5 mm electrode for example, it will suffice to replace "int" by "float".
Next, let's store the calculation in a “result” variable like this.

result = 50* int(electrode – 1)


Then let appear our result with:


print(result)


de Python à Pycharm


So first of all, our program asks us for an electrode thickness, I give it 2 mm. The latter performs the calculation and returns me a result:


de Python à Pycharm


Here is a short program in python, next update I will explain how to refine this program with the conditions .