I recently got hold of the SDK-MPU9150A. I'm trying to read the accelerometer data and accelerometer bias data. I used the "teapot demo app" source as a start, which compiles fine in visual studio 2008. Need 'glut32.dll' in the same bin dir as the teapot demo to run thou. But the real question I have is deciphering the data. I know by looking at the SDK source ("Embedded_MotionApps-MPU9150-Rel-MSP430F5528-V4_1_0_INVN_9x_HOST-2012-02-14") that
the rx receiving code callback looks like this:
static int rx_cb(char data)
{
if (state.uart_in[0] == 'm') {
if (state.uart_in[1] == 'f')
state.uart_in[2] = data;
else if (data == 'f')
state.uart_in[1] = 'f';
else
memset(&state.uart_in, 0, sizeof(state.uart_in));
} else if (data == 'm')
state.uart_in[0] = 'm';
return 0;
}It seems to me that i need to send the string "mf" + "some char" where come char can be 'f' 's' 't' 'a' etc... For example, "mfA" sets the some flag to send accelerometer and accelerometer bias data. As seen in this code:
static signed char handle_input(void)
{
signed char result = 0;
switch (state.uart_in[2]) {
case 'f':
case 'F':
/* Change FIFO rate. */
if (state.fifo_ms == 200) { /* 5Hz */
inv_set_fifo_rate(19);
state.fifo_ms = 100;
} else if (state.fifo_ms == 100) { /* 10Hz */
inv_set_fifo_rate(9);
state.fifo_ms = 50;
} else if (state.fifo_ms == 50) { /* 20Hz */
inv_set_fifo_rate(39);
state.fifo_ms = 200;
}
break;
case 's':
case 'S':
/* Change sensors. */
state.cur_sensor = (state.cur_sensor+1) % ARRAY_SIZE(sensor_config);
state.data_send = 0;
/* Handle 9x->6x and 6x->9x transitions. */
if (sensor_config[state.cur_sensor] == INV_NINE_AXIS) {
eMPL_stop();
eMPL_start_mpu(1);
motion_cb(INV_MOTION);
}
else if (sensor_config[state.cur_sensor] == INV_SIX_AXIS_GYRO_ACCEL) {
eMPL_stop();
eMPL_start_mpu(0);
motion_cb(INV_MOTION);
} else
inv_set_mpu_sensors(sensor_config[state.cur_sensor]);
break;
case 't':
case 'T':
/* Self test. */
inv_self_test_calibration_run();
eMPL_stop();
eMPL_start_mpu(1);
break;
case 'a':
case 'A':
if (sensor_config[state.cur_sensor] & INV_THREE_AXIS_ACCEL)
state.data_send ^= (SEND_ACCEL | SEND_ACCEL_BIAS);
break;
case 'g':
case 'G':
if (sensor_config[state.cur_sensor] & INV_THREE_AXIS_GYRO)
state.data_send ^= (SEND_GYRO | SEND_GYRO_BIAS);
break;
case 'm':
case 'M':
if (sensor_config[state.cur_sensor] & INV_THREE_AXIS_COMPASS)
state.data_send ^= (SEND_MAG | SEND_MAG_BIAS | SEND_HEADING);
break;
case 'z':
case 'Z':
/* Exit loop. */
result = -1;
break;
default:
break;
}
memset(&state.uart_in, 0, sizeof(state.uart_in));
return result;
}Even if I do that I still cannot get the SDK_MPU9150 to send the accelrometer and accelerometer bias data.
I suspect to be 14 bytes long.
where...
* packet[0] = $
* packet[1] = 1 for a debug packet (string of text)
* 2 for a quaternion packet
* 3 for a data packet
* packet[2-12] = data
* packet[13] = r
* packet[14] = n
and packet[8] would be the character tag.
Which packet[8] should be 'a' that identifies the accelerometer and accelerometer bias data being outputted. As seen here:
static void send_data(void)
{
long data[3];
unsigned char out[10];
if (state.data_send & SEND_GYRO) {
if (!inv_get_gyro(data)) {
packetize_data(data, 3, 5, 'g', out);
eMPL_send_packet(PACKET_TYPE_DATA, out);
}
}
if (state.data_send & SEND_GYRO_BIAS) {
if (!inv_get_gyro_bias(data)) {
packetize_data(data, 3, 5, 'b', out);
eMPL_send_packet(PACKET_TYPE_DATA, out);
}
}
if (state.data_send & SEND_ACCEL) {
if (!inv_get_accel(data)) {
packetize_data(data, 3, 12, 'a', out);
eMPL_send_packet(PACKET_TYPE_DATA, out);
}
}But I do not see that. All I get is the following output from a debug printf I made up over and over again.
In hex.
24 03 FF D3 FF 39 0F EB 2E F7 61 DE 0D 0A
24 03 FF D8 FF 5E 0F E4 2E EB 61 F3 0D 0A
24 03 FF D8 FF 5C 0F E8 2E EA 61 08 0D 0A
24 03 FF D8 FF 5D 0F EC 2E E9 61 1D 0D 0A
24 03 FF D8 FF 5F 0F ED 2E E8 61 32 0D 0A
24 03 FF D6 FF 5C 0F E4 2E E7 61 47 0D 0A
24 03 FF D7 FF 5D 0F E6 2E E6 61 5C 0D 0A
24 03 FF D8 FF 5F 0F E0 2E E4 61 71 0D 0A
24 03 FF DB FF 5C 0F E9 2E E4 61 86 0D 0A
24 03 FF D6 FF 5F 0F E7 2E E4 61 9B 0D 0A
24 03 FF DA FF 5D 0F E8 2E E4 61 B0 0D 0A
where packet 0x2E is the contents of packet[8]. Should it be 0x61 where it is 'a'?
I really hope you can point me in the right direction. I would be nice if there was more documentation for this as I am in a desperate situation to decipher whats in the 'SDK source' and 'tea pot demo'.
Re: Re: MPU9150 Reading accelerometer and accelerometer bias?
Hi,
the character tag you are looking for is set in packetize_data() function, which does not operate with the full 14-byte package, but only with data portion (i.e. bytes 2-12). Thus 'tag' is in place 11, which seems to be the correct 0x61 in your example data.
hope this helps
P
Re: Re: MPU9150 Reading accelerometer and accelerometer bias?
Using RealTerm, or similar serial program, I send 'mfs' (0x6d 0x66 0x73) 3 times to mode change to accelerometer:
INV_NINE_AXIS -> mfs
INV_SIX_AXIS_GYRO_ACCEL -> mfs
INV_THREE_AXIS_GYRO -> mfs
INV_THREE_AXIS_ACCEL -> mfs
(INV_THREE_AXIS_COMPASS)
I then send 'mfa' to start/stop sending the raw values
I receive 14 byte packets where every other packet has an 11th byte of 'a' = 0x61, and the other packets have an 11th byte of 'x' = 78
Re: Re: MPU9150 Reading accelerometer and accelerometer bias?
It seems like it should be simpler to get the debug console working. I have teapot demo working in C, and Python visualization working.
I haven't figured out how to get the console portion of the Python code working. Lines 80-90, 169-290 of eMPL's main.c make it look like I should be able to send commands like "T" or "mfG" to get different outputs, however I don't find a provision for this in the Python app. I tried using HyperTerminal and RealTerm, however, it's unclear if it changes anything.
Can anyone confirm that I should be able to pass these variables in, and perhaps suggest a procedure for doing so?
Re: Re: MPU9150 Reading accelerometer and accelerometer bias?
You should be able to direct your "mfa" or "mfg" in the python app with the keyboard. Just make sure that the "cube" window is in current focus for Windows.
Re: Re: MPU9150 Reading accelerometer and accelerometer bias?
SOLVED:
Python does not respond to the keyboard mappings in the "Region and Language" options part of control panel, so you must use your native mapping.