Last active
March 8, 2016 22:02
-
-
Save sofroniewn/0d257ca144e706ebd392 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var now = require('performance-now') | |
//Require LabJack-nodejs | |
var ljn = require('labjack-nodejs'); | |
//Device object (to control a LabJack device)c | |
var createDeviceObject = ljn.getDevice(); | |
//Device object (to control a LabJack device) | |
var device = new createDeviceObject(); | |
// Open a device | |
device.openSync(); | |
///////////////////////////////////////////////////// | |
// Read an digital input | |
var time = now() | |
var val = device.readSync('DIO0') | |
var diff = now()-time | |
console.log('read DIO0:', val); | |
console.log(' ' + diff.toFixed(3) + ' ms') | |
///////////////////////////////////////////////////// | |
// Read an analog input | |
var time = now() | |
var val = device.readSync('AIN0') | |
var diff = now()-time | |
console.log('read AIN0:', val); | |
console.log(' ' + diff.toFixed(3) + ' ms') | |
///////////////////////////////////////////////////// | |
// Read two digital inputs and two analog inputs | |
var time = now() | |
var val = device.readManySync(['DIO0', 'DIO1', 'AIN0', 'AIN1']) | |
var diff = now()-time | |
console.log('read DIO0:', val[0], 'DIO1:', val[0], 'AIN0:', val[2], 'AIN1:', val[3]); | |
console.log(' ' + diff.toFixed(3) + ' ms') | |
///////////////////////////////////////////////////// | |
// Write a digital input | |
var time = now() | |
var errRes = device.writeSync('DAC0', 1.0); | |
var diff = now()-time | |
console.log('write DAC0:', 1.0); | |
console.log(' ' + diff.toFixed(3) + ' ms') | |
///////////////////////////////////////////////////// | |
// Write a digital output | |
var time = now() | |
var errRes = device.writeSync('DIO0', 1); | |
var diff = now()-time | |
console.log('write DIO0:', 1.0); | |
console.log(' ' + diff.toFixed(3) + ' ms') | |
///////////////////////////////////////////////////// | |
// Write two digital outputs and two analog outputs | |
var time = now() | |
var errRes = device.writeManySync(['DIO0', 'DIO1', 'DAC0', 'DAC1'], [1, 1, 1.0, 1.0]) | |
var diff = now()-time | |
console.log('write DIO0:', 1, 'DIO1:', 1, 'DAC0:', 1.0, 'DAC1:', 1.0); | |
console.log(' ' + diff.toFixed(3) + ' ms') | |
///////////////////////////////////////////////////// | |
// Read and write one digital and analog input and output each | |
var time = now() | |
var val = device.rwManySync(['DIO0', 'DIO1', 'AIN0', 'DAC1'], [0, 1, 0, 1],[1, 1, 1, 1], [null, 1, null, 1.0]) | |
var diff = now()-time | |
console.log('read & write DIO0:', val[0], 'DIO1:', 1, 'AIN0:', val[1], 'DAC1:', 1.0); | |
console.log(' ' + diff.toFixed(3) + ' ms') | |
// Close the device | |
device.closeSync(); |
$ node labjack-timing.js
read DIO0: 1
1.423 ms
read AIN0: 10.122373580932617
4.365 ms
read DIO0: 1 DIO1: 1 AIN0: 10.122373580932617 AIN1: 8.632431030273438
10.048 ms
write DAC0: 1
2.608 ms
write DIO0: 1
1.146 ms
write DIO0: 1 DIO1: 1 DAC0: 1 DAC1: 1
2.084 ms
read & write DIO0: 1 DIO1: 1 AIN0: 7.907456874847412 DAC1: 1
6.109 ms
More information on expected communication rates can be found here https://labjack.com/support/datasheets/t7/appendix-a-1
Inside Kipling software, change analog input resolution index to 1 (at gain/range value or 1/±10V, for a 316uV effective resolution over the whole range) and make settling time 10us to get the analog read time down to 800us for one channel.
$ node labjack-timing.js
read DIO0: 1
1.451 ms
read DIO0: 1 DIO1: 1 DIO2: 1 DIO3: 1
1.914 ms
read AIN0: -10.588912010192871
0.811 ms
read DIO0: 1 DIO1: 1 AIN0: -10.589227676391602 AIN1: -10.588912010192871
1.721 ms
write DAC0: 1
1.561 ms
write DIO0: 1
0.920 ms
write DIO0: 1 DIO1: 1 DIO2: 1 DIO3: 1
1.845 ms
write DIO0: 1 DIO1: 1 DAC0: 1 DAC1: 1
1.454 ms
read & write DIO0: 1 DIO1: 1 AIN0: -10.588912010192871 DAC1: 1
2.301 ms
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Timing measurements for DIO and ADC / DAC for the T7 pro from LabJack using https://www.npmjs.com/package/labjack-nodejs. All communication done over USB