Programe de test NC
Description de la mise en oeuvre d'un programme de test
Ce programme fait tourner le moteur l'axe du moteur de 360[d] chaque seconde dans un sens puis dans l'autre
Ajout de la librarie MotionControl
Dans PLC-><MonProject>-><MonProject> Project->References->Add libraries...
Choisir: Motion->PTP->Tc2_MC2 (->OK)
Code
Faire un nouveau projet twincat (voir ce document), sous entendu que le commissing du moteur a ete fait et que le moteur tourne en manuel (voir ce document)
Taper le code du MAIN:
dans <MonProject>->PLC->AddNewItem->StandarPLC_Project
puis <MonProject>->PLC-><MonProject>-><MonProject project>->POUs->MAIN(PRG)
PROGRAM MAIN VAR ton1 : TON ; ton2 : TON ; fbPower : MC_Power ; fbMoveAbsolute : MC_Moveabsolute ; rotationNord : AXIS_REF ; // the following variables are defined only for visualisation/debug bBusy : BOOL; bError : BOOL; bStatus : BOOL; bActive : BOOL; udiErrorID : UDINT ; END_VAR
// Generate a sqare signal on ton1.Q ton1(IN := NOT ton2.Q, PT := T#1S); ton2(IN := ton1.Q, PT := T#1S); // Enable the Drive fbPower(Axis := rotationNord, Enable := TRUE, Enable_Negative := TRUE, Enable_Positive := TRUE, Override := 100.0); // Statuses visualisation bBusy := fbPower.Busy; bError := fbPower.Error; udiErrorID := fbPower.ErrorID; bStatus := fbPower.Status; bActive := fbPower.Active; // Move the motor only when the drive is ready IF bStatus THEN // Goto 360 on the raising edge of ton1.Q fbMoveAbsolute( Axis := rotationNord, Execute := ton1.Q, Position := 360.0, Velocity := 10000.0); // Goto origin (0) on the falling edge of ton1.Q fbMoveAbsolute( Axis := rotationNord, Execute := NOT ton1.Q, Position := 0.0, Velocity := 10000.0); END_IF
Mapping
Il faut compiler le projet: TWC3->BUILD->Build Solution
Puis:
Dans MOTION->NC-Task1SVB->Axes-><monAxe> (ici <monAxe> == RotationNord)
Dans l'onglet Setting, cliquer Link to PLC ...
choisir MAIN.rotationNord
Execution
Activer la configuration (TWC3 icone escalier de carre avec fleche jaune)
OK pour Activate Configuration
OK pour Restart TwinCAT System in Run Mode
login (TWC3 icone fleche verte dans Symbole de carre ouvert)
YES pour creer Port_851 et download
Start (icone fleche verte)
Arret
Stop (icone carre rouge)
Logout (icone fleche rouge sortant du carre ouvert)