Fixed device ID/channel assignment with PCAN-USB

This forum covers issues concerning multiple hardware products.
Locked
G.Lang
Support
Support
Posts: 139
Joined: Wed 22. Sep 2010, 14:58

Fixed device ID/channel assignment with PCAN-USB

Post by G.Lang » Fri 3. Jun 2011, 10:02

When using multiple PCAN-USB adapters together with PCAN-Basic on the same machine it is possible to connect a certain device ID with a hardware handle so that access to a specific unit is independent from the sequence these adapters are plugged into the USB ports. The following steps must be taken to accomplish that:

Each PCAN-USB-Hardware (PCAN-USB, PCAN-USB ISO, PCAN-USB Pro, PCAN-HUB) has a DeviceID (by default this is FFh). This DeviceID can be changed using the current version of PCAN-View (see screenshot below).
set_device_id_with_pcan_view.jpg
set_device_id_with_pcan_view.jpg (41.22 KiB) Viewed 25047 times
Make sure that you assign unique IDs for each of the adapters connected to the same machine, don't duplicate the same device ID because then this entire process will not work.

After changing the DeviceID a few values must be added/created in the Registry.
Here is a small example using 3 USB adapters with the following DeviceIDs:

1. USB-Adapter = 0x01h
2. USB-Adapter = 0x02h
3. USB-Adapter = 0x05h

The following keys must be created:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\pcan_usb]
"Hardware16"="0x201,0x01,0"
"Hardware15"="0x201,0x02,0"
"Hardware14"="0x201,0x05,0"
set_hardwarehandle.jpg
set_hardwarehandle.jpg (118.31 KiB) Viewed 25047 times
Description of Parameter 1:
Hardware16 = HardwareHandle16
Hardware15 = HardwareHandle15
.....
Hardware8 = HardwareHandle8
.....
Hardware1 = HardwareHandle1
 
Description of Parameter 2:
0x201 = PCAN-USB and PCAN-USB ISO
0x202 = PCAN-USB Pro
0x203 = PCAN-USB HUB
0x206 = PCAN-USB Pro FD
0x207 = PCAN-USB FD
 
Description of Parameter 3:
the corresponding (selected) DeviceID
0x00 = don´t care
0x01 through 0xff
In our little example we must use 0x01, 0x02 and 0x05

Description of Parameter 4 (only applicable for USB-PRO, because there we can have 1 DeviceID with 2 CANchannels per device):
0 = Channel 1
1 = Channel 2
 
When using PnP (Plug&Play) devices the hardware handle is usually assigned starting at 16 and then counting down.
This means the first USB-Adapter will get Hardware-Handle16, the second adapter gets HardwareHandle15, the third Adapter HardwareHandle14 etc.
With PCAN-Basic the application that is started first uses Handle "PCAN_USBBUS1" = 0x51, the application that is started next will use Handle "PCAN_USBBUS2" = 0x52 etc..
This results in the following assignment scheme:
HardwareHandle 16 -> PCAN_USBBUS1 0x51
HardwareHandle 15 -> PCAN_USBBUS2 0x52
HardwareHandle 14 -> PCAN_USBBUS3 0x53
The application that is started first will always connect to the adapter with ID01h, the second application connects to the adapter with ID02h and the third application connects to the adapter with ID05h.

PS: Thanks to René from Phytec America :D

sunbo_ll
Posts: 4
Joined: Wed 18. Jan 2017, 11:05

Re: Fixed device ID/channel assignment with PCAN-USB

Post by sunbo_ll » Wed 18. Jan 2017, 11:42

I'm using PCAN-USB light API and have 2 dll-files: PCAN_USB.dll for adapter1 and PCAN_2USB.dll for adpater2. Adapter1 has device id 0x1 and adapter2 has 0x2. The keys are also inserted into the windows registry (Hardware16='0x201,0x1,0' and Hardware15='0x201,0x2,0'). I hope that adapter1 is in use if the PCAN_USB.dll is called and adapter2 is in use if PCAN_2USB.dll is called. But it seems that it does not work. What's wrong?
Softwareentwicklung, OOD/OOP, C/C++, Delphi, Java, QT
Modellierung, Simulation, Datenvisualisierung, Testautomatisierung

User avatar
U.Wilhelm
Sales & Support
Sales & Support
Posts: 1130
Joined: Fri 10. Sep 2010, 19:34

Re: Fixed device ID/channel assignment with PCAN-USB

Post by U.Wilhelm » Wed 18. Jan 2017, 15:26

The PCAN-Light DLL use the same enumaration as the PCAN-Basic API. You only did not see the used Handles.

Here they are:

Light DLL
pcan_usb.dll --> 0x51
pcan_2usb.dll --> 0x52

pcan_pci.dll --> 0x41
pcan_2pci.dll --> 0x42

etc. see Header File of PCAN Basic API
--------------------------------
PEAK-System Technik
Technical Support Team
support@peak-system.com
-------------------------------

G.Lang
Support
Support
Posts: 139
Joined: Wed 22. Sep 2010, 14:58

Re: Fixed device ID/channel assignment with PCAN-USB

Post by G.Lang » Tue 31. Jul 2018, 15:07

Updated list for parameter 2 (CAN_GetDriverName)

PCI and PCIexpress based cards

0x101 = PCAN-PCI

0x101 = PCAN-PCI Express (the Tundra powered version, sold till ~2014)
0x103 = PCAN-PCI Express (current version)
0x113 = PCAN-PCI Express FD

0x101 = PCAN-PC/104-Express (the Tundra powered version, sold till ~2014)
0x107 = PCAN-PC/104-Express (current version)
0x117 = PCAN-PC/104-Express FD

0x101 = PCAN-PC/104-Plus
0x106 = PCAN-PC/104-Plus Quad (4-channel version)

0x101 = PCAN-cPCI

0x101 = PCAN-miniPCI
0x108 = PCAN-miniPCIe
0x118 = PCAN-miniPCIe FD

0x102 = PCAN-ExpressCard
0x10A = PCAN-ExpressCard 34

0x109 = PCAN-Chip PCIe
0x119 = PCAN-Chip PCIe FD

0x11A = PCAN-M.2


USB based interfaces

0x201 = PCAN-USB
0x201 = PCAN-USB ISO
0x207 = PCAN-USB FD

0x202 = PCAN-USB Pro
0x206 = PCAN-USB Pro FD

0x201 = PCAN-USB Hub

0x209 = PCAN-USB X6

0x208 = PCAN-Chip USB


PC Card based cards

0x401 = PCAN-PC Card

Locked