Share GTS-800 Two-time development process steps

Source: Internet
Author: User
1, open the controller gt_open2, start servo enable GT_CLRSTS3, axis planning position clear 0 gt_setprfpos4, Axis motion mode GT_PRFTRAP5, axis target position gt_ SETPOS6, shaft rotation speed GT_SETVEL7, start shaft gt_update8, turn off enable GT_AXISOFF9, close controller Gt_close
C#:using system;using system.collections.generic;using system.linq;using system.text;using gts;namespace GTS{class Pr        ogram {static void command (String sz, short NR) {Console.WriteLine (sz + "=" + NR);            } static void Main (string[] args) {Short mAxis = 2; Short NR = MC.            Gt_open (0, 1);                if (nr! = 0) {command ("Gt_open", nr);                Console.WriteLine ("Open error");            Return            } command ("Gt_open", NR); Clear the Alarms and limit command for each axis ("Gt_clrsts", MC.)            Gt_clrsts (MAxis, 1)); Servo enable command ("Gt_axison", MC.            Gt_axison (MAxis)); Position Clear 0 Command ("Gt_zeropos", MC.            Gt_zeropos (MAxis, 1)); Axis planning Position Clear 0 command ("Gt_setprfpos", MC.            Gt_setprfpos (MAxis, 0));            Sets the specified axis to the point movement mode. Command ("Gt_prftrap", MC.            Gt_prftrap (MAxis)); Sets the point-position motion parameter MC. TtrapPRM trap = new MC.            TTRAPPRM ();            TRAP.ACC = 0.25;            Trap.dec = 0.125;            Trap.smoothtime = 25; Command ("GT_SETTRAPPRM", MC.            GT_SETTRAPPRM (MAxis, ref trap)); Set the target position of the axis command ("Gt_setpos", MC.            Gt_setpos (MAxis, 50000)); Set the target speed command for the axis ("Gt_setvel", MC.            Gt_setvel (MAxis, 25)); Start the Axis motion command ("Gt_update", MC.            Gt_update (1 << mAxis-1)); Mc.            Gt_close ();        Console.readkey (); }    }}
C + + Source: #include "stdafx.h" #include "windows.h" #include "conio.h" #include "gts.h" #define axis1//The function detects the execution result of a GT instruction, command for instruction name, error for instruction execution return value void CommandHandler (char *command, short error) {///if instruction execution return value is not 0, instruction execution error, error result to screen output if ( Error) {printf ("%s =%d\n", command, error);}} int main (int argc, char* argv[]) {short srtn; TTRAPPRM Trap;long sts;double prfpos;//Open Motion Controller SRTN = Gt_open ();//instruction return value detection, please refer to Example 2-1commandhandler ("Gt_open", srtn);// Configure motion Controller//NOTE: The configuration file cancels the alarms and limits of each axis SRTN = gt_loadconfig ("test.cfg"); CommandHandler ("Gt_loadconfig", srtn);// Clear the alarms and limits of each axis SRTN = gt_clrsts (1, 8), CommandHandler ("Gt_clrsts", srtn);//servo Enable SRTN = Gt_axison (axis); CommandHandler ("Gt_ Axison ", SRTN);//Position 0 Srtn = Gt_zeropos (AXIS); CommandHandler (" Gt_zeropos ", srtn);//axis axis planning position 0 Srtn = Gt_setprfpos ( axis, 0); CommandHandler ("Gt_setprfpos", srtn);//The Axis axis is set to point mode Srtn = gt_prftrap (axis); CommandHandler ("Gt_prftrap", SRTN);//Read point motion Parameters Srtn = GT_GETTRAPPRM (AXIS, &trap); CommandHandler ("GT_GETTRAPPRM", srtn); TRAP.ACC = 0.25;trap.dec = 0.125;trap.smoothtime = 25;//Set point motion Parameters Srtn = GT_SETTRAPPRM (AXIS, &trap); CommandHandler ("GT_SETTRAPPRM", sRtn);// Set axis axis target position Srtn = Gt_setpos (axis, 50000L), CommandHandler ("Gt_setpos", srtn);//Set axis axis target speed SRTN = gt_setvel (axis, 50) ; CommandHandler ("Gt_setvel", srtn);//Start Axis axis Motion Srtn = Gt_update (1<< (AXIS-1)); CommandHandler ("Gt_update", SRTN);d o{//reads the state of the axis axis Srtn = gt_getsts (axis, &sts);//Read the planning position of axis Axis Srtn = Gt_getprfpos (axis, &prfpos);p rintf (" Sts=0x%-10lxprfpos=%-10.1lf\r ", STS, Prfpos);} while (sts&0x400);//wait for axis axis planning stop//servo off SRTN = Gt_axisoff (AXIS);p rintf ("\ngt_axisoff () =%d\n", Srtn); Getch (); return 0;}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.