Hello everyone!
I am a mechanical engineering student currently making my master thesis and I do not have much programming experience. Hopefully someone can help me here.
I am making the control of an Additive Manufacturing machine, that directly melts powder metal through a laser.
I have feedback control, with a pyrometer (temperature sensor), and a 200W Fiber laser to melt the metal. The PID controller is ready to be calibrated, my only issue is the communication to the laser control board.
The laser uses a RS-232 interface. I leave below the user's manual Rs232 Laser Interface description.
########################## RS 232 INTERFACE DESCRIPTION ####################
"A three wire (RxD, TxD, GND) interface is used. Most computers are DTE (Data Terminal Equipment) devices. The laser is also a DTE device and therefore you must use a DTE-to-DTE interface cable. These cables are also called null-modem, modem-eliminator, or crossover cables. In addition, the interface cable must have the proper connector on each end. Cables typically have 9 pins (DB-9) or 25 pins (DB-25) with âmaleâ pins or âfemaleâ receptacles inside the connector shell. For RS-232 connections on the rear panel of the Laser Driver please refer to the interface connector pin out. The other end of this cable needs to match the computers interface connector. Remember that this cable must be wired in a null-modem or crossover configuration.
The RS-232 interface has been set to the following parameters:
Baud Rate: 57600
Data Bits: 8 Bits
Stop Bits: 1 Bit
Parity: None
Flow Control: None
Note: After power on the laser sends some service bytes to RS-232 interface. These bytes should be ignored.
All commands and responses will consist of printable ASCII characters. Commands are typically a 3 or 4 letter mnemonic followed by a parameter, if required.
All commands and responses will be terminated with a âcarriage returnâ (CR, 0x0D, \r) character. If a CR terminated string is received, but no valid command is found, a response of âBCMDâ will be sent.
The commands are shown here as all uppercase for clarity; the actual commands are not case sensitive.
A space character is also shown between the command and parameter for clarity.
Every command will generate a response. The responses generally consist of the command echoed back.
If there is a returned value, it will be separated from the echoed command by a â:â character." "
###############################################################
The next pages show the several instructions the laser understands and their description.
(users guide of a more recent fiber laser: http://www.uwlaser.com/uploadfiles/2020/04/20200423170358358.pdf )
On pages 78-forward you can see the type of instructions the laser control board understands (My laser is not as recent as this one, but the communication seems to be simmilar. They are the same manufacturer).
I know this is very dumb but previously I was hoping to code : "Serial.print(" "INSTRUCTION" "); and the laser would respond accordingly, but (probably obviously ahaha) this was not the case.
I have the baud rate set correctly (57600).
Previously I was able to successfully communicate with the laser control board using a common terminal emulation program for RS-232, just by typing the users manual instructions (such as, for example "ABN" or "ABF" which turn ON and OFF a laser guide).
To conclude, I am using an Arduino Uno, with a TTL to RS232 converter.
My main question is, (since I am not that good at programming), how should I write my code?
Is there a library that can help me?
How should I setup the "Serial." communication for the laser to understand me?
Thank you very much for your time.
EDIT:
You can see my code in the comments below