Code Monkey home page Code Monkey logo

mywrio's Introduction

myWRIO

C++ API for National Instruments myRIO

This is a framework to use with myRIO. It allows the user to code on the myRIO without LabVIEW. It is based on the official C API, but handles registers communications to provide a high level, arduino like programming.

Documentation found here

The docs are generated with Doxygen. Each line of code is documented and examples are provided for each class. There is a guide to setup Eclipse to use our API.

  • Blink a LED
#include "MyRIO.h"
using namespace myRIO;
int main() {
    if(!myRIO_init()) {std::cout << "Error initializing myRIO"; return -1;}
  
    bool status = HIGH;
  
    while(1) {
        status=!status
        DIO::writeLed(LED1, status);
        Time::wait_ms(500);
    }
}
  • Output a PWM signal
#include "MyRIO.h"
using namespace myRIO;
using namespace std;
int main() {
    if(!myRIO_init()) {cout << "Error initializing myRIO"; return -1;}
    // Output a 10kHz, 3.3V PWM signal with a duty cycle of 25% for 10 seconds
    PWM channelC0(PWMC0, 10e3, 25);
    Time::wait_s(10);
}
  • Generate a sine with AIO class (Analog Input Output)
#include "MyRIO.h"
using namespace myRIO;
using namespace std;
int main() {
    if(!myRIO_init()) {cout << "Error initializing myRIO"; return -1;}
    double fq = 100;
    double vpp = 4;
    double outputFq = 100e3;
    Time timer = Time::stopwatch();
    timer.reset();
    while(1) {
        AIO::writePin(CO0, (vpp/2)*sin(2*3.141592653*fq*timer.elapsed_ns()*1e-9));
        // we cannot measure more than 2 seconds ; reset it before it's too late
        if(timer.elapsed_ns() >= 1e9L)
            timer.reset();
        // convert the frequency to time, then the time to µs
        Time::wait_us(1e6/outputFq);
    }
    return 0;
}
LEDs example MotorPID example Real time angle supervision (external I2C gyroscope) And a car
Youtube video 2 Youtube video 2 Youtube video 2 Youtube video 2

mywrio's People

Contributors

eviallet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

mywrio's Issues

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.