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

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.

This step by step instruction will guide you through the process and it will be easy to adjust this setup to your needs.

The newest MBED library has some issues with USB devices. For the time being, select MBED library revision 119.

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.

The simple way, send data at 100hz

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

// Define the HIDScope and Ticker object
HIDScope    scope(1);
Ticker      scopeTimer;

// Read the analog input
AnalogIn    a0(p2);

// The data read and send function
void scopeSend()
{
    scope.set(0,a0.read());
    scope.send();
}

int main()
{
    // Attach the data read and send function at 100 Hz
    scopeTimer.attach_us(&scopeSend, 1e4);   
    
    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:

The better way, separate send and control loop

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

// Define the HIDScope and Ticker objects
HIDScope    scope(2);
Ticker      scopeTimer;
Ticker      controllerTimer;

// Two analog inputs to read from
AnalogIn    a0(p2);
AnalogIn    a1(p3);

void controlAndMeasure()
{
    // Do some control
    // ** control code here **

    // Store values in the scope
    scope.set(0,a0.read());
    scope.set(1,a1.read());
}

int main()
{
    // Attach the HIDScope::send method from the scope object to the timer at 50Hz
    scopeTimer.attach_us(&scope, &HIDScope::send, 2e4); 

    // Attach the controlAndMeasure method to the controller timer at 1kHz
    controllerTimer.attach_us(&controlAndMeasure, 1e3);
    
    while(1) { }
        
}

Upload it and you are ready to go!

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.

Quick Start

Alternative: Run from source

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

History

Update dependencies default tip

2017-07-30, by tomlankhorst [Sun, 30 Jul 2017 17:39:31 +0000] rev 7

Update dependencies


Added MBED library check

2016-10-06, by tomlankhorst [Thu, 06 Oct 2016 13:00:13 +0000] rev 6

Added MBED library check


USBDevice 1 revision back

2016-10-06, by tomlankhorst [Thu, 06 Oct 2016 12:54:02 +0000] rev 5

USBDevice 1 revision back


Updated USBDevice lib to most recent version

2016-09-22, by tomlankhorst [Thu, 22 Sep 2016 08:00:52 +0000] rev 4

Updated USBDevice lib to most recent version


Updated USBDevice dependency

2015-05-20, by tomlankhorst [Wed, 20 May 2015 10:10:10 +0000] rev 3

Updated USBDevice dependency


Updated documentation

2015-05-20, by tomlankhorst [Wed, 20 May 2015 09:32:40 +0000] rev 2

Updated documentation


Updated documentation

2014-09-08, by tomlankhorst [Mon, 08 Sep 2014 09:38:36 +0000] rev 1

Updated documentation


Initial version (v0.1)

2014-09-08, by tomlankhorst [Mon, 08 Sep 2014 09:26:53 +0000] rev 0

Initial version (v0.1)