GTS-800 Secondary Development Process summary, gts-800 Secondary Development

Source: Internet
Author: User

GTS-800 Secondary Development Process summary, gts-800 Secondary Development
1. Open the Controller GT_Open2. Enable the servo to enable GT_ClrSts3, clear the axis planning position, rotate the axis movement mode, GT_SetPos6, GT_SetVel7, GT_Update8, and disable GT_AxisOff9. disable controller GT_Close

C #:
Using System; using System. collections. generic; using System. linq; using System. text; using gts; namespace GTS {class Program {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 alarm and limit command ("GT_ClrSts", mc. GT_ClrSts (mAxis, 1); // servo enabling command ("GT_AxisOn", mc. GT_AxisOn (mAxis); // location clearing command ("GT_ZeroPos", mc. GT_ZeroPos (mAxis, 1); // axis planned position zeroing command ("GT_SetPrfPos", mc. GT_SetPrfPos (mAxis, 0); // you can specify the axis as the point motion mode. Command ("GT_PrfTrap", mc. GT_PrfTrap (mAxis); // sets the point 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 of the Axis command ("GT_SetVel", mc. GT_SetVel (mAxis, 25); // start Axis Motion command ("GT_Update", mc. GT_Update (1 <mAxis-1); mc. GT_Close (); Console. readKey ();}}}
C ++ source code: # include "stdafx. h "# include" windows. h "# include" conio. h "# include" gts. h "# define AXIS1 // This function detects the execution result of a GT command. command is the command name, and error is the return value of void commandhandler (char * command, short error) {// if the returned value of the command execution is not 0, it indicates that the command execution is incorrect. if (error) {printf ("% s = % d \ n", command, error) ;}} int main (int argc, char * argv []) {short sRtn; TTrapPrm trap; long sts; double prfPos; // enable the motion controller sRtn = GT_Open (); // check the returned value of the command. For more information, see Example 2-1 commandhandler ("GT_Open", sRtn). // configure the motion controller // note: the configuration file cancels the alarm and limit 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 enabling sRtn = GT_AxisOn (AXIS); commandhandler ("GT_AxisOn", sRtn); // position clearing sRtn = GT_ZeroPos (AXIS); commandhandler ("GT_ZeroPos ", sRtn); // AXIS planned position erasing sRtn = GT_SetPrfPos (AXIS, 0); commandhandler ("GT_SetPrfPos", sRtn ); // set the AXIS to position mode sRtn = GT_PrfTrap (AXIS); commandhandler ("GT_PrfTrap", sRtn); // read the position motion parameter sRtn = GT_GetTrapPrm (AXIS, & trap); commandhandler ("GT_GetTrapPrm", sRtn); trap. acc = 0.25; trap. dec = 0.125; trap. smoothTime = 25; // set the position motion parameter sRtn = GT_SetTrapPrm (AXIS, & trap); commandhandler ("GT_SetTrapPrm", sRtn ); // set the target position of the AXIS sRtn = GT_SetPos (AXIS, 50000L); commandhandler ("GT_SetPos", sRtn); // set the target speed of the AXIS sRtn = GT_SetVel (AXIS, 50); commandhandler ("GT_SetVel", sRtn); // start the motion of the AXIS sRtn = GT_Update (1 <(AXIS-1); commandhandler ("GT_Update ", sRtn); do {// read the status of the AXIS sRtn = GT_GetSts (AXIS, & sts); // read the planned position of the AXIS sRtn = GT_GetPrfPos (AXIS, & prfPos ); printf ("sts = 0x %-10 lxprfPos = %-10.1lf \ r", sts, prfPos) ;}while (sts & 0x400 ); // wait for the AXIS to stop planning // The servo to close sRtn = GT_AxisOff (AXIS); printf ("\ 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.