Using controller as data logger

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
hucker
Posts: 1
Joined: Wed Mar 05, 2014 6:43 pm

Using controller as data logger

Post by hucker »

I'm trying to use a naze32 controller as a form of 3d data logger and am having problems getting data to stream from the device. I've dug through the code and have the idea of how it works:

I can see that the packet is structured like this:

$M<XYCS

$M< is the header
X=Size in binary
Y=Payload ->
C=Command -> e.g. RawIMU = 102 = 'f'
S=8 Bit xor checksum

For my raw IMU command this works out to

$M<0ff

where the 0 is binary 0
the first 'f' is the command 102 decimal
and the second 'f' is the checksum (basically 'f' xor'ed with 0)

So I fire up my terminal emulator (yes it does binary) and tried sending this both in the 'right after boot - not command line' and after '#' command line state and nothing I do seems to dump any data back from the controller.

Am I doing the right thing? I can read C code fine but in baseflight it isn't so easy. Is there a way for me to intercept the serial stream on the board (acronaze) so I can spy on the baseflight command stream? I could just fire up an emulator and see the back and forth...but I think I'm darn close.

Any idea's or a pointer to documentation beyond the Multiwwi Serial Protocol document.

Thanks!

timecop
Posts: 1880
Joined: Fri Sep 02, 2011 4:48 pm

Re: Using controller as data logger

Post by timecop »

All you need to know is the multiwii serial protocol document.
You're probably not formatting the rawimu request correctly and the board just ignores it.
You do NOT need to transmit # as that drops into CLI.
After all lights settle, you should be able to transmit MSP_RAW_IMU, and if properly formatted it will reply with the data.
Note, that multiwii (and by extension baseflight) rescale sensors to arbitrary values, instead of using engineering units. So while you can "log" the data, it might not be much of value other than determining "something was moving at this time".

Rusty105
Posts: 13
Joined: Thu Oct 31, 2013 4:09 pm

Re: Using controller as data logger

Post by Rusty105 »

Just an additional question for this. Can the Naze 32 do data logging onboard?

timecop
Posts: 1880
Joined: Fri Sep 02, 2011 4:48 pm

Re: Using controller as data logger

Post by timecop »

You could use 16mbit flash on rev5 boards to log stuff, but you will need to write the code to do it.

katip0
Posts: 2
Joined: Thu Mar 26, 2015 2:47 am

Re: Using controller as data logger

Post by katip0 »

Hi.

I'm also wanting to use a MultiWii as a sensor data logger but I'm wanting to broadcast the data via Bluetooth.

So has anyone got any ideas where to start of if anyone is or has done anything similar?

Cheers.

nebbian
Posts: 67
Joined: Mon Jul 21, 2014 6:54 am

Re: Using controller as data logger

Post by nebbian »

Fully built into the latest version of Cleanflight.
http://www.rcgroups.com/forums/showthread.php?t=2299805

This can use the inbuilt flash in a full Naze board, or you can use an Openlog board with external SD card.

There are also utilities to display the logged information.

happul3
Posts: 44
Joined: Mon Apr 21, 2014 1:54 am

Re: Using controller as data logger

Post by happul3 »

katip0 wrote:Hi.

I'm also wanting to use a MultiWii as a sensor data logger but I'm wanting to broadcast the data via Bluetooth.

So has anyone got any ideas where to start of if anyone is or has done anything similar?

Cheers.


It is very simple to send any sensor, motor, stick,etc. values via BT. You do not need to understand or change MW's serial protocol for that. You just use "stream" any data you like, limited by only serial bandwidth. You can adopt and expand example below. The output it produces can be captured with any generic serial com program including windows' hypertrm (use "Transfer" -> "Capture text" to log all the output you want. Note that this is rather inefficient use of serial bandwidth, but it can be enough if all you want fits into whatever rate your BT operates at. If you want to fit more, I can share code that I actually use myself. In a nutshell, I transfer 16 bit values as two printable characters and have Excel formula that reconstructs original values (limited to 14bits actually). This way you can still view and copy/paste data from hypertrm as text.


Code: Select all

  //this code snippet to be inserted after  for(n=0;n<UART_NUMBER;n++) { in  serialCom()  procedure inside Serial.ino
  if(CURRENTPORT==3)  {  //choose port your BT module is hooked up to; you can add additional condition like   
  //if(CURRENTPORT==3)&&(rcData[AUX3] >1800)) { //this makes ouptut conditional on AUX3 value - you can stop/start "streaming" manually

            for(uint8_t ii=0;ii<3;ii++) { serialize16str(gyroADC[ii]);  serialize8(',');}     
            serialize8('\r');serialize8('\n');
            UartSendData();
    }


Code: Select all

 //this code snippet is to be included anywhere inside Serial.ino (outside of any procedure, of course)
void serialize16str(int16_t i) { 
  char buf[13];
  uint8_t j,k;
  itoa(i, buf, 10);
  k=strlen(buf);
  for(j=0;j<k;j++)
  serialize8(buf[j]);
}

Post Reply