CANivore User's Guide - CANivore User's Guide
CANivore User's Guide - CANivore User's Guide
com __ 1/21/2021
CANivore
User’s Guide
Revision 1.0
www.ctr-electronics.com
Table of Contents
1. Device description .....................................................................................................................................................5
1.1. Kit Contents ........................................................................................................................................................5
1.2. Features..............................................................................................................................................................6
1.3. Electrical Specifications ......................................................................................................................................7
1.4. General specifications ........................................................................................................................................7
1.5. LED States...........................................................................................................................................................8
2. Block Diagram ............................................................................................................................................................9
3. CAN FD Bus ................................................................................................................................................................9
3.1. Terminating Resistor ........................................................................................................................................10
4. CANivore Processor .................................................................................................................................................10
5. ESP32 Co-Processor .................................................................................................................................................10
5.1. Serial port .........................................................................................................................................................10
5.2. Wi-Fi .................................................................................................................................................................10
5.3. Bluetooth/BLE ..................................................................................................................................................10
6. Software ..................................................................................................................................................................11
6.1. Latest Documentation......................................................................................................................................11
6.2. Software stack-up.............................................................................................................................................11
6.3. Basic Setup .......................................................................................................................................................12
6.3.1. Basic Tasks – Field-upgrade ......................................................................................................................12
6.3.2. Basic Tasks - Naming the CAN bus ............................................................................................................12
6.3.3. Basic Tasks - Programmable Terminating Resistor ...................................................................................12
6.4. Windows PC .....................................................................................................................................................13
6.4.1. Windows PC - Device Manager .................................................................................................................13
6.4.2. Windows PC - Installation .........................................................................................................................13
6.4.3. Windows PC - Driver Uninstall / Reinstall .................................................................................................14
6.4.4. Windows PC – USB Known Issue...............................................................................................................15
6.5. Linux / SocketCAN ............................................................................................................................................16
6.5.1. Linux / SocketCAN - What is SocketCAN ...................................................................................................16
6.5.2. Linux / SocketCAN – Extensions................................................................................................................17
6.5.3. Linux / SocketCAN – Installation ...............................................................................................................17
6.6. Programming ESP32 .........................................................................................................................................17
6.6.1. ESP32 - Enable/Disable .............................................................................................................................17
6.7. Hardware Attached Simulation ........................................................................................................................18
7. Wiring ......................................................................................................................................................................19
7.1. RoboRIO Wiring ................................................................................................................................................19
7.2. Hardware Attached Simulation Wiring ............................................................................................................20
7.3. Network Topologies .........................................................................................................................................21
8. FAQ ..........................................................................................................................................................................22
8.1. Is there a way to tell if the device is present/powered? ..................................................................................22
8.2 How do I tell CAN is connected? .......................................................................................................................22
8.3 How do I tell CANivore is powered?..................................................................................................................22
8.4 How do I tell CANivore is connected to USB? ...................................................................................................22
8.5 How do I field-upgrade the CANivore?..............................................................................................................22
8.6 What do I need to do to use this in FRC? ..........................................................................................................22
8.7 Do I need to install SocketCAN or USB-drivers on to the RIO to use this? ........................................................22
8.8 What happens if CANivore disconnects and reconnects during a match? .......................................................22
8.9 What happens if a non-FD device is connected to CANivore? ..........................................................................22
8.10 What is the ESP32 for? ....................................................................................................................................22
8.11 How can I program the ESP32? .......................................................................................................................22
8.12 How do I select a device on this CANivore’s bus? ...........................................................................................23
8.13 What is Hardware Attached Simulation? ........................................................................................................23
8.14 Connecting CANivore to my Windows Computer doesn’t show up in Tuner .................................................23
9. Mechanical Drawings...............................................................................................................................................24
10. Revision History .....................................................................................................................................................25
It is our intention to provide our valued customers with the best documentation possible to
ensure successful use of your CTRE products. To this end, we will continue to improve our
publications, examples, and support to better suit your needs.
If you have any questions or comments regarding this document, or any CTRE product, please
contact support@crosstheroadelectronics.com
1. Device description
The CTRE CANivore is a USB to CAN FD adapter, capable of providing a CAN FD network to a Windows PC or a
roboRIO-Linux. Each CANivore will allow you to add an additional CAN bus to the roboRIO and control supported
CTR Electronics devices from your robot project.
1.2. Features
• USB to CAN FD adapter for Windows and roboRIO-Linux for supported CTR-Electronics devices. (Note 1)
• Each CANivore adds an entirely new CANFD network to the roboRIO
• Can be used to control and update devices from a Windows PC
• Integrated ESP32 for wireless capabilities (Wi-Fi/Bluetooth) and programmable control
• Windows PC use case does not require custom USB drivers
• CANivore kernel driver already included into NI roboRIO image.
• Ability to set custom name for each CANivore CAN bus
• Modern USB Type-C connector
• Includes a USB A-to-C cable – perfect for the FIRST roboRIO use case.
• Can be USB powered without requiring additional power wiring
• Can be powered from DC supply or battery (up to 28V) for standalone operation
• Can be powered by both USB and power connector for redundant power supply
• Reverse Input Power Protection
• Supports USB Hub
• Supports Hardware Attached Simulation for FRC C++/Java (FRC Simulation on desktop with actual
hardware)
• Polycarbonate housing prevents debris from entering inside device
• Voltage measurement of V+ and 5V rails
• CAN bus utilization measurement
• Multi-color LEDs for Status, Communication, Wi-Fi, and Bluetooth
• Reliable Weidmuller connector for power and CAN
• Robust bootloader and reliable field-upgrade (no physical button required, no “stuck states” that
requires user intervention)
• Wirelessly check, configure, and field-upgrade CANivore using roboRIO Wi-Fi and Phoenix Tuner.
• Wirelessly check, configure and field-upgrade attached CAN devices using roboRIO Wi-Fi and Phoenix
Tuner.
• Software-selectable termination resistor (120 Ω)
Note 1: A future design goal will be to include support for more common Linux platforms. The focus of the initial release was for FIRST
Robotics, but the CTRE CANivore kernel driver can be ported to other Linux systems.
STAT Red Double-Blink (Note 2) Device powered through V+/V-, but USB not plugged in.
Orange Double-Blink if V+/V- is not powered (Note 2) Good USB connection, CAN streaming is disabled
Green Fast-Strobe if V+/V- is powered (Note 3) Good USB connection, CAN streaming is enabled
TIP: Use this to confirm the V+/V- wiring!
Green / CANivore is in Bootloader.
Orange
Most likely device was unplugged during field-upgrade
(Note 4).
LED is never off – one of the two Use Phoenix Tuner to field upgrade latest CRF firmware
colors is always illuminated. file.
Wi-Fi Green Blink (Note 1) Wi-Fi is enabled or ESP32 custom application is allowed
to use Wi-Fi
Off Wi-Fi is disabled
CAN Solid Red LED is never off. Voltage too low for CAN bus.
(CAN bus) CAN communication may not be reliable
Red Double-Blink if termination is disabled (Note No CAN communication
2)
2. Block Diagram
The diagram below shows the organization of the CANivore peripherals.
3. CAN FD Bus
CAN FD is the next iteration of the CAN bus data link layer. The FD stand for Flexible Data-Rate, meaning that
portions of the frame is transmitted at higher data rates (up to 10Mbps). This means less bus time for more data.
Additionally, a single frame can now hold up to 64 data bytes.
• Lower bus utilizations because of less frame overhead and higher bitrates.
• More devices before hitting maximum bus utilization.
• Less time spent designing how to split signals across multiple frames
• Larger frames mean potential firmware features that were not previously possible with CAN 2.0B.
CANivore automatically configures the CAN bus network to be compliant with CAN FD. As a result, end-users do
not need to configure bit timing information.
Note: The other extreme end must also be terminated with a 120Ω resistor. We recommend soldering a 120Ω
through hole resistor between the CANH (yellow) and CANL (green) wires at the extreme end of the bus.
4. CANivore Processor
At the center of the CANivore is a 120MHz Cortex M4F processor. This dedicated controller implements all USB
and CAN bus related features. This includes:
- Communication with CTR-Electronics CANivore-USB kernel driver
- Field-upgrade and other Phoenix Tuner features
- General configuration of the device (termination resistor, device-name, ESP32 enable/disable, etc.)
5. ESP32 Co-Processor
The CANivore features an ESP32WROOM32D as a co-processor for custom user code.
This processor was chosen because:
- Native support for Wi-Fi and Bluetooth/BLE
- Popularity in the embedded systems and hobbyist community
- Increases the maximum potential long-term feature-set of the CANivore
The ESP32 is not necessary when using CANivore to add additional CAN buses for supported Phoenix devices, as
this is implemented by the CANivore core processor. However, the shared data bus between CANivore processor
and ESP32 allows for the potential to provide CAN bus features to customer user applications.
After the initial 2022 release of the product, examples will be posted for sending arbitrary CAN frames. Moving
forward, CTR-Electronics will be investing in the development of advanced ESP32-based features. As features are
added, more examples and documentation will be posted accordingly.
5.2. Wi-Fi
Wi-Fi (2.4 GHz) is integrated into the ESP32. The latest documentation can be found under the ESP32WROOM32D
resources provided by espressif.com.
5.3. Bluetooth/BLE
Bluetooth/BLE is integrated into the ESP32. The latest documentation can be found under the ESP32WROOM32D
resources provided by espressif.com.
6. Software
Although this user’s guide primarily covers hardware-related aspects to the CANivore, outlining the software
interactions may be useful when first becoming familiar with the device.
Software-developers are encouraged to review the software documentation for the latest information, particularly
the “Phoenix Framework Documentation” section. However general software guidance is also provided below.
Note 1: The Diagnostic Server Address is specified in the “Robot Controller Install” tab of Phoenix Tuner.
Note 2: caniv is a command line tool in the roboRIO-Linux system.
See https://ctr-electronics.com/documentation for the latest information, particularly the “Phoenix Framework
Documentation” section.
This also allows developers to identify what devices are on what CAN bus.
CANivore supports custom names up to 32 standard ASCII characters.
Naming the CANivore can be done through the CTRE provided caniv tool or through Phoenix Tuner.
Termination mode can be confirmed in Phoenix Tuner and via the COMM LED.
Note: Measuring the termination resistance via ohmmeter is not possible when CAN bus is active. A software
button may be added in the future to allow for measuring resistance if the need arises.
6.4. Windows PC
CANivore communication is done in a driver-less fashion. Meaning any modern Windows PC will enumerate the
CANivore, and report it as successfully connected in device manager.
Note: It is generally required that only one application can connect to a CANivore in Windows. However, when
desktop-simulating an FRC application, Phoenix Tuner still functions if the Diagnostic Server Address is set to
“localhost”. This allows for simultaneous use of Phoenix API (in the desktop robot application) and Phoenix Tuner
(diagnostics).
3. Navigate to your CANivore and right-click->Properties on the USB Composite Device that is under it. If you
have not renamed the CANivore, it will show as “CANivore Default Name”, otherwise it will be named
“CANivore <custom name>”.
3. Navigate to your CANivore and right-click->Properties on the USB Composite Device that is under it. If you
have not renamed the CANivore, it will show as “CANivore Default Name”, otherwise it will be named
“CANivore <custom name>”.
4. Navigate to “Driver” and click “Uninstall Device”. This will uninstall all the CANivore drivers from the
computer so that the next time CANivore is plugged in, it cleanly gets the new drivers.
These conditions typically cannot be reproduced by the end-user and are only known because of validation-testing
done by the CTR-Electronics team.
However, while supporting our industrial customers with SocketCAN, the list of problems we’ve encountered with
existing USB-to-CAN hardware solutions grew to such a degree that developing the CANivore became the only
solution to ensure a quality experience, in industry and in FIRST Robotics.
For robust operation in the FIRST use-case, the following extensions were implemented:
- CAN bit timings set via SocketCAN are not honored. CANivore will determine the correct bit timings
independently, ensuring they cannot be set incorrectly.
- CTR-Electronics kernel driver is part of the NI FRC 2022 image. If mid-season updates are necessary, they
will be installed via Phoenix Tuner.
- Console features such as candump are functional, however they can consume substantial CPU when printing
to the shell.
- Users should not “bring-up” CANivore networks via shell commands (“ifconfig” for example) or startup
scripts. Phoenix API library will do this for you. If you manually “ifconfig down” a CANivore bus, Phoenix API
will not re-initialize it for you.
- CANivore is rigorously tested with CTR-Electronics supported devices only. Use cases outside of this were not
considered for the initial 2022 release of this device.
- Phoenix API requires user to specify the CAN bus name when creating a software object for supported
devices like Falcon 500 or CANcoder. Developers may also use the socket CAN names such as “can0”, but
these may not be reliable when using more than one SocketCAN bus as the number-suffix may change with
each robot cold-boot. It is recommended to use the CANivore custom name instead.
Examples and documentation for programming the ESP32 will be provided in future updates.
Note: When using ESP32 software tools (Espressif IDF for example), CANivore will conveniently boot the ESP32
automatically. But if the persistent setting is still set to disable (as seen in Phoenix Tuner), ESP32 will not boot on
the next power cycle.
When the CANivore is directly connected to Windows PC (Note 1) via USB, there is opportunity to run with true
hardware, while still having the benefits of local testing and debugging on the host PC. This is referred to as
“Hardware Attached Simulation”.
Note 1: Supporting Linux desktop in future is possible. The CANivore USB kernel driver must be ported to Linux-x86-64.
7. Wiring
The CANivore provides its own separate CAN FD bus. This means the CANivore should only be connected to the
host via the USB cable, and not through another CAN connection. Power can be supplied to the CANivore through
USB, or optionally through the V+ and V- Weidmuller ports. CAN is connected to CANH and CANL Weidmuller ports,
with yellow to CANH and green to CANL.
In the past with CAN 2.0, teams with very short CAN buses may have been able to get some degree of success
without ensuring the above requirements are met, such as with star or ring topologies. However, as transmission
frequencies increase (such as in CAN FD), it is more important to ensure proper bus topology (daisy chain or short
stub lengths).
This is the reason CTR-Electronics incorporates true daisy-chaining (Note 2) in all modern CAN bus products.
Note 1: CANivore can act as one of the terminating resistors with its software-selectable terminating resistor.
Note 2: True daisy chaining means bridging the CANH and CANL lines within the product, and not inside a connector (critical failure point) or
inside of breakout far away from the devices.
8. FAQ
8.1. Is there a way to tell if the device is present/powered?
To determine visually if the device is powered and functioning, check the built-in LED, see Section 1.5. LED States.
If COMM LED is red, recheck all cabling in between CANivore connector and USB root hub (host controller).
If using a USB hub, rule it out by removing it and re-testing.
In the unlikely event that Windows failed to enumerate the CANivore correctly, a workaround is provided in
Section 6.4.4.
9. Mechanical Drawings