C# program- g code with ABB robot?
charly99
✭
Hello
I'm trying to develop a school proyect using a 120-503244 ABB robot and a IRC5 controller
i have to do a 3D printer with the robotic arm
i want to do a program in C# preferently, in which i can import a g- code and sent it to the robot, or some function to send a rapid file to the robot
and some way at the same time to connect that C# program with pronterface software to be able to print
Now i have a C# program in which i can detected the controller and select the controller and start comunication with rapid, but the rapid program is on the flex pedant
this is the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ABB.Robotics;
using ABB.Robotics.Controllers;
using ABB.Robotics.Controllers.Discovery;
using ABB.Robotics.Controllers.RapidDomain;
using System.Threading;
namespace PCSDK_Csharp_BasicScanApp_560
{
public partial class Form1 : Form
{
private NetworkScanner scanner = new NetworkScanner();
private Controller controller = null;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void btnScan_Click(object sender, EventArgs e)
{
DisableControllerFunctionality();
listView1.Items.Clear();
this.scanner.Scan();
ControllerInfoCollection controllers = scanner.Controllers;
ListViewItem item = null;
foreach (ControllerInfo controllerInfo in controllers)
{
item = new ListViewItem(controllerInfo.IPAddress.ToString());
item.SubItems.Add(controllerInfo.Availability.ToString());
item.SubItems.Add(controllerInfo.IsVirtual.ToString());
item.SubItems.Add(controllerInfo.SystemName);
item.SubItems.Add(controllerInfo.Version.ToString());
item.SubItems.Add(controllerInfo.ControllerName);
this.listView1.Items.Add(item);
item.Tag = controllerInfo;
}
}
private void EnableControllerFunctionality()
{
// put all the enable and disable functionality in the same place so that it is easy to reuse
label1.Visible = false;
listView1.Enabled = false;
gbxControllerSelected.Visible = true;
}
private void DisableControllerFunctionality()
{
// put all the enable and disable functionality in the same place so that it is easy to reuse
label1.Visible = true;
listView1.Enabled = true;
gbxControllerSelected.Visible = false;
if (this.controller != null) //if selecting a new controller
{
this.controller.Logoff();
this.controller.Dispose();
this.controller = null;
}
}
private void StartProduction()
{
try
{
if (controller.OperatingMode == ControllerOperatingMode.Auto)
{
using (Mastership m = Mastership.Request(controller.Rapid))
{
this.controller.Rapid.Start();
}
}
else
{
MessageBox.Show("Automatic mode is required to start execution from a remote client.");
}
}
catch (System.InvalidOperationException ex)
{
MessageBox.Show("Mastership is held by another client. " + ex.Message);
}
catch (System.Exception ex)
{
MessageBox.Show("Unexpected error occurred: " + ex.Message);
}
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void listView1_DoubleClick_1(object sender, EventArgs e)
{
ListViewItem item = this.listView1.SelectedItems[0]; if (item.Tag != null)
{
ControllerInfo controllerInfo = (ControllerInfo)item.Tag;
if (controllerInfo.Availability == Availability.Available)
{
if (controllerInfo.IsVirtual)
{
this.controller = ControllerFactory.CreateFrom(controllerInfo);
this.controller.Logon(UserInfo.DefaultUser);
listView1.Items.Clear();
listView1.Items.Add(item);
EnableControllerFunctionality();
}
else //real controller
{
if (MessageBox.Show("This is NOT a virtual controller, do you really want to connect to that?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
{
this.controller = ControllerFactory.CreateFrom(controllerInfo);
this.controller.Logon(UserInfo.DefaultUser);
listView1.Items.Clear();
listView1.Items.Add(item);
EnableControllerFunctionality();
}
}
}
else
{
MessageBox.Show("Selected controller not available.");
}
}
}
private void btnProduction_Click_1(object sender, EventArgs e)
{
if (controller.IsVirtual)
{
StartProduction();
}
else
{
if (MessageBox.Show("Do you want to start production for the selected controller?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
{
StartProduction();
}
}
}
}
}
0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 316 IRC5
- 61 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 800 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings