$M< SERIAL RC What port to use

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
max7
Posts: 15
Joined: Mon Apr 07, 2014 12:25 pm

$M< SERIAL RC What port to use

Post by max7 »

I have MultiWii quad connected to port COM1 and MultiWii configure app works on that port.

I am trying to write command in that port with my own app
$M< MSP_SET_RAW_RC etc

But it does not work.

I used RealTerm to read what MultiWii app send to copter and I do not recognize protocol.
It does not have $M<

Do I have to use another port to send RC commands? What protocol MultiWii Conf app uses?

I have MultiWii Crius board.
It seems it has 2 TTL ports.

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: $M< SERIAL RC What port to use

Post by crashlander »

MultiWii Crius is to broad description there are AIO Pro versions with 4 serial ports, SE and LE have only 1!
Since MSP_SET_RAW_RC is normal MSP command it can be used on any available serial port but baud rate must match to what you set it while configuring your config.h

Regars
Andrej

max7
Posts: 15
Joined: Mon Apr 07, 2014 12:25 pm

Re: $M< SERIAL RC What port to use

Post by max7 »

I have CRIUS_SE_v2_0

I can't find baud rate in config.h
(only GPS baudd rate)

But I believe I use 9600 and it works.

Does MultiWii conf use $M< protocol?

max7
Posts: 15
Joined: Mon Apr 07, 2014 12:25 pm

Re: $M< SERIAL RC What port to use

Post by max7 »

@Andrej Thank You !

default baud rate is 115200

It was the problem.

config.h

#define SERIAL0_COM_SPEED 115200
#define SERIAL1_COM_SPEED 115200
#define SERIAL2_COM_SPEED 115200
#define SERIAL3_COM_SPEED 115200

max7
Posts: 15
Joined: Mon Apr 07, 2014 12:25 pm

Re: $M< SERIAL RC What port to use

Post by max7 »

I have 2 TTL ports on my PC
One reads data and MultiWii conf is connected to it

and I write to another port.
e.g. if I write MSP_RAW_IMU and MSP_ATTITUDE then MultiWii conf shows graph with correct values,

So I can write to MultiWii and read it back.

Now I send MSP_RC to get RC values. and I send RC values with MSP_SET_RAW_RC but it does not work.

I can arm with thr = 1000, yaw = 2000 or see send values back with MSP_RC

Here is my code to send joystick values

Code: Select all

      char * getMSP(int &size){
         int p = 0;
         buf[p++] = '$';
         buf[p++] = 'M';
         buf[p++] = '<';
         buf[p++] = 16;
         buf[p++] = MSP_SET_RAW_RC;
         *(short*)(buf+p) = (short)roll;p+=2;
         *(short*)(buf+p) = (short)pitch;p+=2;
         *(short*)(buf+p) = (short)yaw;p+=2;
         *(short*)(buf+p) = (short)thr;p+=2;
         *(short*)(buf+p) = (short)0;p+=2;
         *(short*)(buf+p) = (short)0;p+=2;
         *(short*)(buf+p) = (short)0;p+=2;
         *(short*)(buf+p) = (short)0;p+=2;
         char sum = 0;
         for(int i = 3; i < p; i++){
            sum ^= buf[i];
         }
         buf[p++] = sum;
         size = p;
         return buf;
      }

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: $M< SERIAL RC What port to use

Post by crashlander »

Since I''m hobby programer it is probably better (easier for me) to show you my code that works... :)

https://code.google.com/p/mwii-msp-tx/s ... _BABEL.ino

Regards
Andrej

max7
Posts: 15
Joined: Mon Apr 07, 2014 12:25 pm

Re: $M< SERIAL RC What port to use

Post by max7 »

Andrej, thanks but my code does exactly same thing.
+ My other commands work.

Is it possible that I have to enable some #define in arduino code?

I checked response when I send RC command copter responds

$ M > HEX(00) HEX(C8) HEX(C8)

HEX is hex char code

HEX(C8) == DEC(200) == MSP_SET_RAW_RC

HEX(C8) comes twice in response. just like I printed

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: $M< SERIAL RC What port to use

Post by crashlander »

Than it is O.K.
BUT!!! You must send the command at least couple of times per second for this to work or normal PCM, PPM decoding routine takes over and than fail safe....


Regards
Andrej

max7
Posts: 15
Joined: Mon Apr 07, 2014 12:25 pm

Re: $M< SERIAL RC What port to use

Post by max7 »

RCSERIAL command are active for 0.5 second and I send them 10 times a second.

Should I see Roll, Pitch, Yaw, Thr changes in MultiWii conf when I send RCSERIAL commands? (my motors are off)

Would I be able to ARM/DISARM with RCSERIAL?

Should I send values in 1000-2000 range?

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: $M< SERIAL RC What port to use

Post by crashlander »

max7 wrote:RCSERIAL command are active for 0.5 second and I send them 10 times a second.

I'm doing it with 40Hz, but 10 should work!
max7 wrote:Should I see Roll, Pitch, Yaw, Thr changes in MultiWii conf when I send RCSERIAL commands? (my motors are off)

Yes!
max7 wrote:Would I be able to ARM/DISARM with RCSERIAL?

Yes!
max7 wrote:Should I send values in 1000-2000 range?

Yes!

Your board has only 1 serial port so you can not use it for GUI and TX at the same time!
http://www.hobbyking.com/hobbyking/stor ... _FTDI.html

max7
Posts: 15
Joined: Mon Apr 07, 2014 12:25 pm

Re: $M< SERIAL RC What port to use

Post by max7 »

crashlander wrote:Your board has only 1 serial port so you can not use it for GUI and TX at the same time!
http://www.hobbyking.com/hobbyking/stor ... _FTDI.html



I have 2 USB TTL on PC.
I use one to send command and one to read.

My joystick app was sending: MSP_RC, MSP_ATTITUDE, MSP_ALTITUDE, MSP_RAW_IMU and MultiWii conf was using another port to read respond.

So I was able to add my joystick commands and see feedback.
All commands worked except MSP_SET_RAW_RC

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: $M< SERIAL RC What port to use

Post by crashlander »

Sorry but I do not understand exactly how you connect your stuff but Atmega 328p (used on that board) has single UART that is on the outside shared (connected) to two pin headers one for connecting FDTI and other with only 4 pins.
So when only one is connected and your app sends sequence of MSP_SET_RAW_RC (waits for response) and than immediately queries actual MSP_RC it should get proper response. If you connect both at the same time you probably get some weird voltage/signal interaction between serial ports and/or clash of GUI versus your app sends and receives.

You can use any MEGA based Arduino to test/debug your code (you do not need any sensors to test that part only I2C error counter will go mad) since it has 4 serial ports and you can use "native" GUI UART speed (115200bps) for GUI and any other speed for sending MSP_SET_RAW_RC on the other port.

Regards
Andrej

max7
Posts: 15
Joined: Mon Apr 07, 2014 12:25 pm

Re: $M< SERIAL RC What port to use

Post by max7 »

I switched from USB TTL CP2102 to FTDI and it started to work.


Not changes were made. Function I published it bug free. If someone needs C or C++ MSP joystick code. Please use it. It is public domain.

max7
Posts: 15
Joined: Mon Apr 07, 2014 12:25 pm

Re: $M< SERIAL RC What port to use

Post by max7 »

FTDI is connected directly in MultiWii and CP2102 had wires.

115200 may be to fast to send large joystick packet but some shorter packets were passing it.
I read somewhere that multiwii has 2% error rate at 115200 speed

max7
Posts: 15
Joined: Mon Apr 07, 2014 12:25 pm

Re: $M< SERIAL RC What port to use

Post by max7 »

Here is photo how I connected it and it worked
https://www.flickr.com/photos/122767914 ... 737134794/

The problem is errors. Right now it works when connected with wires at 9600 but does not work wireless when I connect transmitter.

iambramha
Posts: 7
Joined: Wed May 14, 2014 4:59 pm

Re: $M< SERIAL RC What port to use

Post by iambramha »

Hey guys looks like you are discussing something that I am looking for. Here is what I want to do..

Use one UART on Mega to connect to the Config GUI, and Use another UART to receive MSP_SET_RAW_RC from a Xbee or similar UART transceiver to control the Quad. Is this possible. Do I have to make any config.h changes to assign the serial ports to the GUI and the XBee? I mean how does the MultiWii know that MSP_SET_RAW_RC is coming on another serial port?

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: $M< SERIAL RC What port to use

Post by crashlander »

iambramha wrote:Is this possible.

Yes!
iambramha wrote:Do I have to make any config.h changes to assign the serial ports to the GUI and the XBee?

No change to MWII code is needed. (Apart from setting proper baud rate for connected device)
iambramha wrote: I mean how does the MultiWii know that MSP_SET_RAW_RC is coming on another serial port?

MWII listens no all available serial ports for valid MSP commands.

Regards
Andrej

Post Reply