Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

CAN USB Interface with VB6 example problem

Hello all

I'm having a problem which is VERY similar to a post that was posted here before in this link:

http://forums.ni.com/t5/Automotive-and-Embedded-Networks/Visual-basic-6-0-with-PCI-CAN-series-2/m-p/...

 

the problem is that the question is about the PCI-CAN interface and mine is about the USB-8473 CAN-USB interface.

 

I'm trying to operate the CAN-USB connection with a Simex controller from Acutronic. the commands are very similar to the commands that are posted as a link on the above post.

Im trying to operate the "Transmit Receive same port" VB code that came with the NI-CAN software. As posted on the link above the Data which is sent to the CAN interface comes in the code as:

 

Transmit.Data(0) = &H0
Transmit.Data(1) = &H1
Transmit.Data(2) = &H2
Transmit.Data(3) = &H3
Transmit.Data(4) = &H4
Transmit.Data(5) = &H5
Transmit.Data(6) = &H6
Transmit.Data(7) = &H7

 

which I change to the needed command (one of many...):

 

Transmit.Data(0) = &H40
Transmit.Data(1) = &H41
Transmit.Data(2) = &H60
Transmit.Data(3) = &H0
Transmit.Data(4) = &H0
Transmit.Data(5) = &H0
Transmit.Data(6) = &H0
Transmit.Data(7) = &H0

 

I receive No replay in the Data text box.

 

As the original post (again...) I do receive the initial bit from the CAN bus indicating that communication is OK.

I checked the COB ID and the value is 601.

All other parameters are good as well.

 

When operating the Lab view application (which is similar to the VB application) "Transmit receive same port". everything works fine: all commands are sent and received as they should.

 

Additional data:

the OS is XP

the CAN-Bus software is NI-CAN 2.6.3

the USB interface is USB-8473

 

Any help or leads will be welcomed!!

 

Thanks,

Shilo

 

 

0 Kudos
Message 1 of 5
(9,384 Views)

Got it!!!

 

To all that will try to use the VB6 application:

 

In the LabView examples the COB ID default is in hex, and in the VB examples the COB ID default is dec !!! The GUI of the 2 examples (VB & LabView) is exactly the same but it will not work unless you use the correct COB-ID.

 

So, for example, if you want to use the labview example and you want to enter the ID 601: you Enter 601 in the ID text box.

However, if you want to use the VB6 example with the same ID you need to insert 1537 (=601 hex!!)

 

I hope that with this post I will save some people the 3 days that it took me to find this!

 

Shilo

0 Kudos
Message 2 of 5
(9,365 Views)

Hi S_Badichi and everyone,

 

I reply to this topic with the hope that you can help me with this.

I need to use VB6 to communicate with "NI PCI-CAN 2 series 2" to transmit and receive signal from a CAN bus.

 

The tasks are:

1. Using ID 0xFFE0 send the following message to CAN line: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02

2. Verify CAN line is sending CAN messages every 50ms with content 0x00, 0x00, 0x03, 0x30, 0x00, 0x00, 0x0F, 0x00

 

Could you tell me how to do with VB6?

 

Thanks,

0 Kudos
Message 3 of 5
(9,084 Views)

Hello

I would first look for examples on the software that came with your hardware. helped me alot.

secondly, when you have a code and you want to see if it does something, use the Spy from NI that tells you everything that hapens on your bus, to see if you are comunicating with the CAN bus.

 

Shilo

0 Kudos
Message 4 of 5
(9,078 Views)

Thank you Shilo for the reply.

 

The device I want to connect to is a control board, it has CAN chanel. Uer can command the board to do something by sending data to CAN bus.

When I connect CANL and CANH to board and use Spy I don't see any signal from CAN bus, I believe the board is working and sending signal. So there may be something wrong with the wiring connection !!!

 

Now I want to check sending and receiving between 2 CAN port (CAN0 and CAN1) by using VB sample files "Single Sample Input" and "Single Sample Output"

One program send data out from one CAN0 port and the other receive data from CAN1.

The wire connection I use as follow:

Connect pin CAN_L from CAN0 to CAN_L on CAN1

Connect pin CAN_H from CAN0 to CAN_H on CAN1

Connect a resistor 124 Ohm across 2 CAN lines.

 

Attached is the sample VB6 files from the NI folder.

When I try to send and receive data, the received data is often different with the sent, for example when send a value 22 at Chanel 0, on the other window I can get value 21.98 or something different.

 

Could you tell me what is wrong and how to correct it.

And how to customize VB6 program to do what I mentioned in previous post?

 

Thanks.

0 Kudos
Message 5 of 5
(9,068 Views)