Giter VIP home page Giter VIP logo

vescnet's Introduction

VescNET

This library can be used to communicate .NET applications to VESC drivers using usb/serial port.

This project is based on vedderb/bldc_uart_comm_stm32f4_discovery repository.

Table of contents

Features

  • Read VESC firmware information
  • Get values from VESC
  • Read/Set VESC motor parameters
  • Read/Set VESC app parameters
  • Set Duty Cycle
  • Set Current
  • Set Current Brake
  • Set RPM
  • Set Position
  • Set Handbrake Current
  • Set Servo Position
  • Request Encoder Detection
  • Terminal Commands

Usage

Build bldc instance

var buffer = new VescNET.Infra.Buffer();
var packetProcess = new PacketProcess();
var packet = new Packet(buffer, packetProcess);
var serial = new SerialPort();
var comm = new BldcSerial(packet, serial);
var bldc = new Bldc(buffer, comm);

Register communication events

comm.ConnectionChanged += BldcComm_ConnectionChanged;
comm.OnData += BldcComm_OnData;

Handle connection changed event

private void BldcComm_ConnectionChanged(object sender, bool connected)
{
  if (connected)
  {
    Console.log("VESC connected");
  }
  else
  {
    Console.log("VESC disconnected");
  }
}

Handle data event:

private void BldcComm_OnData(object sender, VescNET.Domain.DTOs.ReceivedData e)
{
  switch (e.PacketId)
  {
    case CommPacketId.FwVersion:
    case CommPacketId.GetValues:
    case CommPacketId.DetectEncoder:
      Console.log(PacketProcess.PrintData(e));
      break;
    case CommPacketId.GetMcConf:
    {
      Console.log("McConf received");
      var mcConf = e.Data as McConfiguration;
      // handle mcConf
      break;
    }
    case CommPacketId.GetAppConf:
    {
      Console.log("AppConf received");
      var appConf = e.Data as AppConfiguration;
      // handle appConf
      break;
    }
    case CommPacketId.SetMcConf:
      Console.log("Mcconf sended to VESC");
      bldc.GetMcconf();
      break;
    case CommPacketId.SetAppConf:
      Console.log("Appconf sended to VESC");
      bldc.GetAppconf();
      break;
  }
}

vescnet's People

Contributors

wjsan avatar

Watchers

 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.