Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing CAN-Device using CANopen

Hi all
 
Today I started with the initial startup of a CAN system, which should be used in a test rig.
First some information about the system:
- 3 external nodes connected to the bus (using CANopen protocol (at least I was told so), usually running autonomously)
- 1 CAN interface card (NI PCI-CAN Series 2)
- PC-System running under WinXP professional
 
I know the cabling works, as this was tested with another software.
 
The first thing I made a few weeks ago, was to download some source from the forums. Looking at this, I created a simple vi, which should get data using SDO (attached).
I also attached some pictures of this other software (screenshot software, screenshot can-trace). I just tried to do the same (read a value), with the above mentioned vi. There is also a screenshot from this vi, when I executed it. First it seemed ok, but then I got a warning (probe 1) out of CWrite.vi and right afterwards I got an error (probe 2) out of CWait.
At another try I came out of CAN init.vi with a warning, but then I got an error "unknown object" when trying to write the data.
 
Could you give me some advice on that? The values I tried to send are the default values of the vi.
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 1 of 15
(6,745 Views)

Hi Becktho,

First of all the warning and the error you got means that there are Bus Problems and your controller had entered the error passiv status. The first thing you should verify is the Bus Termination foir your connection. To assume it is High Speed CAN, take care that your system uses two 120 Ohm resistors on both ends of your system, but not more.

The second is, you are using the SDO VI inside a while loop. Normaly this VI was written to be used for single command tasks, not for continuously operations. It may that the 100 ms timing is to fast for the device, because it uses Object configuration or for your network, because SDO Priority is not that high.

To find a solution, it would be nice if you could explain some more details about your needs. What are you doing with a SDO in a while loop?

 

Thanks

DirkW

0 Kudos
Message 2 of 15
(6,708 Views)
Hi Dirk
 
Thanks for your reply - it's a ray of light in a dark sky.. Smiley Wink.
There are three devices connected over the bus. The NI-Interface is linked to it, using a T-connection. I'll check the point with the resistor - maybe that's a problem.
 
The vi didn't run more than one iteration and it's just to get in touch with CAN, as this is my first app, using this technology.
 
In the end I first should read about 20 values, let the user edit them and write them back to one of the 3 devices.
 
Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
Message 3 of 15
(6,706 Views)
Hi becktho,
 
The first thing to consider starting with CANopen is to get the big picture about the Communication theory. Attached you will find a short introduction into CAN Bus and CANopen.
The second ressource should allways be the manufacturer manual for your Hardware.
There you can find the supported PDO's and SDO Configurations and i assume you used it for your getting started.
 
CANopen works mostly using Remote Frames (RTR) to ask a device for data and then the device answers on the same COB ID with data.
Therefore you need a write and a read operation with NI CAN.
 
Attached you will find a more simple type of programm communicting with a single CANopen sensor in peer to peer with a NI CAN device.
Perhaps this is a good starting point, to get it running first, before you step into the more advanced things.
 
Dirk W
0 Kudos
Message 4 of 15
(6,698 Views)

Hallo Dirk

Ich switche jetzt auf Deutsch, nachdem ich in deinem Beispiel-Code einen Kommentar auf Deutsch gesehen habe.

War heute wieder an diesem Prüfstand und habe dein Programm mal laufen gelassen und dabei folgendes Verhalten gehabt:
1. Kein Problem bis zur Funktion "ncWriteObj.vi" - dort wurde eine Warnung zurück geliefert.
2. In der Funktion "ncReadNetMult.vi" wurde dann ein Fehler (siehe Attachment) ausgelöst.

Leider macht diese Fehlermeldung irgendwie nicht so wirklich Sinn, da die Busteilnehmer mit Spannung versorgt sind. Die ganze Verkabelung wurde, wie vorher schon mal erwähnt, mit einem anderen Programm (ext. SW) und dem Notebook eines Kollegen getestet. Dieser Kommuniziert über eine Softing CANUsb-Schnittstelle mit den CAN-Devices - ohne Probleme und mit der selben Prüfstandeinstellung wie ich das Versuche. Der Bus ist in den Geräten 2x mit 120Ohm abgeschlossen - also müsste auch das passen.

Ebenfalls angehängt habe ich dein Programm, so wie ich es getestet habe.

Für weitere Tipps und Infos bin ich sehr dankbar. Ich werde in den nächsten Tagen auch mal versuchen über diese Softing Schnittstelle zu kommunizieren. Trotzdem ist mein Schlussziel immer noch die Verwendung der NI-Karte.

Danke für deine Bemühungen.

Thomas

Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
Download All
0 Kudos
Message 5 of 15
(6,621 Views)

Hallo Thomas,

Ja, ist ist zwar im Forum immer besser in Englisch, weil dann mehr Leute etwas davon haben aber jetzt wo wir mehr ins detail gehen muessen ist es vielleicht ion Deutsch besser.

Der Fehler bedeutet eigentlich nur das Client und Server irgendwie nicht miteinander kommunizieren koennen. Nachdem wir ja ein Kabel oder Abschlussproblem ausschliessen koennen, kann es eigentlich nur noch an der Baudrate oder einer falschen COB ID liegen.

Wie arbeiten denn deine Geraete genau. Dein VI arbeitet mit einer SDO Anfrage. Willst du einen einzelwert abfragen oder eine Uebertragung von mehreren Werten ausloesen?

Wenn du den Busmonitor in der richtigen Baudrate ueber den MAX (measurement und Automation Explorer) startes, empfaengst du da irgendwas von deinen Geraeten ohne das du irgendwas sendest?

Normalerweise Sendet ein Geraet seine daten ueber PDO's die entweder selbsstaendig gesendet werden oder ueber ein Remote Frame abgefragt werden.

Die Frage ist, was erwarten deine Geraete.  Vielleicht koenntest du  kurz die Anleitung zu einem deiner Geraete anhaengen und beschreiben was du genau auslesen willst?

Ich koennte dann mal erklaeren wie ich es machen wuerde.

PS. NI wird im Februar eine CANopen Library fuer NI CAN und unsere Karten herausbringen. Das sollte dann einiges erleichtern. Vielleicht hast du ja Lust einen Beta Test zu machen?

DirkW

0 Kudos
Message 6 of 15
(6,614 Views)
Hallo Dirk
 
Ist zwar schon wieder 'ne Weile her, aber hier bin ich wieder. Glücklicherweise bin ich einen Schritt weiter und konnte heute erstmals mit dem CAN-Device "reden".
 
Im angehängten VI siehst du was ich gesendet bzw. was ich empfangen haben. Gemäss einem vorhandenen CAN-Trace, habe ich 8Bytes (60 01 23 4A 00 00 00 00) an die ID 581 gesendet. Sowohl über die NI-CAN-Karte, als auch über die andere Schnittstelle. Bei den Versuchen zuvor hatte ich eine falsche Baud-Rate eingestellt (so eine Schande, jedoch wurde mir das vor längerer Zeit mal so mitgeteilt). Auf jeden Fall hätte ich gemäss CAN-Trace auf die ID 601 ebenfalls 8 Bytes (22 01 23 4A XX YY 00 00, wobei XX bzw. YY einen gültigen Wert haben) erhalten müssen, jedoch habe ich nur Daten auf die ID's 181 - 183 erhalten (wie im VI ersichtlich).
 
Was muss ich nun tun, um diese Werte korrekt auszulesen, bzw. gibt es eine elegantere Möglichkeit Daten abzurufen (es sind ca. 10 Werte die ich lesen bzw. evlt. überschreiben muss)?
 
Danke für deine Bemühungen
 
Thomas
 
P.S.:
Bezüglich dem Beta-Test lehne ich dankend ab. Da es meine erste Applikation mit CAN ist und ich zurzeit auch mit der Umstellung auf LV8.0 beschäftigt bin, würde ich lieber mit den vorhandenen Funktionen vorlieb nehmen, oder allenfalls bei dem endgültigen Release dieser CANOpen-Bibliotheken umstellen.
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 7 of 15
(6,449 Views)

Hi Thomas,

I try to answer your question in english because of the feedback from the forumand to give other users the chance to read this thread too.

I did the same stuff years ago and I tried it ones again. It seems you have an failure in your application.  To write to an object dictionary you have to write an SDO 601h (1537d) and to Read an SDO 581h(1409d) to get the answer about what you have written. The 601h ID uses 22h in Byte 0 to indicate it is a write and you will get back ID 581 with 60h in Byte 0, which mean everything worked ok. So perhaps you sent the wrong message first?

If you read from a object dictionary the Byte0 is 40h for ID 601h and the answer has 42h in Byte0 for ID 581h.

ID 181 to 183 are typically digital data PDO's which are send automatically some times. This depends to the configuration and should be changeable using a SDO.

Attached you will find an example reading the manufacturee name using a SDO.

 

DirkW

Message 8 of 15
(6,440 Views)

Hi Dirk

Thanks so far - I'll have another try as soon as possible.

You mentioned several hex-values (22h = write, 60h = ok, 40h, 42h) - could you tell me where I can find a definition of these values?

Thomas

Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 9 of 15
(6,426 Views)

Hi Dirk

I just tested it the way you described and it worked. In the attached VI you can see the values I wrote and what Data I received. Now - could you tell me how I could read specific objects in an easier way?

As you can see, I sent some kind of request and got an entry from ID 581 in the read Data (I stopped the loop after detecting that). Now  this dataset is from index 2301h, Sub-index 4Ah. Well, I could check the string for ID 581 and read out the index and sub-index, but I wonder if there was an easier way to read this specific data. If so, could you describe it referring to the vi attached or maybe modify it?

Thanks in advance.

Thomas

Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 10 of 15
(6,423 Views)