down load program

down load program

Postby richard » 04 Apr 2008, 09:05

I want to download a program to TMCM-102IF through VB6.0. The program consists of 5 commands. How can I down load the commands through VB6.0 into module?
Thanks.
richard
User
User
 
Posts: 8
Joined: 04 Mar 2008, 07:03

Postby Olav Kahlbaum (TRINAMIC) » 07 Apr 2008, 07:54

To download a TMCL program into a module, the following steps have to be performed (these are the same steps that also the TMCL IDE does):
-Send the "enter download mode command" to the module. This is command 132, with type, motor and value parameter all set to zero.
-Send your commands to the modul as usual (for every command you will get a normal reply, but with the status byte set to 101 instead of 100 (101 means "command successfully stored").
- As the last command, send a command 0 with all parameters set to zero (this is just an end marker for the disassemble function of the TMCL IDE).
- Send the "exit download mode" command. This is command 133, with type, motor and value field set to zero.

During development of your programm you can manually check if everythibng went okay by using the disassemble function of the TMCL IDE.
User avatar
Olav Kahlbaum (TRINAMIC)
Site Admin
 
Posts: 3356
Joined: 11 Aug 2006, 08:02

Re: down load program

Postby harold » 26 Jan 2010, 15:42

Hello Olav,

I read your postings Tue Sep 12, 2006 10:39 am and Mon Apr 07, 2008 7:54 am.

I am a developer and a costumer ask me to write a program, which download a TMCL program from the PC into the PD3-110-42-232 via Mouseclick (and via a RS-232). I am NOT a
professional in TRINAMIC; I don't know this machine before.

To set the PD3-110-42-232 in binary Mode (01 85 00 00 00 00 00 00 86, as binary) and to start the TMCL program in the PD3-110-42-232 (01 81 01 00 00 00 00 00 83, as binary) is no problem; it works.

The problem is to download a new TMCL program into the PD3-110-42-232.

My program send:

-------------

- command 132 (enter download mode):
01 84 00 00 00 00 00 00 85
as binary, the PD3-110-42-232 answer (I think it is ok)

-------------

- a little TMCL program for example:

00000100
00000000
00000000
00000000
00000000
00001011
10111000
11000111
00011011
00000001
00000000
00000000
00000000
00000000
00000000
00011100
00000100
00000000
00000000
00000000
00000000
00000000
00000000
00000100
00011011
00000001
00000000
00000000
00000000
00000000
00000000
00011100
00011100
00000000
00000000
00000000
00000000
00000000
00000000
00011100

the PD3-110-42-232 did not answer, I think only to send the binary (load from the *.bin file, which the TMCL-IDE generate) is wrong, after I read you postings:

"For every command in the file:
Read 8 bytes from the file. Send the address byte of the module, and add the address byte to the checksum byte (the 8th byte of the record from the file). Then send these 8 bytes.
The module will send a reply where the status code is set to 101 (this means "command stored")."

"-Send your commands to the modul as usual (for every command you will get a normal reply, but with the status byte set to 101 instead of 100 (101 means "command successfully stored").
- As the last command, send a command 0 with all parameters set to zero (this is just an end marker for the disassemble function of the TMCL IDE).

-------------

- command 133 (exit download mode):
01 85 00 00 00 00 00 00 86
as binary, the PD3-110-42-232 answer. I thought it is ok,
before I read your postings.

"After the last command has been sent, send the "exit download mode" command (command 133, all parameters set to 0)."

and

"- Send the "exit download mode" command. This is command 133, with type, motor and value field set to zero."

-------------

A little problem is, that the PD3-110-42-232 is in a factory far away without online-contact; so I can't test it.

It's possible to send an example in binary?

Thank you very much!
harold
User
User
 
Posts: 2
Joined: 19 Jan 2010, 20:23

Re: down load program

Postby Olav Kahlbaum (TRINAMIC) » 27 Jan 2010, 09:10

On our website you can also find a little TMCL program download tool. Maybe it is okay for your customer to use that one? Then you won't have to write your own download tool. It can be found here: http://www.trinamic.com/tmc/media/Downloads/modules/TMCL/AppNotes/TMCLDownloader.zip.
User avatar
Olav Kahlbaum (TRINAMIC)
Site Admin
 
Posts: 3356
Joined: 11 Aug 2006, 08:02

Re: down load program

Postby Highlander » 30 Jan 2010, 01:21

I am
very interesting to know the binary code before the tmc-code, which saw by the questions of harold.

I hope, it's possible to answer me in a resolution.

cu
posting.php?mode=reply&f=13&t=992#

The in future Highlander
Highlander
Newbie
Newbie
 
Posts: 1
Joined: 30 Jan 2010, 00:57

Re: down load program

Postby Olav Kahlbaum (TRINAMIC) » 01 Feb 2010, 09:28

I also would be interested what that "binaray code" means. I do not understand what this should do (and I prefer hexadecimal code).
User avatar
Olav Kahlbaum (TRINAMIC)
Site Admin
 
Posts: 3356
Joined: 11 Aug 2006, 08:02

Re: down load program

Postby harold » 02 Feb 2010, 03:30

Hello Olav,

thank you very much.

The TMCLDownloader.exe is exactly the program, which I need!

But I saw it, before I ask in the forum.

The little problem is, that the customer need a complete automatic program. No manual download. The programs download into the PD3-110-42-232 should change complete automatic and the start of several different TMCL-programs also.

And so I need the code to download the TMCL-programs. The customer create his own TMCL-programs, my job is only to download these programs, to start and to stop the PD3-110-42-232 and to download then next TMCL-program and so on.

I think, it's no technical problem to make the TMCLDownloader.exe to a "slave" of my program; but I think, it's not correct to do this.

I think "binary code" is the language of the PD3-110-42-232 and it's easily to program in this way, but I have no problem with hexadecimal code; or other code.

I think it's the best, to make a unit from the TMCLDownloader.exe. If you want to send me the source, I will do it.
harold
User
User
 
Posts: 2
Joined: 19 Jan 2010, 20:23

Re: down load program

Postby Olav Kahlbaum (TRINAMIC) » 02 Feb 2010, 09:26

For more information on downloading a binary TMCL file to a module, please see the following two topics:
http://www.trinamic.com/ttdg/viewtopic.php?t=64
http://www.trinamic.com/ttdg/viewtopic.php?t=992

I will think of releasing some source code of the TMCL program downloader.
User avatar
Olav Kahlbaum (TRINAMIC)
Site Admin
 
Posts: 3356
Joined: 11 Aug 2006, 08:02

Re: down load program

Postby Stefanµ » 21 May 2012, 15:26

und wie kann man
Loop:
und
JC NZ ,Loop
mit dem Verfahren zum EEProm senden?

sendCmd(1, 132, 0, 0, 0); // Enter Download Mode Command
sendCmd(1,UF4,0,0,0); // Set RAM Write Pointer to 0
sendCmd(1,MVP, 2, 0, 0) // mvp coord
-> Loop:
sendCmd(1, GAP,POS,0,0); // Get X
sendCmd(1, UF4,4,0,0); // Write Akku to RAM + increment
sendCmd(1, UF0,0,ADC4,0); // Get ADC
sendCmd(1, UF4,4,0,0); // Write Akku to RAM + increment
sendCmd(1, GAP,8,0,0); // Position reached
-> sendCmd(1, 21,1,0, Loop); // JC NZ, Loop
sendCmd(1, UF4,2,0,0); // Get RAM Write Pointer
sendCmd(1, 35,1,2,0 ); // AGP Akku to GP1
sendCmd(1,0,0,0,0); // End Marker für disassemble
sendCmd(1, 133, 0, 0, 0); // Exit Download Mode Command
Stefanµ
User
User
 
Posts: 9
Joined: 18 Nov 2011, 16:02
Location: Munich

Re: down load program

Postby Olav Kahlbaum (TRINAMIC) » 22 May 2012, 08:33

Den JC-Befehl eigentlich genau so wie die anderen Befehle auch. Nur den Label (z.B. "Loop") muß man natürlich durch die Adresse des Befehls ersetzen, an den man springen möchte (also im Prinzip genau so, wie es der TMCL-Assembler in der TMCL-IDE auch macht).
In diesem einfachen Fall (Rückwärtssprung, der Label liegt also irgendwo vor dem Sprungbefehl) muß man sich ja nur beim Übertragen merken, an welcher Adresse der anzuspringende Befehl liegt und beim Übetragen des Sprungbefehls diese Zahl im Parameterfeld angegben. Da die Befehlsadresse mit jedem übertragenen Befehl um 1 inkrementiert wird und der Download in diesem Beispiel bei Adresse 0 begonnen wurde, wäre das hier eine 2, man würde in diesem Beispiel also JC NZ, 2 übertragen (sendCmd(1, 21, 1, 0, 2)).
Hat man allerdings auch Vorwärtssprünge, dann muß man vor der Übertragung in zwei Durchgängen assemblieren (Zwei-Pass-Assembler wie in der TMCL-IDE). Aber da könnte man auch die TMCL-IDE benutzen (z.B. aus anderen Programmen heraus im Kommandozeilenmodus) und sich so etwas Arbeit sparen.
User avatar
Olav Kahlbaum (TRINAMIC)
Site Admin
 
Posts: 3356
Joined: 11 Aug 2006, 08:02

Re: down load program

Postby Stefanµ » 23 May 2012, 17:03

Danke.
das klappt ja alles soweit.
Aber leider doch nicht ganz.
Hier mein test: ich lade example.programm mittels IDE hoch.(Rol, wait,mst, ROR,wait,MST)
Starte mein Programm-schreiben.
Im TMCL-IDE -> Disassemble zeigt wunderbar mein Programm an.
(Firmware: 6.37, ide2.02, 612-SG)
wenn ich jetzt aber mittels C-Programm meine App starten will [sendCmd(1,129,1,0,0); oder sendCmd(1,129,0,0,0);] führt er immer noch das example-Programm aus.
(Habe schon aus-ein-schalten und reset probiert)

Muss man da noch einen Befehl-Pointer auf 0 setzen, bevor man den Download-Mode startet?

den Status protokolliere ich auch mit(100 bei 132 und 133, bei allen anderen 101), wie gewünscht.
-----
Programm-schreiben-Funktion:
private: System::Void butPwrite_Click(System::Object^ sender, System::EventArgs^ e) {
sendCmd(1, 132, 0, 0, 0); // Enter Download Mode Command
sendCmd(1,UF4,0,0,0); // #0 RamWritePointer auf 0 setzen
sendCmd(1,MVP, 2, 0, 0); // #1 Move to Coord Mo Var0
sendCmd(1,GAP, POS, 0, 0); // #2 Get act.Position
sendCmd(1,UF4, 4, 0, 0); // #3 Write Akku to RAM + Increment
sendCmd(1,UF0, 0, ADC4, 0); // #4 Get ADC-Value
sendCmd(1,UF4, 4, 0, 0); // #5 Write Akku to RAM + Increment
sendCmd(1,GGP,0,2,0); // #6 Get Global Parameter 0, Bank2
sendCmd(1,33,9,0,0); // #7 CALCX LOAD
sendCmd(1,SGP,132,0,0); // #8 SGP TickTimer,0,0
sendCmd(1,GGP,132,0,0); // #9 GGP TickTimer
sendCmd(1,33,1,0,0); // #10 CALCX SUB
sendCmd(1,20,0,0,0); // #11 COMP 0
sendCmd(1,21,6,0,9); // #12 JC LT, 9
sendCmd(1,GAP, 8, 0, 0); // #13 Get Position Reached
sendCmd(1,21, 0, 0, 2); // #14 Jump Conditional ZE Akku==0 zu Befehl 2
sendCmd(1,GAP, POS, 0, 0); // #15 Get act.Position
sendCmd(1,UF4, 4, 0, 0); // #16 Write Akku to RAM + Increment
sendCmd(1,UF0, 0, ADC4, 0);// #17 Get ADC-Value
sendCmd(1,UF4, 4, 0, 0); // #18 Write Akku to RAM + Increment
sendCmd(1,UF4, 2, 0, 0); // #19 Get WritePointer
sendCmd(1,35, 1, 2, 0); // #20 AGP 1,2 - Akku to GP
sendCmd(1,0,0,0,0); // End Marker für disassemble
sendCmd(1, 133, 0, 0, 0); // Exit Download Mode Command
}
Stefanµ
User
User
 
Posts: 9
Joined: 18 Nov 2011, 16:02
Location: Munich

Re: down load program

Postby Olav Kahlbaum (TRINAMIC) » 24 May 2012, 08:00

Bevor man ein Programm neu startet, ist es empfehlenswert, auch noch einmal den Befehl 131 (reset TMCL application) auszuführen, damit Stack Pointer, Akkumulator und X-Register sowie Flags auf Null gesetzt sind. Dann startet man am mit dem Run-Befehl (am besten mit Typ=1 und Value=0, um von Adresse 0 zu starten).
Daß allerdings das bereits überschriebene Programm ausgeführt wird, kann eigentlich nicht sein. Es ist nirgendwo anders gespeichert. Vielleicht verhält sich Ihr neues Programm ähnlich wie Ihr erstes Beispielprogramm?
User avatar
Olav Kahlbaum (TRINAMIC)
Site Admin
 
Posts: 3356
Joined: 11 Aug 2006, 08:02

Re: down load program

Postby Stefanµ » 02 Jul 2012, 11:20

habe das Problem gefunden:
Hatte beim Hochladen kein STOP mit drin:

...
sendCmd(1,35, 1, 2, 0); // #20 AGP 1,2 - Akku to GP
sendCmd(1,28, 0, 0, 0); // #21 STOP (End of TMCL-Application)
sendCmd(1,0,0,0,0); // End Marker für disassemble
sendCmd(1, 133, 0, 0, 0); // Exit Download Mode Command
sendCmd(1,131,0,0,0); // Reset TMCL Application -> Foren-Antwort
Stefanµ
User
User
 
Posts: 9
Joined: 18 Nov 2011, 16:02
Location: Munich

Re: down load program

Postby TRINAMIC_SK » 03 Jul 2012, 08:52

OK, danke für das Feedback.

(Topic closed)
User avatar
TRINAMIC_SK
Site Admin
 
Posts: 55
Joined: 19 Apr 2010, 10:41
Location: Hamburg


Return to Modules / Interface issues / PC software

Who is online

Users browsing this forum: No registered users and 1 guest