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

Homepage

The HID Scope comes in handy for debugging purposes. You can easily specify which values you want to monitor, whether it are Analog inputs, filtering floats or boolean states. Please refer to this bitbucket repository for the PC scope application: https://bitbucket.org/tomlankhorst/hidscope

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.

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)

Using the HID Scope software

The software is written in Python and currently compatible with Windows. A deprecated NodeJS version exists that is compatible with OSX and Unix but it is not supported anymore.

Usage- Windows

Alternative - Run from source

Alternatively the program can be run from source - Download Python 2.7 - Clone the repo - Run python server.py


All wikipages