Skip to content

About

Hardware-agnostic C++20 CANopen (CiA 301/402) client for controlling HardFOC Vortex motor controllers over CAN. Part of the HardFOC ecosystem.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Vortex Driver

A C++20 CANopen host client for HardFOC Vortex devices: NMT commands and expedited SDO writes with named CiA 301 and CiA 402 objects, over a CAN transport you provide.

Host generic test Docs License: GPL-3.0

Documentation: https://hardfoc.github.io/hf-vortex-driver/

Layer diagram: the application calls VortexHostSession, which encodes NMT and expedited SDO frames
    and passes them to the VortexCanTransport interface, which your transport implements with BaseCan,
    SocketCAN or a loopback, which sends them on the CAN bus to the Vortex device.

In 30 seconds

Implement VortexCanTransport::send() for your CAN driver (Porting), then:

#include "vortex/VortexHostSession.hpp"
#include "vortex/VortexProtocol.hpp"

using namespace hf::vortex;

// Put node 5 in Operational and select CiA 402 profile velocity mode (3).
bool start_node_in_velocity_mode(VortexCanTransport& bus) {
    VortexHostSession session(bus);
    constexpr std::uint8_t kNode = 5;

    if (!session.sendNmt(NmtCommand::Start, kNode)) {               // 0x000: 01 05
        return false;                                               // transport refused the frame
    }
    return session.sdoDownloadExpedited(kNode, kIdxModesOfOperation, // 0x605: 2F 60 60 00 03
                                        /*sub=*/0, /*value=*/3, /*size=*/1);
}

What it does

  • sendNmt(): Start, Stop, Pre-operational, Reset node, Reset communication, to one node or all.
  • sdoDownloadExpedited(): writes 1, 2 or 4 bytes to any object, with the CiA 301 command specifier.
  • Named objects: controlword, statusword, modes of operation, actual position and velocity, error register, a HardFOC vendor range.
  • One virtual method to port; a BaseCan adapter is ten lines.
  • No heap, no threads, no RTOS; transmit only (read responses with hf-utils-canopen or CANopenNode).

Install

git submodule add https://github.com/hardfoc/hf-vortex-driver.git external/hf-vortex-driver
add_subdirectory(external/hf-vortex-driver)
target_link_libraries(my_app PRIVATE hf_vortex_driver)

Documentation

Quickstart Wire the bus, write the transport, start a node
Hardware Bus settings, COB-IDs, frame bytes, objects
API guide NMT, SDO, the CiA 402 state machine
Porting The transport contract and a BaseCan adapter
API reference Doxygen

Tests

cmake -B build -S . -DHF_VORTEX_BUILD_DOC_SNIPPETS=ON && cmake --build build && ctest --test-dir build

License

GPL-3.0; see LICENSE.

About

Hardware-agnostic C++20 CANopen (CiA 301/402) client for controlling HardFOC Vortex motor controllers over CAN. Part of the HardFOC ecosystem.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages