A simple but very effective scope. Up to 6 channels of 32 bit float data at 1 kHz.

Dependencies:   USBDevice

Dependents:   HIDScope TEST Project5-Motorcontrol EMG_HIDScope_Gr6 ... more

You are viewing an older revision! See the latest version

A simple oscilloscope for your device

It is possible to see what is going on in your device live. This step by step instruction will guide you through the process and it will be easy to adjust this setup to your needs.

Step 1, using the HIDScope on your MBED

If there is no project you currently working on, create one first. Now simply import the HIDScope library into your project by clicking on 'Import Library' on the homepage of this library.

Include the HIDScope library in your header

include the HIDScope library

#include "HIDScope.h"

And define the HIDScope beneath your #include-s, outside of any function. The only parameter that it takes is the number of channels you would like to use. In this case we will use one channel.

define the scope

HIDScope    scope(1);

Now set the data and send it over USB! This example reads and sends at 100hz the value of the analog in.

send data at 100hz

#include "mbed.h"
#include "HIDScope.h"

HIDScope    scope(1);
Ticker      scopeTimer;

AnalogIn    a0(p2);

void scopeSend()
{
    scope.set(0,a0.read());
    scope.send();
}

int main()
{
    
    scopeTimer.attach_us(&scopeSend, 1e4);  // send data at 100hz    
    
    while(1)
    {
    }
        
}

If you have a control-loop running at 10kHz you certainly wouldn't want to transfer the data at 10kHz (that isn't even possible using this device). You could SET the data in the 10kHz loop and SEND the data in a 50hz loop. See the following example using 2 channels:

example using a separate send-timer

#include "mbed.h"
#include "HIDScope.h"

HIDScope    scope(2);
Ticker      scopeTimer;
Ticker      controllerTimer;

AnalogIn    a0(p2);
AnalogIn    a1(p3);

void superFast()
{
    scope.set(0,a0.read());
    scope.set(1,a1.read());
}

int main()
{
    
    scopeTimer.attach_us(&scope, &HIDScope::send, 2e4);     // Send data @ 50hz
    controllerTimer.attach_us(&superFast, 1e3);             // Control at 1kHz
    
    while(1)
    {
    }
        
}

Upload it, you are ready! (With your MBED)

Step 2, installing the HID Scope software

The software is compatible with Windows, OSX and Linux.

Installation - Windows

You have to go through 2 installation steps and 1 step to start the scope.

Installation: NodeJS

Go to [NodeJS](http://nodejs.org/) website and click INSTALL follow the instructions

Installation: Get the HID Scope

  • Open the just renamed folder on your desktop and start 'win_install_modules'

Run: Start the HID Scope

  • Open the 'hidscope' folder on your desktop and start 'win_start_scope'

Installation - OSX / Unix

You have to go through 2 installation steps and 1 step to start the scope.

Installation: NodeJS

Go to [NodeJS](http://nodejs.org/) website and click INSTALL follow the instructions

Installation: Get the HID Scope

  • Open ‘terminal’
  • Go to your desktop using the command

cd /Desktop/

  • Clone the HIDScope repository using

git clone https://bitbucket.org/tomlankhorst/hidscope.git

  • Go to the server directory inside the hid scope directory you just cloned

<<code>>cd ./hidscope/server <</code>>

  • Download the required node-modules as super-user

sudo npm install connect ws serve-static node-hid

Run: Start the HID Scope

  • Start the scope by executing the following command in Terminal

node /Desktop/hidscope/server/server.js


All wikipages