Hello I try to simulate a 3D axis with Twincat (3) NC I and for now I'm stuck.
I use TC3 but there are lot of documents for TC2 so I started by this point:
http://infosys.beckhoff.com/english.php?content=../content/1033/tcnci/plclibconfiguration/html/TcPlcLibNcCfg_CfgBuild3DGroup.htm&id=
Unfortunately, I cannot open the samples with TC3 and in FB some inputs/outputs changed.
At the final step of the project, the 3 axis robot will receive positions data from external source (so for us it will be through ADS I guess) and will have to build and follow this path.
For now, I just tried to make a single line and to run it once.
I want to check my result through a scope project with ActPos of differents Axis (I made it with a small PTP 1 axis project last week with success).
Unfortunately, it's very hard to manage it because there are so much things to do and without guideline I can't figure out...
Here follows my source code if someone could have a look, I'd appreciate a lot!
Thanks
In NC / Motion I defined 3 axis (X,Y,Z) with Id = 1 to 3
I defined too a NC-Channel in this part with 1 group (group 4) and its Id = 4.
In PLC, references added: Tc2_NCI and Tc2_PlcInterpolation
GVLs:
VAR_GLOBAL
start AT %I* : BOOL; // Not used before HMI's design
done : BOOL := FALSE;
gstart : ST_NciGeoStart; // plc-g-code block to start
glinie : ST_NciGeoLine; // plc-g-code block to do one simple line
fbFeedTablePrep : FB_NciFeedTablePreparation;
fbFeedTable : FB_NciFeedTable;
configGroup : CfgBuild3DGroup;
entries : ST_NciFeedGroupTable;
entriesgrouptable : ST_NciFeedGroupTable;
c2p : NCTOPLC_NCICHANNEL_REF;
END_VAR
===========================
My only POU (no variables) with MAIN: gcodeprog (PRG)
IF done = FALSE THEN
// Config:
configGroup.nXAxisId := 1;
configGroup.nYAxisId := 2;
configGroup.nZAxisId := 3;
configGroup.nGroupId := 4;
configGroup.bExecute := TRUE;
// init Position:
gstart.fPosX := 0;
gstart.fPosY := 0;
gstart.fPosZ := 0;
// prep init config:
fbFeedTablePrep(
nEntryType := E_NciEntryTypeGeoStart,
pEntry := ADR(gstart),
bResetTable:= FALSE,
stFeedGroupTable := entriesgrouptable,
nFilledRows=>,
bError =>,
nErrorId =>);
// A simple Linie:
glinie.nDisplayIndex := 1;
glinie.fEndPosX := 200;
glinie.fEndPosY := 400;
glinie.fEndPosZ := 100;
glinie.fVelo := 100; (*mm per sec*)
// prep simple Linie:
fbFeedTablePrep(
nEntryType := E_NciEntryTypeGeoLine,
pEntry := ADR(glinie),
bResetTable:= FALSE,
stFeedGroupTable := entriesgrouptable,
nFilledRows=>,
bError =>,
nErrorId =>);
// Run the program:
fbFeedTable
(stFeedGroupTable := entriesgrouptable,
stNciToPlc := c2p,
bExecute := TRUE
);
// We want to run this program only once
done := TRUE;
END_IF
========================================
and the main:
gcodeprog(); // loop and loop again...
I use TC3 but there are lot of documents for TC2 so I started by this point:
http://infosys.beckhoff.com/english.php?content=../content/1033/tcnci/plclibconfiguration/html/TcPlcLibNcCfg_CfgBuild3DGroup.htm&id=
Unfortunately, I cannot open the samples with TC3 and in FB some inputs/outputs changed.
At the final step of the project, the 3 axis robot will receive positions data from external source (so for us it will be through ADS I guess) and will have to build and follow this path.
For now, I just tried to make a single line and to run it once.
I want to check my result through a scope project with ActPos of differents Axis (I made it with a small PTP 1 axis project last week with success).
Unfortunately, it's very hard to manage it because there are so much things to do and without guideline I can't figure out...
Here follows my source code if someone could have a look, I'd appreciate a lot!
Thanks
In NC / Motion I defined 3 axis (X,Y,Z) with Id = 1 to 3
I defined too a NC-Channel in this part with 1 group (group 4) and its Id = 4.
In PLC, references added: Tc2_NCI and Tc2_PlcInterpolation
GVLs:
VAR_GLOBAL
start AT %I* : BOOL; // Not used before HMI's design
done : BOOL := FALSE;
gstart : ST_NciGeoStart; // plc-g-code block to start
glinie : ST_NciGeoLine; // plc-g-code block to do one simple line
fbFeedTablePrep : FB_NciFeedTablePreparation;
fbFeedTable : FB_NciFeedTable;
configGroup : CfgBuild3DGroup;
entries : ST_NciFeedGroupTable;
entriesgrouptable : ST_NciFeedGroupTable;
c2p : NCTOPLC_NCICHANNEL_REF;
END_VAR
===========================
My only POU (no variables) with MAIN: gcodeprog (PRG)
IF done = FALSE THEN
// Config:
configGroup.nXAxisId := 1;
configGroup.nYAxisId := 2;
configGroup.nZAxisId := 3;
configGroup.nGroupId := 4;
configGroup.bExecute := TRUE;
// init Position:
gstart.fPosX := 0;
gstart.fPosY := 0;
gstart.fPosZ := 0;
// prep init config:
fbFeedTablePrep(
nEntryType := E_NciEntryTypeGeoStart,
pEntry := ADR(gstart),
bResetTable:= FALSE,
stFeedGroupTable := entriesgrouptable,
nFilledRows=>,
bError =>,
nErrorId =>);
// A simple Linie:
glinie.nDisplayIndex := 1;
glinie.fEndPosX := 200;
glinie.fEndPosY := 400;
glinie.fEndPosZ := 100;
glinie.fVelo := 100; (*mm per sec*)
// prep simple Linie:
fbFeedTablePrep(
nEntryType := E_NciEntryTypeGeoLine,
pEntry := ADR(glinie),
bResetTable:= FALSE,
stFeedGroupTable := entriesgrouptable,
nFilledRows=>,
bError =>,
nErrorId =>);
// Run the program:
fbFeedTable
(stFeedGroupTable := entriesgrouptable,
stNciToPlc := c2p,
bExecute := TRUE
);
// We want to run this program only once
done := TRUE;
END_IF
========================================
and the main:
gcodeprog(); // loop and loop again...