How to write analog input values to file on disk with macro
Posted: Thu Oct 26, 2023 9:33 am
Hi!
I'm a new forum user but long time user of the UCCNC-software on serveral machines. Based in Sweden.
In one of the machines, a simple CNC-controlled measuring machine, installed in a factory that manufactures plastic components, I have an AXBB-E motion controller with two "Sick Magnetic Cylinder Sensor - Position Sensor" connected to the AI1 and AI2 ports (analog inputs 0-5V). I run the AXBB-E controller with UCCNC.
The machine acts a simple measuring machine with two pneumatic cylinders that is measuring heights between 0-5 mm.
You put the product in and press start. The cylinders go down.
If the measurement is OK the product pass.
If the measurement is NOK the product failes.
The machine is working as intended.
However, I now want to record the measured heights and export the value to a text file on C: for statistics.
How do I do that within a macro?
I have found forum topics suggesting using something called "system.IO.StreamWriter" but if I add "using System.IO;" in my code it does not run the script I just get a syntax error from UCCNC.
This is how I collect the value from the analogue sensors.
Now, how do I write the values of AnalogIn1 and AnalogIn2 to a file on C:\ ?
Thanks for any suggestions.
I'm a new forum user but long time user of the UCCNC-software on serveral machines. Based in Sweden.
In one of the machines, a simple CNC-controlled measuring machine, installed in a factory that manufactures plastic components, I have an AXBB-E motion controller with two "Sick Magnetic Cylinder Sensor - Position Sensor" connected to the AI1 and AI2 ports (analog inputs 0-5V). I run the AXBB-E controller with UCCNC.
The machine acts a simple measuring machine with two pneumatic cylinders that is measuring heights between 0-5 mm.
You put the product in and press start. The cylinders go down.
If the measurement is OK the product pass.
If the measurement is NOK the product failes.
The machine is working as intended.
However, I now want to record the measured heights and export the value to a text file on C: for statistics.
How do I do that within a macro?
I have found forum topics suggesting using something called "system.IO.StreamWriter" but if I add "using System.IO;" in my code it does not run the script I just get a syntax error from UCCNC.
This is how I collect the value from the analogue sensors.
- Code: Select all
int AnalogIn1; //Variabel analog input 1
int AnalogIn2; //Variabel analog input 2
AnalogIn1 = exec.Getanaloginput(1) / 100; //Read analog input 1
AnalogIn2 = exec.Getanaloginput(2) / 100; //Read analog input 2
Now, how do I write the values of AnalogIn1 and AnalogIn2 to a file on C:\ ?
Thanks for any suggestions.