www.promax.
VTB USER GUIDE The information contained in this document are for informational purposes only and are subject to change without notice and should not be interpreted by any commitment by Promax srl. Promax Ltd. assumes no responsibility or liability for errori or inaccuracies that may be found in this manual.
VTB USER GUIDE 1 INTRODUCTION VTB is an integrated development environment for OBJECT oriented programming on PROMAX platforms. This environment contains inside all tools needed to development of application in simple and intuitive way. The VTB philosophy is based on latest technologies R.A.D. (RAPID APPLICATION DEVELOPMENT) which allow a fast development of application writing a reduced amount of source code.
VTB USER GUIDE 3 DEVELOPMENT ENVIRONMENT The development environment of VTB has an common intuitive interface like all Windows applications. It isn't necessary to have a great experience of programming. In the environment is included an EDITOR optimized for VTB programming.
VTB USER GUIDE 3.1 Toolbar New Project - From menu File → New project It creates a new application. The previous one is closed requesting a confirm for saving. Open Project - From menu File → Open project It opens an existing project. Save Project - From menu File → Save project It saves the current project Copy Selected Object/s - From menu Edit → Copy (Ctrl+C) The selected objects are copied in the clipboard. All property are copied, also the object position inside the page.
VTB USER GUIDE Background The selected objects is brought to the background of the page. It can be covered by other objects making it invisible. Align left The selected objects are aligned to left margin. The reference object will be the last selected. Align right The selected objects are aligned to right margin. The reference object will be the last selected. Align top The selected objects are aligned to top margin. The reference object will be the last selected.
VTB USER GUIDE EtherCAT Configurator It launches the EtherCAT configuration tool (see chapter ETHERCAT CONFIGURATOR). DEBUG It launches the DEBUG tool (see chapter DEBUG APPLICATION).
VTB USER GUIDE 3.2 Project Manager The PROJECT MANAGER allows a fast selection and navigation in all the PAGES of the PROJECT. From this AREA we have the entire control of the application: viewing pages, managing of variables, writing code, etc. New Page - From menu Pages → New It adds a new page to the project. The page is automatically numbered. A page can contain GRAPHIC OBJECTS and source code. Both will work only when the page will be loaded and only a page at time can be loaded.
VTB USER GUIDE 3.3 Objects manager The OBJECTS MANAGER allows a fast selection of the objects to insert in the current page. Inside it there are both base-objects and enhanced-objects. For a detailed description of a single object there is a separated user manual. To insert an object it have to be selected and then dragged to the desired position. The LOAD button allows to browse the CUSTOM OBJECT which are not included in the standard library.
VTB USER GUIDE 3.4 Functions Manager In this Tree View are showed all the STRUCTURE and FUNCTIONS grouped per page. Just open the nodes to view informations. In STRUCTURE section there is the possibility to add a new one by add-element button, it is also possible to remove the selected structure by delete-element button. Opening an existent structure the fields of it are showed.
VTB USER GUIDE 4 CONFIGURATION OF VTB From Menu Tools Options This command is used to configure some options of the VTB environment and the target hardware. 4.1 General Options This table contains the general options of VTB View Grid When this check-box is activated the grid on the page windows is displayed. The grid is useful as referenc to position the graphic objects. Snap to Grid Activating this check-box the snap to grid is enabled.
VTB USER GUIDE Standard Mode OBSOLETE Debug Mode OBSOLETE Debug Standard OBSOLETE Debug.NET It forces the use of the new DEBUG.NET application. On PC must be installed the Framework 2.0 or major. This is the debug option recommended. Warning Level Level 0 Compiler doesn't display any warning messages. Level 1 Compiler displays warning messages when improper or dubious operations on variables are found. Anyway the binary file is created. 4.
VTB USER GUIDE 4.3 Field-Bus Protocol These options allow to select the Field-Bus protocols used by the target hardware. For the moment the protocols implemented are two: CanOpen Ethercat CoE Standard DS301 DS4xxx (Can Over Ethercat) CanOpen Protocol It enables the CanOpen protocol. BaudRate It selects the BaudRate of CanOpen line. Sync It enables or disables the SYNC message on CanOpen line. The message Sync is sent cyclically at the time of TASK PLC (set in General Options).
VTB USER GUIDE function open_cancfgerr(nodes as char) as void nodes = Total number of nodes in the CanOpen configuration. This function is called by the system before starting the CanOpen configuration. The total number of the nodes in the configuration is written in the parameter nodes. function cancfgerr(nodo as int, err as uchar) as void nodo=Number of configured node. err=Result of configuration. 0 = Node correctly configured. <>0 = Error code. See relative chapter of CanOpen functions.
VTB USER GUIDE 4.4 Target Hardware Configuration An application must always refer to the target hardware. That allows VTB to preconfigure for the selected hardware so it can use the relative function-call, use the appropriate memory addresses, signal the specific errors, use the correct debug, etc. Normally it is set before starting the application but we can change it ever after to adapt the same application at another hardware. Target Hardware This Combo allows to choose the code of target hardware.
VTB USER GUIDE 5 TASKS MANAGED BY VTB VTB provides the programmer for TASKS wich can be combined to create an application. Two of these are interrupt tasks, that means they are executed, interrupting the other tasks, at fixed and constant time; the other two task in cooperative mode: they are executed one after another.
VTB USER GUIDE 5.1 Task Plc This task is the higest priority one: it is deterministic and run at fixed time making it suitable to manage situation that need a fast and precise response time. This task can not be interrupted by no other tasks but it can instead interrupt any other. Normally it is used by AXIS CONTROL OBJECTS or fast PLC cycles, but it can contain every type of code sequence exluding some IFS functions like: GRAPHICS FUNCTIONS AXIS INTERPOLATION (xxx.MOVETO, xxx.
VTB USER GUIDE 5.2 Task Time TASK TIME, like TASK PLC, works at fixed time. It deffers from that for two features: a) it has a lower priprity and it can be INTERRUPTED by TASK PLC; b) it hasn't limit to managing of the IFS functions of VTB. The scan time of this task is programmable at multiple of the sampling time of TASK PLC.
VTB USER GUIDE Also there is a section MASTER EVENT but it has been left only for compatibility with older versions and therefore it must not be used. INIT PAGE The code in this section runs only one time at the start of the program and usually it handles the initialization of the global variables in the application. In this section we can write any type of code as long as it isn't STATIC CODE which can block the program.
VTB USER GUIDE 6 VARIABLES TYPE VTB can manage several types of variables which can be used in programming phase. Commonly all VARIABLES will be allocated in the VOLATILE MEMORY (RAM) of the system and they are zeroed at reset. In systems equipped with NON-VOLATILE RAM (as NG35 or PEC70) it's also possible to allocate them in this area, they are defined as STATIC VAR and they will retain its value also after turn-off. VARIABLES follow the STANDARD terminology similar to common programming languages.
VTB USER GUIDE 6.2 Internal Variable These variables are allocated in the VOLATILE MEMORY (RAM) of the system and are zeroed at reset. The possible types managed by VTB reflects the main types defined in a lot of programming languages and they are the following: TYPE DIMENSION RANGE BIT 1 bit From 0 to 1 CHAR 8 bit signed From –128 to +127 UCHAR 8 bit unsigned From 0 to 255 INT 16 bit signed From –32.768 to +32.767 UINT 16 bit unsigned From 0 to 65.535 LONG 32 bit signed From –2.147.
VTB USER GUIDE 6.3 Pointers VTB is able to manage the pointers to variables too. Pointers defines the address of allocation memory of the variables, not its content. Some VTB functions need of pointers as parameter particularly when the function manage arrays or strings. To define the address of a variable it's enough insert the postfix () except for the funcions.
VTB USER GUIDE It's also possible to declare pointers to data STRUCTURES.
VTB USER GUIDE 6.4 Bit This type of variable can have only two values: 0 or 1, normally associated to a state OFF/ON or FALSE/TRUE. The variable BIT must always refer to an original variable which will can contain more bits. This variables are very useful to manage FLAGS, digital I/O lines and in all cases where we need to read or write a single bit directly. The bit variables can be both GLOBAL or PAGE LOCAL and they can be used like normal variables.
VTB USER GUIDE 6.5 Arrays The arrays can be declared in the INTERNAL or STATIC variables and they can be defined as any type except the BIT one. The arrays managed by VTB are SINGLE-DIMENSION and the maximum limit depends on the free memory available. To declare an array we have to do as for a normal variable putting after the name, between parenthesis, the desired dimension. If there was the need to use a TWO-DIMENSION array (matrix) we have to work with STRUCTURES.
VTB USER GUIDE 6.6 VCB Variables (CanOpen or EtherCAT) The variables of type VCB are common variables which reflect the state of variables allocated in remote device connected at the central unit by field-bus like CANOPEN or ETHERCAT. These variables aren't defined directly by VTB environment but come from an external configurator which defines the field-bus typology and the connected devices.
VTB USER GUIDE 6.7 System Variables Variables of type System are variables already defined by operative system, therefore we must not to declare them but they can be used as commen variables. This is the list of the SYSTEM VARIABLES available. There are more system variables but reserved to the system. TYPE R/W _SYSTEM_PXC NAME LONG R/W DESCRIPTION _SYSTEM_PYC LONG R/W _SYSTEM_PZC LONG R/W _SYSTEM_PAC LONG R/W _SYSTEM_ACT_PAGE INT R It contains the page number currently loaded/displayed.
VTB USER GUIDE 6.8 Static Variables The variables of type STATIC are declared in NON-VOLATILE RAM: they aren't zeroed at reset and maintain their value also after turn off. They are very useful to retain data which change frequently (as encoders, counters, etc.), and which could not be saved in flash memory (IMS). Besides they are common variables. STATIC variables are always GLOBAL that is visible in all page and in all tasks.
VTB USER GUIDE 6.9 Fixed Variables The variables of type FIXED are allocated at a fixed address in the internal memory of the device which, unlike common variables, doesn't change modifying the program. This type of variable simplifies the use of systems connected to an external HOST (ex. PC). In fact using FIXED variables there will be no need to recompile the HOST application at each change in VTB program. FIXED variables are always GLOBAL that is visible in all page and in all tasks.
VTB USER GUIDE 6.10 Delegates This type of variables is used to call a function by a variable. First of all the address of the function to call must be written in the DELEGATE variable. Then we can use this variable to call the function with the instruction call_delegate. It can also be created an array of DELEGATE variables and then call a function according to the index of the delegate.
VTB USER GUIDE 6.11 DEFINE DEFINES are complex equivalences. They are composed by the NAME and the VALUE. The name identifies the DEFINE, the VALUE can contain any alfa-numeric expression. The compiler each time a NAME of DEFINE is found, replaces it with its VALUE. They are very useful to simplify the use of complex expressions or to Parametersze part of code. Also they can be combined between self.
VTB USER GUIDE 6.12 Text Tables OBSOLETE 6.13 Structures The STRUCTURES can be declared only as INTERNAL variables. The fields of a structure can be of any type except BIT and pointer. To declare a STRUCTURE open the STRUCTURE TABLES and define the NAME of the structure and all single elements we need. When a structure is declared, in the list of the variable types the NAME of the STRUCTURE will be showed, allowing to define a new variable of all types declared as structure.
VTB USER GUIDE 7 OPERATORS The operators of VTB are common to other compilers. 7.
VTB USER GUIDE 7.2 Notes on Expressions VTB manages the mathematical expressions completely. Anyway we have to make WARNING when in the expression there are INTEGER variables together FLOAT variables.
VTB USER GUIDE 8 MATH FUNCTIONS VTB manages a wide SET of mathematical functions. 8.1 SIN Return the sinus of an angle in a FLOAT value. Hardware All Syntax Sin (angle) as float The argument angle can be a FLOAT value or any numeric expression which represents the angle in radians. Example: Used variables: angle float Cosec float angle = 1.3 cosec = 1 / Sin (angle) ‘ Define the angle in radians. ‘ Calculate the cosecant. 8.2 COS Return the cosinus of an angle in a FLOAT value.
VTB USER GUIDE Example: Used variables: angle float ctan float angle = 1.3 ctan = 1 / Tan (angle) ‘ Define the angle in radians. ‘ Calculate the cotangent. 8.5 ATAN Return the arctangent of a number in a FLOAT value between -π/2 and +π/2. Hardware All Syntax Atan (number) as float The argument number can be a FLOAT value or any numeric expression. 8.6 ASIN Return the arcsin of a number in a FLOAT value.
VTB USER GUIDE 8.8 ATAN2 It's similar to atan but it returns a value from -π and +π . Hardware All Syntax Atan2 (y, x) as float The arguments y and x are of type FLOAT. Return Value The return value coincides with the angle whose tangent is y / x. Example Used variables: x float y float angle float radians float result float PI float PI= 3.141592 x=1.0 y=2.
VTB USER GUIDE 8.10 FABS Return the absolute FLOAT value Hardware All Syntax FAbs (numero) as float The argument number can be a FLOAT value or any numeric expression. Example Used variables: Num float Num = -3.250 Num = Abs(Num) ‘ return the value 3.
VTB USER GUIDE 9 INSTRUCTIONS TO CONTROL THE PROGRAM FLOW In VTB there are a lot of instruction to control the program flow. They are similar to other compiler and THEY ARE AVAILABLE IN ALL THE HARDWARE TYPES. 9.1 IF-ELSE-ENDIF Allow the conditional execution of a group of instruction according to the result of an expression. Syntax If condition [instruction] Else [instructionelse] endif The syntax of instruction if... else is composed by the following elements: condition Mandatory.
VTB USER GUIDE Label Label1 . Label Label2 9.3 GOSUB-RETURN Allow to pass the control to a SOUBRUTINE and to return at the next program instruction. Syntax GoSub labelname The argument labelname can be any LABEL inside the current PAGE or inside the MAIN task. Notes GoSub and Return can be used everywhere in the code, but they must be both included in the same PAGE or in MAIN task.
VTB USER GUIDE 9.5 INC Increments a variable of any type. Syntax Inc varname The argument varname can be any variable declared in the program. Description Inc is the same as VAR=VAR+1 but it is executed more quickly. Example INC var1‘var1 is incremented by 1 9.6 DEC Decrements a variable of any type. Syntax Dec varname The argument varname può essere una qualsiasi variabile dichiarata nel programma. Description Dec is the same as VAR=VAR-1 but it is executed more quickly.
VTB USER GUIDE Example Used variables: var1 int var2 int var3 int Select var1 case 10 ‘ if var1=10 ... case var2+var3 ‘ if var1=var2+var3 ... case 5 TO 20 ‘ if var1 is between 5 and 20 ... case 1,6,8 ‘ if var1=1 or var1=6 or var1=8 ... case else ‘ all other value of var1 ... Endselect 9.8 FOR-NEXT-STEP-EXITFOR Allow the iteration of a block of instructions for a number of times according to a variable. It is a mix between BASIC and C languages.
VTB USER GUIDE For var1=0 to var1<8 ... Next var1 ‘ Repeat 8 times For var1=1 to var1
VTB USER GUIDE 10 FUNZIONI VTB manages functions with the same syntax as VISUAL BASIC. It exist a limitation in the declaration of internal variables: they can not be ARRAYS, STRUCTURES or BITS. 10.1 Declaration of a function Syntax function function_name(par_1 as int, par_2 as char, ….., par_n as *long) as function_type dim var as int ‘local variables .... .... ‘body of the function ....
VTB USER GUIDE 10.2 Declaration of the function internal variables Syntax Dim varname as type The syntax of instruction dim is composed by the following elements: varname type BITS. Mandatory. Name of the variable. Mandatory. Type of the variable.
VTB USER GUIDE 11 SYSTEM FUNCTIONS VTB provides a wide LIBRERY to a complete management of the hardware devices. Some function can be available only for some type of hardware 11.1 FUNCTIONS FOR THE SERIAL PORT CONTROL All Promax hardware devices have 1 or 2 serial channel available to the application. In VTB there are some object to manage the common serial protocol, for example MODBUS protocol both MASTER and SLAVE. However it's possible to use one serial channel to customize the protocol.
VTB USER GUIDE SER_PUTCHAR Sends a character to the serial port. Hardware All Syntax SER_PUTCHAR (int CodeChar) Parameters CodeChar Code of the character to send SER_PUTS Sends a string of characters to the serial port. The string must be ended with the character 0 (NULL). Hardware All WARNING: This function can not be used in a BINARY transmision but only with ASCII transmision.
VTB USER GUIDE SER_PRINTF Formatting print of a FLOAT value. It is the same as ser_printl but use a float value Hardware All Syntax SER_PRINTF (const char *Format, float Val) Parameters Format Val String corresponding to the format to be printed Any integer value or expression SER_PUTBLK Sends a precise number of characters to the serial port.
VTB USER GUIDE 11.2 MISCELLANEOUS API FUNCTIONS GET_TIMER Reads the system timer in units of TASK PLC (scan time). Hardware All Syntax Long GET_TIMER () Return value: Value of the system timer in sampling units Some defines are automatically generated by VTB to adapt the application at the scan time: TAU Scan time of TASK PLC in milliseconds (INTEGER value) TAUFLOAT Scan time of TASK PLC in milliseconds (FLOAT value) TAUMICRO Scan time of TASK PLC in 0.
VTB USER GUIDE ALLOC Dynamic allocating of memory area. Hardware NG35 Syntax ALLOC (Long Mem) as long Parameters Mem Total amount of memory to be allacated Return value: <>0 Pointer to the allocated memory 0 Allocation error Example Pnt As *Char N as Long Pnt=Alloc(3000) FOR N=0 to N<3000 PUNT[N]=N NEXT N ‘ Alloc 3000 byte of memory FREE Frees the a memory area previously allocated with alloc.
VTB USER GUIDE 11.3 API FUNCTIONS FOR MANAGING OF STRINGS VTB doesn't use STRING variables, to manage them there are some apposite functions similar to the “C” language. STRCPY Copies the string pointed by SOURCE into the array pointed by DEST. The string must terminate with the character 0 (NULL).
VTB USER GUIDE STRCAT Appends a copy of the source string to the destination string. Hardware All Syntax STRCMP(Char *Dest, Char *Source) Parameters Dest Source Pointer to destination Pointer to source Example Used variables: Str(30) Char Strcpy(Str(),”My “) StrCat(Str(),”Text”) ‘ str will contain “My Text” STR_PRINTL Converts an INTEGER variable to a characters STRING.
VTB USER GUIDE Avalaible formats ###### ###.### +#### #0.## X#### B#### Print a fixed number of characters Force the print of decimal point Force the print of the sign Force the print of a ZERO Print in HEXADECIMAL format Print in BINARY format 23456 123.456 +1234 0.12 F1A3 1011 11.4 FUNCTIONS FOR AXES INTERPOLATION The axis interpolation functions are contained in an OBJECT in the CLASS COBJINTERPOLA. In this chapter are descriped this function with the primitive name.
VTB USER GUIDE Char 0 1 Command not written in the buffer (buffer full) Command written in the buffer Notes Moveto is usually used to interpolate more than 2 axes. The speed vector is distributed on all axes to be interpolated. When mode=2 it is calculated the presence of a multidimensional edge according to the values in sgl3d. When mode=2 the test of edge is made only on the axis of the working plane and according to the value in sglp.
VTB USER GUIDE LINETO Lineto interpolates the axis distributing the vector speed ONLY ON THE AXES OF THE CURRENT WORKING PLANE. The other axis will be TRANSPORTED. The function is useful to manage TANGENTIAL AXIS such as cutting machine, where the blade have to be transported to increasing the fluidity of the movement. The eventual stop of axis is calculated according to the threshold value in sglp.
VTB USER GUIDE ‘ ********************************************************* ‘ Movement function waiting if the buffer is full ‘ ********************************************************* Function muovi() as Void Dim test as Char Label Move test=Obj.lineto(vel,VectAssi()) if test=0 goto Move endif EndFunction ARCTO Movement with CIRCULAR interpolation on the axes of the current WORKING PLANE. Two axes execute a CIRCULAR interpolation while the others are interpolated in LINEAR mode.
VTB USER GUIDE Function muovi() as Void Dim test as Char Label Move test=px_arcto(vel,2,VectAssi(), Cx, Cy) if test = 0 goto Move endif EndFunction SETCMD This function allows the synchronization of commands with the axis movement. In fact because of BUFFER OF AXIS MOVEMENT the interpolation functions don't wait the execution of the command but write it in the buffer.
VTB USER GUIDE STOP Stops axis with the programmed deceleration (acc) waiting for the complete execution (axis stopped). STOP is used to stop the axis before the TARGET point, programmed with MOVETO, LINETO or ARCTO, is reached. The movement buffer will be emptied. Hardware All Syntax .STOP() Notes STOP, unlike FSTOP, waits the axis are stopped, for this IT MUST NOT BE CALLED IN TASK PLC. FSTOP Stops axis with the programmed deceleration (acc) without waiting for the complete execution (axis stopped).
VTB USER GUIDE Note Keep in mind these rules: – – AXIS MUST BE STOPPED CHANGING INSTANTLY THE POSITION IT OCCURS A PARTICULAR SEQUENCE TO AVOID THE PHISICAL AXIS MOVES ROUGHLY For example WHEN USING THE CANOPEN AXIS IT NEEDS: – REMOVING THE CANOPEN FROM THE INTERPOLATION MODE – PRESETTING THE CANOPEN AXIS BY METHOD .
VTB USER GUIDE variable type passed by pointer. Example Used variables: value int Ret char value=100 Ret=pxco_sdodl(1,2000,0,2,value()) 'node=1, index=2000, subidx=0, 'len=2 byte, value=100 ‘test if error occurs if Ret<>0 if Ret=2 read_sdoac()‘read eventual SDO ABORT CODE ... endif ... endif PXCO_SDOUL This function allows to read data from a node of the canopen net using the protocol SDO. It is supported only the SDO EXPEDITED mode allowing to read up to 4byte of data length.
VTB USER GUIDE PXCO_SDODL or PXCO_SDOUL. The read code will be written in the system variables _SYSTEM_SDOAC0 e _SYSTEM_SDOAC1. Refer to the DS301 specific of the CAN OPEN for the code error values. Hardware All Syntax READ_SDOAC() PXCO_SEND Sending of a CAN frame at low level. This function allows to send in the net a CAN frame with a desired COB-ID and DATS. For example it's possible to send manually PDO frames, HEART-BEAT frames, etc.
VTB USER GUIDE Example Used variables: pxco_nmt(2,1) ‘Set in STOP the node 1 READ_EMCY Reads the last EMERGENCY OBJECT frame sent by a CAN OPEN node. The emergency code is written in the system array _SYSTEM_EMCY(8) and it will contain all the 8 bytes of the EMERGENCY OBJECT frame as from the DS301 specific of the CAN OPEN. Usually it is called cyclically. The emergency code depends by type of connected device, therefore refer to its manual.
VTB USER GUIDE For example a FLASH memory has a maximum number of writing, block erase, etc. IMS_WRITE Writes in the internal FLASH at the address contained in ADDR, the data pointed by Punt for a total of NBYTE of data. The FLASH memory is managed in BLOCKS of 256 bytes, for this it's recommended to write multiple of 256 bytes.
VTB USER GUIDE customized protocols. SET_IP Sets the parameters of TCP/IP protocol. Hardware NG35,NGMEVO Syntax SET_IP(ip as *char, sm as *char, gw as *char) Parameters ip IP address of the device sm subnet mask gw gateway Example Set_ip(“10,0,0,15”,”255,255,255,0”,0) 'IP = 10,0,0,15 'SUBNET = 255,255,255,0 'GATEWAY = nothing WARNING: This function must be called in the INIT section of the MAIN or PLC TASK. PXETH_ADD_PROT Adds a custom protocol to a specific port of TCP/IP.
VTB USER GUIDE PROTOCOL PROCESS FUNCTION This function isn't defined by system but it must be written in the application. The system will call this function, by the pointer passed with pxeth_add_prot, each time a data packet is received from the port associated to this protocol. To read the received data the function pxeth_rx have to be call while to send the response data they must be written in the transmit buffer (buftx) and return from the function the number of bytes we want to send.
VTB USER GUIDE 11.8 DISK DRIVER FUNCTIONS Some devices, such as NG35, can manage files by the standard fyle system FAT16 (or FAT32) on optional memory as FLASH DISK or USB KEY. The library functions are contained in the object FATLIB which will be loaded before using. In this chapter are described all the GENERIC function of the object. Remember to put the prefix of the OBJECT NAME. If, for example the object is named disk the function OpenRead will must be called as disk.OpenRead.
VTB USER GUIDE .OpenCreate(handle as int, path as *char) as char Creates a new file opening it in write mode, if it already exists it is overwritten. Parameters handle path Number to assign to file for any reference Name of the file, it can contain also the complete path Example Used variables: err char err=disk.OpenRead(1,”\data\table.dat”) ‘ open table.dat in the directory data if err ... endif CLOSE Closes the file with the selected HANDLE freeing it to successive use. Syntax .
VTB USER GUIDE err=disk.OpenRead(1,”\data\table.dat”) ‘ open table.dat in the directory data if err ... endif while 1 err=disk.Read(1,dati(),10,nbyte()) ‘read blocks of 10 bytes ... if err ... endif if nbyte<10 ‘ .. to the end of file exitwhile endif loop disk.Close(1) ‘ close the file WRITE Writes LEN bytes in the file with the HANDLE reference. Syntax .
VTB USER GUIDE .SeekRel(handle as int, offs as long) as char Sets the offset from the current position of the file. Parameters handle offset Reference number of the file Value of the offset in number of bytes Example err=disk.OpenRead(1,”\data\table.dat”) ‘ open the file ... err=disk.Seek(1,200) ‘ set current position at 200 bytes CHDIR Changing of current directory. All successive functions without a complete path will refer to the current one. Syntax .
VTB USER GUIDE Syntax .Rename(oldpath as *char, newpath as *char) as char Parameters oldpath Name of file/directory to be renamed newpath Name of the new file/directory to be renamed Example err=disk.Rename(”text.txt”,”data.dat”) ' rename the file text.txt with ' data.dat in the current directory COPY Duplicates a file. If a file with the destination name exists this is overwritten. Syntax .
VTB USER GUIDE .name(13) .lname bit 1 hidden bit 2 system bit 3 volume bit 4 directory bit 5 arch. Short name ex. “nomefile.ext” Pointer to long name (max 255 characters) Example ' Function to print on the serial port of the file list in the current ' directory function list_dir() as void dim res as char dim pname as *char dim flbyte as long res=disk.OpenDir(“”) if res ser_puts("No file") ser_putchar(10) ser_putchar(13) return endif while 1 res = disk.ReadDir() if res || disk_finfo.
VTB USER GUIDE GETFREE Reads the property of a driver: total dimension and number of free bytes. The informations are written in the structure ObjectName_dinfo Syntax .GetFree(drv as char) as char Parameters drv Index of the driver: 0 = A: 1 = B: Structure ObjectName_dinfo .btot Disk dimension in bytes .bfree Number of available bytes Example err=disk.GetFree(0) ser_puts("bytes free: ") ser_printl("#.###.###.### ",disk_dinfo.bfree) ser_puts("su ") ser_printl("#.###.###.### ",disk_dinfo.
VTB USER GUIDE REAL TIME CLOCK (RTC) When files are created in the relative fields of the FAT the actual date and time are written. For this in the same object there are the reading and writing functions of the real time clock. All the information pass in a defined structure names RTC. Syntax RTC.Read() as void Read the Real Time Clock RTC.Write() as void Write in the Real Time Clock Structure RTC RTC.year Year (0-99) RTC.month Month (1-12) RTC.day Day (1-31) RTC.dweek Day of week (0-6) RTC.
VTB USER GUIDE 11.9 INTERFACE FUNCTIONS FOR NG35 This group of functions allows the interfacing to the hardware resource of NG35 systems. Hardware NG35 NG_DI - DIGITAL INPUTS This function allows to read the digital input of the expansion cards of NG35: NG-IO and NG-PP. The expansion cards are identified with a progressive number starting from 0. The first card near the NG35 has the index 0.
VTB USER GUIDE NOTES FOR PROGRAMMING WITH DIGITAL I/O To obtain an application program more clear and stable we suggest to call the I/O function only from TASK PLC. Therefore, in this task, read the inputs writing them in a GLOBAL variable (ex. Input) and write the outputs reading them from another GLOBAL variable (ex. Output). On these variables can be defined the single bits associated to the digital channels and then using them at occurrence.
VTB USER GUIDE NG_DAC – ANALOG OUTPUTS This function allows to update the analog outputs of each channel equipped in the NG35 expansions NG-IO and NG-PP (as option). These expansions have a digital to analog converter at 12 bit, with a range of +/-10V. Therefore a value of +2047 corresponds to 10V in output, a value of -2047 corresponds to -10V.
VTB USER GUIDE NG_ENC - ENCODER INPUTS This function allows to read the quadrature encoder input of each channel equipped on the expansion card NG-IO. The resolution is 32 bits. This function read only the increment which will be added to a variable passed by its pointer. Therefore the real encoder counter will be contained in a variable defined in the application and it will can be zeroed in any time.
VTB USER GUIDE NG_T0 – ZERO INDEX OF ENCODER This function allows to read the state of the zero index input of each encoder channel equipped in the expansion card NG-IO. The channel selection is made as for the reading of encoders. Syntax NG_T0(Char Chan) as char Parameters Chan Number of channel (from 0 to 15) Return value: State of the index input: 0 OFF 1 ON WARNING: THE INDEX INPUT IS DIFFERENTIAL, THE ON STATE ON OCCURS WHEN ON CH+ THERE IS A VOLTAGE GREATER THAN THE VOLTAGE ON CH- .
VTB USER GUIDE TEMPERATURE READING ON NG35 The NG35 is equipped with a TEMPERATURE SENSOR which can be useful to monitor the internal temperature. The sensor is connected to the Nr. 9 internal ANALOG CHANNEL and it can be read with the system function ng_adc as for the other analog inputs. To convert the value in degrees Celsius we have to do a calculation (see example).
VTB USER GUIDE 11.10 Functions for NGMsX - NGMEVO Functions for NGMsX expansion board for NGMEVO Hardware NGMEVO NG_DAC – Analog Outputs NGMsX This function allows to update the analog outputs of each channel equipped in the NGMsx This expansions have a digital to analog converter at 12 bit, with a range of +/-10V. Therefore a value of +2047 corresponds to 10V in output, a value of -2047 corresponds to -10V.
VTB USER GUIDE NG_ENC - ENCODER INPUTS This function allows to read the quadrature encoder input of each channel equipped on the expansion card NGMsX. The resolution is 32 bits. This function read only the increment which will be added to a variable passed by its pointer. Therefore the real encoder counter will be contained in a variable defined in the application and it will can be zeroed in any time.
VTB USER GUIDE 0 OFF 1 ON WARNING: THE INDEX INPUT IS DIFFERENTIAL, THE ON STATE ON OCCURS WHEN ON CH+ THERE IS A VOLTAGE GREATER THAN THE VOLTAGE ON CH- . Example if ng_t0(0) ... endif NG_RELE – RELE' NGMsX This function allows to update the two RELAIS equipped in each expansion card NGMsx. Usually these RELAIS are connected to the input ENABLE of the SERVO DRIVER but they can be managed for any applications. The channel selection is made as for the reading of encoders.
VTB USER GUIDE 11.11 Functions for Analog Outputs on NGQ Functions for NGQ Analog Outputs Hardware NGQ NG_DAC – Analog Outputs NGQ This function allows to update the analog outputs of each channel equipped in the NGQ This expansions have 2 digital to analog converter at 12 bit, with a range of +/-10V. Therefore a value of +2047 corresponds to 10V in output, a value of -2047 corresponds to -10V. The selection of the channel is made by an index from 0 to 1.
VTB USER GUIDE 11.12 Functions for NGQx Analog Outputs and encoder inputs Functions for NGQx Analog Outputs and encoder inputs Hardware NGQx NG_DAC – Analog Outputs NGQx This function allows to update the analog outputs of each channel equipped in the NGQx This expansions have 2 digital to analog converter at 12 bit, with a range of +/-10V. Therefore a value of +2047 corresponds to 10V in output, a value of -2047 corresponds to -10V. The selection of the channel is made by an index from 0 to 1.
VTB USER GUIDE ENCODER ENABLE=true on NGQ INIT Object Syntax NG_ENC(Char Chan, Long *Val) Parameters Chan Number of channel (from 0 to 1) val Pointer to a long variable where will be contained the counter Example Used variables: posx LONG posy LONG ' Counter encoder channel 0 ' Counter encoder channel 1 In TASK PLC: ng_enc(0,posx) ng_enc(1,posy) EVERYWHERE: if posx>25000 ' Read encoder channel 0 ... posx=0 ' Reset counter channel 0 endif if posy>200000 ' Read encoder channel 1 ...
VTB USER GUIDE Parameters Chan Number of channel (from 0 to 1) Stato State of the relay: 0 OFF (contact opened) 1 ON (contact closed) Example Used variables: channel UINT stato UINT channel = 1 stato = 1 ng_rele(channel,stato) channel = 2 stato = 0 ng_rele(channel,stato) ng_rele(0,1) 'active the relay of the second channel ‘disactive the relay of the third channel ‘active the relay of the first channel 86
VTB USER GUIDE 11.13 INTERFACE FUNCTIONS FOR NGM13-NGMEVO-NGQ-NGQx This group of functions allows the interfacing to the hardware resource of NGM13 systems. When this target is selected the OBJECT NGM13_INIT NGMEVO_INIT is automatically loaded. It defines the hardware configuration of the device. Hardware NGM13-NGMEVO NGM13_INIT PROPERTY-NGMEVO_INIT PROPERTY The object provides a complete vision of all the software option to be set for the correct use of NGM13-NGMEVO.
VTB USER GUIDE NGQ_INIT PROPERTY-NGQ and NGQx The object provides a complete vision of all the software option to be set for the correct use of NGM13-NGMEVO. In detali it allows to set: Enabling of the communication protocol RPC (PROMAX proprietary), with relative baudrate The step/dir axes to be used in interpolation mode Property Link RPC port Link RPC baud P-P Interp. Mask STEP Level ENCODER Enable Serial port RS232 on which enable the RPC protocol to manage an HOST PC connection.
VTB USER GUIDE NG_DI - DIGITAL INPUTS NGQ NGQx This function allows to read the digital input of the NGQ-NGQx The card Index must be 0 Syntax NG_DI(Char Card) as uint Parameters Card Index of the expansion card (fmust be 0) Return value: Uint Value of 16 BITS of the input, if Bit is 1 the input is ACTIVE Input Bit 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 15 14 13 12 11 10 8 7 6 5 4 3 2 1 0 9 NG_DO – DIGITAL OUTPUTS NGM13-NGMEVO This function updates the digital output of the NGM13-NGMEV
VTB USER GUIDE NOTES FOR PROGRAMMING WITH DIGITAL I/O To obtain an application program more clear and stable we suggest to call the I/O function only from TASK PLC. Therefore, in this task, read the inputs writing them in a GLOBAL variable (ex. Input) and write the outputs reading them from another GLOBAL variable (ex. Output). On these variables can be defined the single bits associated to the digital channels and then using them at occurrence.
VTB USER GUIDE NGQ NGQx – ANALOG INPUTS The NGQ and NGQx, have up to 4 Analog Inputs (only ONE for NGQx). 12 Bit. In THE NGQ if are ENABLED the STEP/DIR channels, only ONE analog input is available Syntax NG_ADC(Char Ch) as uint Parameters Chan Number of the channel (from 0 to 7) Return value: Returns the analog value (from 0 to 4095).
VTB USER GUIDE 11.14 STEP/DIR CHANNELS-NGM13-NGMEVO-NGQ-NGPP The system NGM13,NGMEVO,NGQ e NG-PP are equipped with 4 STEP/DIR channels which allows to work with axis with linear, circular or helical interpolation. Normally for their use it is associated to a library object according to the type of application. For example we can use them with INTERPOLATOR, POSITIONER, CAM, GEAR, etc. In this chapter will be described the need functions to interface these objects to the STEP/DIR output.
VTB USER GUIDE PP_GETPOS – READING OF ACTUAL POSITION NGPP-NGMEVO This function reads the actual position of a step/dir channel. The value will correspond to the DOUBLE of the real position. This function isn't present in NGM13,NGQ where to read the actual positions there are 4 system variables.
VTB USER GUIDE 7) 8) Write in TASK PLC the following CODE: pp_step(0, PosAxis * RappX) Write in MAIN TASK the test code to execute a movement (example): if START_CONDITION AxisX.Vel=1000 AxisX.quota=100000 AxisX.start=true START_CONDITION=false ' To avoid recursive starts endif With this example the variable pos_asse will reach the value 100000 following the programmed RAMP in the object.
VTB USER GUIDE 4) Declare the following GLOBAL VARIABLES: PosAxes(2) long - position of the axis Rapp(2) Float - ratio between generated steps and effective movement 5) Initialize in the section INIT of the MAIN task the variable RAPP(0) and RAPP(1) at the desired value (however not equal to 0). A negative value will be able to change the direction of the axis. 7) Set the following PROPERTY of the OBJECT INTERPOLA1 (example) 7) Write in TASK PLC the following CODE: pp_step(0, Obj.
VTB USER GUIDE The flag DisableStep allows the stop of steps generation. Then at the moment we need to execute an axis preset, referring to the previous examples, call this code: PRESET AXIS WITH INTERPOLATOR: DisableStep=true pos_vect(0)=qpresetX ' preset position X pos_vect(1)=qpresetY ' preset position Y obj.
VTB USER GUIDE 12.2 Exporting VARIABLES We can export the desired variable to FRAMEWORK and then, on PC, write or read them as normal variables of the project. To export a variable, when we declare it, enable the CHECK EXP and write the name of the exporting class (default Generic). The class serves only to group the exporting variables so to make more simple the research of them in the PC application. In the example the variables will be contained in Generic.
VTB USER GUIDE 13 APPLICATION DEBUG The DEBUG utility allows to control, both read and write, of all the application variables, to insert BREAK POINT and to execute the code STEP by STEP. That makes more simple the development of the application. The application DEBUG can be execute by RS232 port as well as ETHERNET. When the serial port is used, the PC must be connected to the first port of the target hardware (SER-1/ PROG). WARNING: If application uses the first serial port, (ex. MODBUS, etc.
VTB USER GUIDE Pagina It selects the page of the VARIABLE (if it is a local variable of a page), PAGINA 0 refer to the GLOBAL variables. Contesto If the watching VARIABLE is local of a FUNCTION (defined with dim) we can select the contest (function) of this variable. These types of variables are visible only if a BREAK POINT in the relative contest is reached. Remove the selected variable. The selected variable will be removed from the WATCH window. Remove all variables from the WATCH window.
VTB USER GUIDE Reset It simulates a RESET of the HARDWARE. WARNING: The application will be restarted. Save the list of variables on file It is possible to create a file with the list of the variables in the WATCH windows to reload it afterword. Load a variables list file It allow to reload a list of variables previously saved. The content of the variables WILL NOT BE INIZIALIZED. Load a variables list file with value It allow to reload a list of variables previously saved.
VTB USER GUIDE Errors are sampled by directly by the target hardware in REAL TIME and they are displaied in TEMPORAL order. It is also possible to save the logging list in a file to analyse them afterword.
VTB USER GUIDE Scope Enable the digital scope (see relative section) DEBUG.NET options It allows to set some DEBUG options. Block Read Delay (Ms) If this option is greater than ZERO a delay is added after the read of a block. If DEBUG uses the serial port RS232 IT ISN'T NECESSARY. It can be useful in ETHERNET because the high speed of the protocol could create some problem to the VTB application (slowdowns).
VTB USER GUIDE Display the content of TASK PLC WARNING: in TASK PLC it isn't possible to set a Break-Point. 13.2 Writing of a variable It is possible to change the value of all the variables in the WATCH list. Double click on the value and then write the desired value. If the variable is a type BIT the double click switches from TRUE to FALSE and vice versa. 13.3 Insert/Remove a Break-Point The insert of a Break-Point allows to break the program in a specified point.
VTB USER GUIDE 13.4 Firmware update With DEBUG application it is possible to update the FIRMWARE of the hardware in use. WARNING: FIRMWARE update can be executed only by serial port RS232. With the INFO button this window is showed: From Menu Gestione Firmware we can chose between two options: Update from Server In this case an INTERNET connection is necessary. The application checks if on SERVER PROMAX there is a newer version of the FIRMWARE proposing the updating.
VTB USER GUIDE 13.5 Digital Scope DEBUG.NET provides a SCOPE application to further support of debugging. DIGITAL SCOPE is able to monitor the variables in the WATCH window. The scope can display up to 3 CHANNEL.
VTB USER GUIDE Selects the variable to connect to a channel. The variable must be in the WATCH window. Enables or disables the TRACK of a channel. Sets an OFFSET on the TRACK. Enabling LATCH, when the variable overcomes the Latch value, the TRACK will be FROZEN. Set the BASE-TIME for all the tracks. When scope is in OFF state, it aloows to scroll the track in the sampled memory. Scope ON/OFF. Positioning the mouse on a point of the track, the value of the variable will be showed.
VTB USER GUIDE 14 CANOPEN CONFIGURATOR The CanOpen Configurator software, is a tool that is included in the VTB IDE package and allow to describe the CanOpen net that a Promax CNC will use. With this software, the developer can easily describe the number of slave nodes and the various PDOs that the net will exchange. 14.1 Note on the devices using This software can work with Promax CanOpen slaves (Old CanIo and CanAx or newer NG series) and also with third companies slaves.
VTB USER GUIDE 14.
VTB USER GUIDE Can Open Configurator interface, appear as a standard Windows style application, with classics menu and tool bar. Then there is a configuration panel, that shows the actual configuration with the name of the file and the various nodes included. The other section can show a summary of the characteristics of the selected PDO. Tool bar New Configuration - From menu File → New It creates a new configuration file. The previous one is closed requesting a confirm for saving.
VTB USER GUIDE Configuration panel The Configuration panel it's the real work area of the application. It shows the actual net configuration and makes possible to modify it. Every work that we must do in our file, can be made here, selecting various informations and using the tool bar or menu command.
VTB USER GUIDE The tree structure displays the composition of the configured CanOpen net. The root it's the project name and every branch represents a node. In example, taken from a real configuration, we have: • NGM13 it's the slave/node type; • node id it's 2; After, there is a very useful function: configuration time-out (see 111). Then we can see the defined structure of the device we are using, taken from its EDS file. Here we have a device that have four TX (transmit) and four RX (receive) PDO.
VTB USER GUIDE Change PDO configuration Now, let's see how we can change or add a PDO configuration in a slave device. To change the PDO configuration, we can make a double-click on the required PDO, or select “Modify → PDO Configure” PDO Type Objects Configured PDO Property . In the first row of the form that will appear, we can read the device name, then the PDO type-id. The first property that can be setted, is the “modo”, mode, that define the PDO mode of work.
VTB USER GUIDE With a double-click on one of it, will open a form where we can see and set the object that we want to manage. It shows the name of the object, that we can change to easy remember it, the Can Open object dictionary index and subindex and the length, expressed as bit. Changing the index, always expressed as hexadecimal number, the software will search the relative object inside the EDS file of the device, with its standard name.
VTB USER GUIDE 14.4 PDO characteristics panel This panel make a summary of PDO properties. On the upper edge, it shows the number of devices that the project contains. Then, selecting a PDO of one device, it will show all the information about it, like Mode, Cob-id, length and so on. It's only a visualization, it isn't possible to change any property on it.
VTB USER GUIDE 14.5 Project management How to add a node To add a node in a project, we have two main possibility: • add a node using a EDS file,“+EDS” button; • add a node from library; About the using the library, we can talk about later (see 116). Using the EDS file, we can see a list of the devices that are present in the system, where it's possible to choose the required one.
VTB USER GUIDE Opening a project Starting the Configuratore inside VTB IDE, it will automatically open the configuration related to the VTB project. Also there is the possibility to open a different project, using the commands described above (see 109). 14.6 Library using Configuratore gives the possibility to save a ready made and tested configuration, that could be used inside any other project that have to use the same particular device.
VTB USER GUIDE Open a configuration The “+lib” button (see 109), gives the access to the library, where a particular configuration can be selected. Every configuration will be displayed with its description, allowing to see the already configured objects or properties, for ex. After the configuration as been inserted in the project, it can be modified as required in the normal manner. fig. 14.13: Insert from library form 14.7 Note on “packed” PDOs A particular case of PDOs are “packed” PDO.
VTB USER GUIDE fig. 14.14: First node Pdo declaration Second node PDO declaration Third node PDO declaration There are displayed three I/O slaves, old Promax devices named CanIo and CanAx, that have the RX1 PDO configured. As we can see the first slave (CanAx, node 9) have the PDO setted to “Fast”, while the two others have the same one as “Manual”. But have a look on the summary on the right of each image.
VTB USER GUIDE The first one is the “packed” PDO, this PDO will be read from all three slaves for the output state. But how can they split its own data from the others? On every slave there is a parameter that specify this information. As it is displayed in the figures above and showed in fig. 14.17, on every slave there is a parameter (“byte PDO uscite”) that specify to the devices, where in the PDO data, starts the byte that it have to use.
VTB USER GUIDE Index 1 INTRODUCTION ........................................................................................................................ 3 2 NOTES ON PROGRAMMING LANGUAGE ............................................................................ 3 3 DEVELOPMENT ENVIRONMENT........................................................................................... 4 4 3.1 Toolbar.....................................................................................................
VTB USER GUIDE 7 OPERATORS ............................................................................................................................. 33 Logic and Mathematical Operators ..................................................................................... 33 7.2 Notes on Expressions .......................................................................................................... 34 8 7.1 MATH FUNCTIONS .......................................................................
VTB USER GUIDE SER_PUTBLK ............................................................................................................. 48 SER_PUTST ................................................................................................................ 48 11.2 MISCELLANEOUS API FUNCTIONS ............................................................................. 49 GET_TIMER ...............................................................................................................
VTB USER GUIDE IMS_READ .................................................................................................................. 63 11.7 ETHERNET FUNCTIONS ................................................................................................. 63 SET_IP ......................................................................................................................... 64 PXETH_ADD_PROT .................................................................................................
VTB USER GUIDE TEMPERATURE READING ON NG35 ................................................................. 79 11.10 Functions for NGMsX - NGMEVO ............................................................................... 80 NG_DAC – Analog Outputs NGMsX ...................................................................... 80 NG_DAC_CAL - CALIBRATION OF THE ANALOG OUTPUT OFFSET NGMsX 80 NG_ENC - ENCODER INPUTS .............................................................................
VTB USER GUIDE 12.1 Enabling the creation of the COMPONENT NGFRAMEWORK ...................................... 96 12.2 Exporting VARIABLES ...................................................................................................... 97 12.3 Exporting FUNCTIONS...................................................................................................... 97 13 APPLICATION DEBUG ........................................................................................................... 98 13.