How do I define and call a function?

How do I define and call a function?

Postby noamyuzuk » 05 Feb 2007, 19:35

Is anyone here can help me to create a function and to call her?

noam.... 8)
noamyuzuk
User
User
 
Posts: 3
Joined: 05 Feb 2007, 19:30

Postby Olav Kahlbaum (TRINAMIC) » 06 Feb 2007, 08:56

This can be done using the commands CSUB and RSUB. CSUB calls a subroutine, and RSUB jumps back to the command following the CSUB command.

Example:
Code: Select all
Loop:
    MVP ABS, 0, 10000  //Move to position 10000
    CSUB MyFunction    //Call a subroutine
    //...do something else here...
    JA Loop            //Jump to start of the main loop

MyFunction:    //Here is the subroutine
    WAIT POS, 0, 0  //wait until position reached
    MVP ABS 0, 0    //move back to position 0
    WAIT POS, 0, 0  //wait until position reached
    RSUB    //End of our subroutine



Please see also chapter 3.20 and 3.21 in the TMCL reference manual.
User avatar
Olav Kahlbaum (TRINAMIC)
Site Admin
 
Posts: 3363
Joined: 11 Aug 2006, 08:02

Postby noamyuzuk » 06 Feb 2007, 10:32

thanks to you and how i can use in direct mode to call a function ?

and how can i use in user function that found in direct mode?

noam...
noamyuzuk
User
User
 
Posts: 3
Joined: 05 Feb 2007, 19:30

Postby Olav Kahlbaum (TRINAMIC) » 07 Feb 2007, 08:57

In this case the CSUB and RSUB commands can not be used. Instead, you will have to use the "run" command in direct mode (like the TMCL IDE does to start a program). This is command 129 (it does not have a mnemonic). These commands are listed in chapter 3.34 of the TMCL manual. Your TMCL program in the module should then end with a "STOP" command.
Use the run command with the "type" parameter set to 1 and the "value" parameter set to the address from where you would like to start the program. A TMCL program normally starts at address 0, but you can also start at any other address, e.g. if you would like to define and use more than one function. In this case, use labels and turn on the function "generate symbol file" in the "Options" dialogue of the TMCL IDE (menu "Settings", function "Options"). The TMCL assembler then also geenrates a text file that conatins the address of every label, so that you can take the addresses from there.
User avatar
Olav Kahlbaum (TRINAMIC)
Site Admin
 
Posts: 3363
Joined: 11 Aug 2006, 08:02

Postby noamyuzuk » 08 Feb 2007, 11:24

Thanks but how can i dill with bin file?

how can i open it?

noam
noamyuzuk
User
User
 
Posts: 3
Joined: 05 Feb 2007, 19:30

Postby Olav Kahlbaum (TRINAMIC) » 09 Feb 2007, 09:16

I did not mean to generate a binary file, but a symbol file (there are two options in the assembler options dialogue: "Generate a symbol file" and "Write output to binary file". Please tick the first one, "Generate a symbol file"). The symbol file (*.sym) is just a text file that can be opened with any text editor (of course also the editor of the TMCL IDE).

Binary files (*.bin) generated by the TMCL assembler (with the option "Write output to binary file" switched on) contain the binary representation of the TMCL program (which is sent to the module when clicking the "Download" button). Information about the format of such files and how to use them can be found here: http://www.trinamic.com/ttdg/viewtopic.php?t=64.
User avatar
Olav Kahlbaum (TRINAMIC)
Site Admin
 
Posts: 3363
Joined: 11 Aug 2006, 08:02

A direct programming can be done in my software.

Postby Andrew » 13 Oct 2007, 19:56

A lucky coincidence.
My software, which I call TMCM-DLL allows to do what you require.
That is: to run a TMCL program in direct mode.

To those who do not understand what a user wants here:
He wants to execute a jump in direct mode, rather than send the jump to the module.
My software allows exactly that, and much more. You can write fully fledged direct programs in it. Please read about it here:
http://www.trinamic.com/ttdg/viewtopic.php?t=30
Andrew
 


Return to Trinamic Motion Control Language (TMCL)

Who is online

Users browsing this forum: No registered users and 1 guest