Difference between revisions of "BalanceBoard Lab"

From TSG Doc
Jump to navigation Jump to search
Line 103: Line 103:
== Python software ==
== Python software ==
from PyDAQmx import Task
from PyDAQmx import Task
from PyDAQmx.DAQmxConstants import *
from PyDAQmx.DAQmxConstants import *
Line 159: Line 159:

Revision as of 16:13, 26 March 2015

Balance board

Image: 300 pixels


A balance board(force platform) is commonly used in motor control labs and neurologic clinics. They essentially consist of a set of finely calibrated scales, measuring mechanical forces. The pattern of forces can be used to derive body position, at a high spatial and temporal resolution.


There are several boards specified up to 1M2 and 0,5M2 with a sub-millimeter spatial resolution and a 200 hz temporal resolution.

A typical balance board records at a high spatial and temporal resolution. Regarding spatial resolution: a platform can detect changes from a few sub-millimeters (freezing) to at least 500 centimeter (forward or backward steps). The platform records reliably over four vertical forces. Regarding temporal resolution: the signals are typically sampled at 200 Hz. Even though the system allows even higher sampling rates, in practice 100 Hz is sufficient.

The pressure sensors derive directly from the wii balance board. Each sensor has a maximum pressure of 120Kg. In-house electronics is build to get a clean amplification from the sensors. A National instruments card, USB-6221, takes care of the A/D conversion and connects with usb to a pc. The force plate can be integrated into existing systems for stimulus presentation and for recording bodily signals such as EEG, EMG and heart rate. In practice, this means that the systems are time-locked within millisecond accuracy.


Find the BalanceboardCalibration manual here Media:SOP_1_BalanceboardCalibration.pdf

Find the BalanceBoardBaseline manual here Media:SOP_2_BalanceBoardBaseline.pdf

Find the InstructionPosture manual here Media:SOP_3_InstructionPosture.pdf

Technical design

Image: 600 pixels

Find the national instruments specifications manual here Media:NI_USB-6221.pdf

National instruments settings

Image: 600 pixels

Presentation software

sub runtrials_national begin

	# The dio_device will setup NI-DAQmx device number 1 "Dev1"
	dio_device card = new dio_device(ni_dio_device, 1, 0 );
	#int id = card.acquire_analog_input( "MyVoltageOutTask" );
	int id1 = card.acquire_analog_input( "ForceMeasurement,Voltage_0" );
	int id2 = card.acquire_analog_input( "ForceMeasurement,Voltage_1" );
	int id3 = card.acquire_analog_input( "ForceMeasurement,Voltage_2" );
	int id4 = card.acquire_analog_input( "ForceMeasurement,Voltage_3" );
	count_old = response_manager.total_response_count();
	until false
		if response_manager.total_response_count() > count_old then
			count_old = response_manager.total_response_count();
			calibrate_board = true;
		message_scale[1] = round(round(card.read_analog( id1, 1000.0 ),6) * 1000.0, 0);
		message_scale[2] = round(round(card.read_analog( id2, 1000.0 ),6) * 1000.0, 0);
		message_scale[3] = round(round(card.read_analog( id3, 1000.0 ),6) * 1000.0, 0);
		message_scale[4] = round(round(card.read_analog( id4, 1000.0 ),6) * 1000.0, 0);
		if calibrate_board then
			zero_scale_left_up    = message_scale[left_up];
			zero_scale_left_down  = message_scale[left_down];
			zero_scale_right_up   = message_scale[right_up];
			zero_scale_right_down = message_scale[right_down];
			calibrate_board = false;
message_scale[left_up]    = message_scale[left_up] - zero_scale_left_up;
		message_scale[left_down]  = message_scale[left_down] - zero_scale_left_down;
		message_scale[right_up]   = message_scale[right_up] - zero_scale_right_up;
		message_scale[right_down] = message_scale[right_down] - zero_scale_right_down;
		pos_dot_x = (message_scale[right_up] + message_scale[right_down]) - message_scale[left_up] + message_scale[left_down]);
		pos_dot_y = (message_scale[left_up] + message_scale[right_up]) - message_scale[left_down] + message_scale[right_down]);
		p_balance.add_part( balance_pos, (pos_dot_x * 1.0), (pos_dot_y * 1.0));
		p_balance.remove_part( 8 );
	card.release_analog_input( id1 );
	card.release_analog_input( id2 );
	card.release_analog_input( id3 );
	card.release_analog_input( id4 );			

Python software

from PyDAQmx import Task
from PyDAQmx.DAQmxConstants import *
from PyDAQmx.DAQmxTypes import *
import numpy
import msvcrt
import time

times = []
try :
    freq = 100.0 # Hz
    numinputs = 4

    analog_input = Task()
    read = int32()
    timer= time.clock()
    running = True

    data = numpy.zeros((numinputs,), dtype=numpy.float64)

    #DAQmx Configure Code
    analog_input.CreateAIVoltageChan("Dev1/ai0:%i" % (numinputs - 1), None, DAQmx_Val_RSE, -10.0,10.0,DAQmx_Val_Volts,None)

    datalist = []
    while running:
        #DAQmx Start Code
        timeBeforeRead = time.clock()
        line = ser.readline()

        time.sleep((1 / freq) - (time.clock()- timeBeforeRead))
        times.append(timeBeforeRead - time.clock())
        if msvcrt.kbhit():
            running = False

finally :
    print "Stop"
    t = numpy.array(times)
    afwijking = numpy.mean(abs(t - numpy.mean(t)))
    maxafwijking = max(abs(t-numpy.mean(t)))
    print numpy.mean(t), afwijking, maxafwijking