GithubHelp home page GithubHelp logo

cc100-canbus's Introduction

cc100-canbus

This repository contains a Node-RED module with nodes to initialize the CAN interface on a CC100 and send CANOpen NMT protocols.

Compatibility

This Node-RED package works with alpine based docker containers using the apk package manager.
It has been tested the following docker images:

Usage

To use the CAN interface of the cc100 the flag --network=host has to be used in the docker run command, which makes the port forwarding obsolete.

docker run -d \
--name node-red \
--restart always \
--privileged=true \
--user=root \
--network=host \
-v node_red_user_data:/data \
nodered/node-red

To install the module in Node-RED use the palette or npm i @wago-gmbh/cc100-canbus.

Nodes

All nodes use the interface can0 as default. To use a different interface change the name of the interface in the node properties.

canbus-initalize

Initializes the CAN interface on the device with the given bitrate.

Input: Bitrate of the can network as integer
Output: Command executed by the node as string

canbus-opperational

Forces the addressed device to transit to the opertaional state. Flow has to be deployed after each initialization of the CAN interface.

Input: Address of the device to be addressed as integer.

canbus-stopped

Forces the addressed device to transit to the stopped state. Flow has to be deployed after each initialization of the CAN interface.

Input: Address of the device to be addressed as integer.

canbus-pre-opperational

Forces the addressed device to transit to the pre-opertaional state. Flow has to be deployed after each initialization of the CAN interface.

Input: Address of the device to be addressed as integer.

canbus-reset

Forces the addressed device to transit to reset. Flow has to be deployed after each initialization of the CAN interface.

Input: Address of the device to be addressed as integer.

canbus-reset-communication

Forces the addressed device to transit to reset communications. Flow has to be deployed after each initialization of the CAN interface.

Input: Address of the device to be addressed as integer.

To address all devices on a network instead of a specific device use 0 as address.

CAN communictaion

The CAN interface needs to be initialized, before the other nodes are deployed.
When the CAN interfaced is initialized again after a reboot of the device, the flow has to be deployed again.
The can-initialize node can only be used once to set up the CAN interface. To change the bitrate the device has to be rebooted.

For recieving and sending CAN messages node-red-contrib-socketcan can be used. The name of the interface on the cc100 ist can0. The enabling of the interface is done by the canbus-initialize node.

Node-RED flow

An example flow using 500000 as a bitrate and addressing device 10 with the NMT commands.

[
    {
        "id": "f6f2187d.f17ca8",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "58540408bfda88c1",
        "type": "canbus-initialize",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "interface": "can0",
        "x": 380,
        "y": 100,
        "wires": [
            [
                "c426c59f83e55fbc"
            ]
        ]
    },
    {
        "id": "5c4fdeb911b1908c",
        "type": "inject",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "500000",
        "payloadType": "num",
        "x": 170,
        "y": 100,
        "wires": [
            [
                "58540408bfda88c1"
            ]
        ]
    },
    {
        "id": "c426c59f83e55fbc",
        "type": "debug",
        "z": "f6f2187d.f17ca8",
        "name": "debug 1",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 600,
        "y": 100,
        "wires": []
    },
    {
        "id": "d69aa36bf15f1ffe",
        "type": "canbus-pre-opperational",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "interface": "can0",
        "x": 410,
        "y": 220,
        "wires": []
    },
    {
        "id": "36dd2a984bed6bd6",
        "type": "inject",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "10",
        "payloadType": "num",
        "x": 170,
        "y": 220,
        "wires": [
            [
                "d69aa36bf15f1ffe"
            ]
        ]
    },
    {
        "id": "b193cb290857ddc4",
        "type": "canbus-opperational",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "interface": "can0",
        "x": 400,
        "y": 160,
        "wires": []
    },
    {
        "id": "35384ffb4ce24eae",
        "type": "inject",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "10",
        "payloadType": "num",
        "x": 170,
        "y": 160,
        "wires": [
            [
                "b193cb290857ddc4"
            ]
        ]
    },
    {
        "id": "d9f1b5aa4e5e1add",
        "type": "canbus-stopped",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "interface": "can0",
        "x": 380,
        "y": 280,
        "wires": []
    },
    {
        "id": "8e539c1d7089b6a0",
        "type": "canbus-reset",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "interface": "can0",
        "x": 370,
        "y": 340,
        "wires": []
    },
    {
        "id": "b8917ce1338684c3",
        "type": "canbus-reset-commmunications",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "interface": "can0",
        "x": 430,
        "y": 400,
        "wires": []
    },
    {
        "id": "0a3a052a9978e769",
        "type": "inject",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "10",
        "payloadType": "num",
        "x": 170,
        "y": 280,
        "wires": [
            [
                "d9f1b5aa4e5e1add"
            ]
        ]
    },
    {
        "id": "3a33c7577deda244",
        "type": "inject",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "10",
        "payloadType": "num",
        "x": 170,
        "y": 340,
        "wires": [
            [
                "8e539c1d7089b6a0"
            ]
        ]
    },
    {
        "id": "dc3bf31a92bda73a",
        "type": "inject",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "10",
        "payloadType": "num",
        "x": 170,
        "y": 400,
        "wires": [
            [
                "b8917ce1338684c3"
            ]
        ]
    }
]

cc100-canbus's People

Contributors

konhol avatar

Watchers

dirk.meihoefer@wago.com avatar Sergei Ikkert avatar Helmut Saal avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.