VISTA read problem

Specific issues occuring when using TRINAMIC modules with National Instruments LabVIEW

VISTA read problem

Postby Phil » 05 Oct 2010, 16:19

Schrittmotorsteuerung.zip
(33.95 KiB) Downloaded 155 times
Hello,
I have a problem with reading from a TMCL module. With the help of the LabView VI provided by Trinamic I was able to move the linear stage controlled by a module from Trinamic. But now I want to read the actual position and I am just not able to do it. I searched for solutions but as I am using Mac OS X I can't use a .dll file. My VI which does not really work is attached. As you can see I tried to read the reply:
1. directly after the move command (for test purposes)
2. after giving a new command "get axis parameter" (instruction number 6 with type 1 to get the actual position - I got the hex code from the VI TMCL.vi provided by Trinamic)

Now I am not even sure if the replies are correct but I am quite sure they are not. The position reply should update while the stage is moving... Could anyone please help me with that?

Regards
Phil
Phil
User
User
 
Posts: 4
Joined: 05 Oct 2010, 14:43

Re: VISA read problem

Postby G_geek » 06 Oct 2010, 09:53

Hello Phil,
looks like you have a timing problem here....
Your program reads the module reply with a fixed delay of 20ms after each write, I would recommend to remove these delays and place a while loop around the "Bytes at port" property node which will be stopped once the complete answer (9 Bytes) has been received and then do the "read VISA".... (see picture for example...)
Additionally you should flush the receive buffer before writing a new command to make shure that there is nothing left from a previous command.
Image

On this page http://www.w71775bjq.homepage.t-online.de/39994.html you will also find a LABVIEW library and a Test-Application which will exactly do what your code should do...

hope it was helpful

have fun
G_geek
User avatar
G_geek
Power User
Power User
 
Posts: 42
Joined: 15 Dec 2009, 21:32
Location: Germany

Re: VISA read problem

Postby Phil » 27 Oct 2010, 11:43

Hello again,
I now tried the .llb file. I have a questions: Is it possible to get the password for the vi TMVL_move_to_position? Because I really want to know how to read from my device correctly. I didn't make until today, the reply in my code always gives me first the last move order and after another click on my read button the position. I don't know why. If you want to have a look at my latest try...
Attachments
Archiv.zip
(41.71 KiB) Downloaded 139 times
Phil
User
User
 
Posts: 4
Joined: 05 Oct 2010, 14:43

Re: VISA read problem

Postby Phil » 27 Oct 2010, 14:18

Hello again,
I redesigned my program a little. I am now able to read from my device, but the reply is not the one I need. Is it possible to get the password for your .llb? Because I tested it and it seems to work... I want to find my mistake!

Regards
Phil
Phil
User
User
 
Posts: 4
Joined: 05 Oct 2010, 14:43

Re: VISA read problem

Postby igor_jarkow » 28 Oct 2010, 11:56

Ich hätte gerne auch den Passwort wissen! Bei mir ist das Problem beim ablesen von Daten. Den Answer von der Karte TMCM-351 sehe ich als kommische zeichen, wenn ich die Anzeige als Hexadezimal darstelle lassen, dann kann man HEX sehen. Aber wenn ich versuche im LabView im Blockdiagramm die Werte vom String zu behandeln, dann geht es einfach nicht! Ich bräuchte eigentlich aktuelle position abzufragen!
igor_jarkow
Newbie
Newbie
 
Posts: 1
Joined: 25 Oct 2010, 15:21

Re: VISA read problem

Postby Olav Kahlbaum (TRINAMIC) » 29 Oct 2010, 07:46

Die Antwort von der Karte ist (wie ja auch der Befehl an die Karte) kein direkt lesbarer String (ASCII-Format), sondern besteht aus neun Bytes (Binärformat), bei denen es keinene Sinn macht, diese als Zeichen darzustellen. Der zurückgegebene Wert (z.B. bei Abfrage der Position) steckt im fünften, sechsten, siebten und achten Byte der Antwort. Diese vier Bytes bilden zusammen eine 32-Bit-Integer-Zahl. Siehe auch TMCM-351 TMCL Firmware Manual, Kapitel 5.2.
User avatar
Olav Kahlbaum (TRINAMIC)
Site Admin
 
Posts: 3369
Joined: 11 Aug 2006, 08:02

Re: VISA read problem

Postby G_geek » 29 Oct 2010, 14:53

Hi,

@Phil......
Have you really checked my VI`s?? Tested the example application?? Doesn`t look so.....

If you open and run the example application "TMCM_310_testapplication.vi" you will see
1: how to use the "event structure" in Labview (since this might cause problems if not correctly used, as in your "Schrittmotorsteuerung.vi")
2: Once you open the source of the example application (since this is is not pw protected) you can open the frontpanel of e.g. the TMCL_get_axis _parameter. Here you will see the direct response of the module in binary form as well as the "humanized" value of the bytes 5,6,7 and 8 as integer 32value(its the "return value" indicator).
Since this is what you want to see there is absolutely no need to share the password here...

If you absolutely want to fix your "schrittmotorsteuerung1.vi" then do the following:
-remove this event-structure on the left (the one within the 1st step of the sequence structure)
-place all the "instruction" values from this deleted event structure directly into the corresponding event of the remaining event structure
-change the "position-reply-button-pressed event" to the general "timeout"event and wire a 100ms constant to the event structures timeout terminal

Now your application will read the actual position of the selected motor every 100ms and you will see the changes in the reading response directly
But note that the response is still in binary format which needs to be "translated" to an integer value (tip: use the string subset to extract the bytes 5-8 and pass them through the "type cast" function...)

@Igor
See above, there is no need to share the password, everything is already there and documented in the TMCL reference manual from TRINAMIC
You just need to read it!
If you see "komische Zeichen" you need to make yourself familar about the difference between HEX, BINARY,ASCII etc. and then convert them to something you can read (see tip above)

have fun
G_geek
User avatar
G_geek
Power User
Power User
 
Posts: 42
Joined: 15 Dec 2009, 21:32
Location: Germany

Re: VISA read problem

Postby Olav Kahlbaum (TRINAMIC) » 01 Nov 2010, 09:10

Thank you once again, G_geek! Many people don't seem to be familiar with the differences between ASCII and binary formats.
User avatar
Olav Kahlbaum (TRINAMIC)
Site Admin
 
Posts: 3369
Joined: 11 Aug 2006, 08:02

Re: VISA read problem

Postby Phil » 02 Nov 2010, 11:56

Thanks for the reply G_geek
well I tested your testapplication.vi and I have one problem with it. When I, for example, have the absolute position 0 in the middle of my moving distance, I can get negative positions when I rotate the motor to the left (or right, doesn't matter). Then I get weird replies even with your code. The error message then is: timeout read data (code number 1275301). I tried to increase the timeout but it doesn't work.

I have a similar problem with my code. It crashes sometimes when I should get negative position reply. But sometimes, it just crashes and I don't know why. And I have the problem that the first reply after pressing the move forward or backward of to position button is 18 bits long! It gives 2 replies back! The last command before writing the read order and after that the read reply. I tried to solve it by searching the string for the correct beginning of the position reply but I think there is something wrong with the reply because it is 18 bits long. Maybe this causes the program to crash. Do you have an idea of what it could be?
Attachments
Archiv.zip
(39.85 KiB) Downloaded 125 times
Phil
User
User
 
Posts: 4
Joined: 05 Oct 2010, 14:43

Re: VISA read problem

Postby G_geek » 03 Nov 2010, 16:00

Hi Phil,
you`re on the right track...just a few steps to complete

1) I found that you have activated the termination end character at the "VISA initialize" ,set this to "false" to prevent communication termination if a 0x0A is inside the data. The additional "VISA open" after the initialisation can be removed...

2) within the "timeout" event you need to wait a little bit between writing the command to the device and reading the answer...
Place a sequence structure into the error cluster behind the "VISA write" and put a 50ms "wait until next" inside.
The four "position" bytes only need to be passed through the "type cast" function (numeric-> Data manipulation) with a default I32 at the type input and you`ll have nice positive and negative position readings....

With these modifications I can use your code without problems and the motor turns nicely whenever I press the buttons....
I`ve also tested my demo application and found no problems with negative readings....

have fun
G_geek
User avatar
G_geek
Power User
Power User
 
Posts: 42
Joined: 15 Dec 2009, 21:32
Location: Germany

Re: VISA read problem

Postby Luap » 19 Feb 2011, 14:53

Hallo G_geek,

bist du bereit dein Passwort für deine VIs zur Verfügung zu stellen?
Ich würde gerne auf ein paar VIs aufbauen bzw erweitern.
Wäre echt nett und vielen Dank dafür.

viele Grüße Paul
Luap
User
User
 
Posts: 14
Joined: 21 Dec 2010, 16:28

Re: VISA read problem

Postby G_geek » 21 Feb 2011, 10:43

Hallo Paul,
kurze Antwort:
Nein!
lange Antwort:
1)Die von mir zur Verfügung gestellten VI`s (GGP,MVP etc.) stellen (als eigenständige Sub VI`s)die kleinsten möglichen Einheiten der Kommunikation mittels LABVIEW mit den Trinamic Modulen dar, alles weitere sollte dann auf Applikationsebene passieren ich sehe hier keinen "Optimierungsbedarf" also auch keine Notwendigkeit das Passwort rauszugeben. (Bei den grundlegenden Funktionsblöcken von LABVIEW fragt ja auch keiner nach dem Passwort...)
2)Ich bin gerne bereit für die von mir zur Verfügung gestellten Sub-VI`s(und nur für diese ) hier den notwendigen Support zu geben, falls wer Probleme damit haben sollte. Wenn aber dann quelloffen da drin "rumgefummelt" wird, ist sinnvolle Hilfestellung kaum mehr möglich, da dann nicht mehr sichergestellt ist, dass man auch vom gleiche Code redet wenn was nicht funktioniert.
3)Die einzelnen VI`s haben alles was gebraucht wird, um professionell damit arbeiten zu können (Ein- und Ausgänge für die COM Schnittstelle und die Parameter sind deklariert und ein Errorhandling zur Einbindung in datenflussorientierte Programmstrukturen ist auch vorhanden, siehe Beispiel-Applikation die nicht PW geschützt ist).
Wenn Du also "..auf ein paar VI`s aufbauen bzw. erweitern ..." willst, würde mich mal interessieren was genau auf dieser Ebene verbesserungswürdig wäre...

have fun
G_Geek
User avatar
G_geek
Power User
Power User
 
Posts: 42
Joined: 15 Dec 2009, 21:32
Location: Germany

Re: VISA read problem

Postby Luap » 21 Feb 2011, 16:15

Hallo,

ich bin mom an einem Projekt dran wo ich eine Regelung/Steuerung für einen Prüfstand realisieren soll. Dabei muss ich zwei Schrittmotoren ansteuern und gewährleisten, dass sie genau um 90° versetzt rotieren.
So nun möchte ich den Encoder von beiden Schrittmotoren mit labview auslesen und die Werte in einem Diagramm übereinander legen und damit überprüfen ob Sie auch um 90° versetzt arbeiten.
Deshalb wollte ich das VI "TMCL_get_axis_parameter" erweitern im sinne von die eingelesenen Werte in einem Diagramm darstellen. Und das ganze mal zwei erweitern weil ich eben zwei Motoren habe und davon jeweils den Encoder
einlese und vergleiche.
Das Projekt ist auch nicht kommerziell, nicht das ich damit Geld verdienen möchte. Mir würde auch schon reichen, wenn du mir nur das eine VI zur verfügung stellst.
Wäre dir wirklich verbunden wenn das ginge.

vielen DANK

Grüße Paul
Luap
User
User
 
Posts: 14
Joined: 21 Dec 2010, 16:28

Re: VISA read problem

Postby G_geek » 21 Feb 2011, 18:19

Hi Paul,
sorry, aber das ist ganz klar Applikations Ebene.
Datenvisualisierung hat absolut nichts in einer Low Level Kommunikationsroutine zu suchen.Damit würdest Du dir auch keine Freude machen....
Was Du da machen willst kann meine "TMCM 310 testapplication" aus der Library auch schon fast....
Du müsstest nur noch die Indikatoren "pos motor 0" und "pos motor1" in einen Cluster packen und dann auf einen WaveformChart Indikator schicken.... fertig.
Schau Dir im Quellcode der Testapplikation mal den case "read position" an, da sieht man wie es geht.
Eigentlich nur das "get_axis_parameter.vi" mit "actual position" als Parameter in einer Schleife laufen lassen und dann die "return value" weiterverarbeiten/visualisieren.

have fun
G_geek
User avatar
G_geek
Power User
Power User
 
Posts: 42
Joined: 15 Dec 2009, 21:32
Location: Germany

Re: VISA read problem

Postby Luap » 28 Feb 2011, 13:50

Hallo G_geek,

kannst du mir erklären, was im Case "No Action" gemacht wird? verstehe das iwie nicht.
Außerdem wüsste ich wieso ich kein zusätzliches Case hinzufügen kann?

gruss Paul

ps: kann ich dich vllt per email weiters Kontaktieren, falls ich weitere fragen habe?
Luap
User
User
 
Posts: 14
Joined: 21 Dec 2010, 16:28

Next

Return to LabVIEW (TM) specific issues

Who is online

Users browsing this forum: No registered users and 0 guests