qcn

  • 參考 - USB感應器的通訊協定 (連結)

USB感應器能自行找尋COMPORT

ONavi isn't very good on support as codemercs.com is for their JoyWarrior sensors.

basically after the drivers are installed you have to enumerate USB serial devices

to find the sensor, i.e. the ONavi is a pseudo-modem.

I don't know if python has a way to do this ie scan COM ports in Windows

(the ONavi can often be something strange like COM63).

it may be easier if you know the COM port # ahead - I have to scan for the ONavi GUID:

DEFINE_GUID(GUID_CLASS_ONAVI_1, 0x4d36e978L, 0xE325, 0x11CE, 0xbf, 0xc1, \

0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18);

USB感應器設定為傳輸速率為115200 N-8-1

once you've found & opened the COM port, set the communication settng if needed,

ie 115.2K baud, 8 bytes, no parity, 1 sto bt, dtr control enable, rts control enable,

flow control disable

電腦送出字元*給USB感應器

to read a value you send/write the ONavi comport a * (asterisk) character

USB感應器回應字串**XXYYZZC

the subsequent read from the COM port should yield the ONavi data as a string

formtted **XXYYZZC

回應的標頭字串中 代表解析度為12/16/24bit

the first two characters are ** for the 12-bit sensor and ## for the 16-bit sensor

and $$ for the not-yet-ready 24-bit sensor

回應的標尾字串C代表結束

it sends two bytes following the leading 2 chars for the X/Y/Z components,

and a single-byte at the end for a checksum (which isn't used)

so in C I use:

x = (bytesIn[2] * 255) + bytesIn[3];

y = (bytesIn[4] * 255) + bytesIn[5];

z = (bytesIn[6] * 255) + bytesIn[7];

to convert to m/s/s:

x1 = ((float) x - 32768.0f) * FLOAT_ONAVI_FACTOR * EARTH_G;

y1 = ((float) y - 32768.0f) * FLOAT_ONAVI_FACTOR * EARTH_G;

z1 = ((float) z - 32768.0f) * FLOAT_ONAVI_FACTOR * EARTH_G;

where FLOAT_ONAVI_FACTOR = 7.629394531250e-05f

and EARTH_G = 9.78033f

  • 參考 - USB感應器的取樣頻率

設定一

If successful the main program will print out 10 seconds of monitoring values. NB --

OQCN needs to get data at 50Hz, i.e. for accelerometers that do hardware sampling, get a point ever .02 seconds (50 times a second i.e. 50Hz) --

設定二

but try to sample more and average points (see "mean_xyz()" function) up to 500Hz

(i.e. 10 samples averaged every .02 seconds).

  • 運算邏輯 - 電腦端傳回的資料

The OnePoint code set should:

1) access the sudden motion sensor i

2) Display the acceleration measured by the sudden motion sensor

3) Apply a significance level filter (magnitude of acceleration/standard deviation in a 1 minute window).

4) When the significance level is high (>3 standard deviations), issue a trigger visually. Don't issue another high trigger unless the trigger is 1.5 times higher than in the 1 minute prior.

5) Save to disk a 2 minute time series for each component of acceleration. The time series is centered on the trigger and output 1 minute after the trigger.

  • 感測驗證LaunchPad OQCN

Tests with JoyWarrior, MotionNode, and ONavi USB sensors side-by-side

(literally taped next to each other on ruler, resting on a desk which I "tapped")

x-bash slow 1-sec period 10 soft 10 hard, fast 3-5/sec 20 soft then 20 hard

y-bash slow 1-sec period 10 soft 10 hard, fast 3-5/sec 20 soft then 20 hard

z-bash slow 1-sec period 10 soft 10 hard, fast 3-5/sec 20 soft then 20 hard

very fast x/y/z periods

invert/rotate about x/y/z

onavi & motionnode had some dropouts, perhaps 3 devices on my Macbook's USB bus was too much?

http://github.com/carlgt1/qcn

  • 參考資料