Use serial port 3 in MEGA too...

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
nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Use serial port 3 in MEGA too...

Post by nhadrian »

Hi all,

I just found the r1055 release on multiwii repo.
I tried, when only OSD on serial3 is connected it works great.
But, with this simple clone method, when serial 1 is connected to GUI too, it crashes, many data loss, etc.
I thought it's not as easy as it is written down but it is interresting to solve this question anyway and have two fully functional serial ports on MEGA... could be useful when ie. bluetooth and OSD are connected at the same time!!!

What do you think guys?

BR
Adrian

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: Use serial port 3 in MEGA too...

Post by haydent »

when you say serial 1 are you numbering 0-3 or 1-4 for ports ?

i made a thread about this sort of thing too: viewtopic.php?f=7&t=2218

what is "this clone method" ? is it something in r1055 ? i havent looked at it

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: Use serial port 3 in MEGA too...

Post by nhadrian »

I suggest to check r1055 first and then you'll understand.
The idea of the author was that he copied all functions of main serial port to serial 3 port. So it is not a remapping like in your topic but the idea of having two working serials at the same time. But, because of the interrupts it is now working really when there is communicaion on both serial ports...

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: Use serial port 3 in MEGA too...

Post by haydent »

i understand now. prob best to contact author directly.

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: Use serial port 3 in MEGA too...

Post by Alexinparis »

I think the purpose was to be able to connect an OSD on serial port 3, but not be able to communicate at the same time with GUI and OSD.
It would be possible, but it would require some code evolution with multiple buffers.

ronco
Posts: 317
Joined: Thu Aug 18, 2011 2:58 pm

Re: Use serial port 3 in MEGA too...

Post by ronco »

Hi,

i made a similar mod :D .. but for serial 1 .. it may be easy made variable with a define.. to choose the serial port that clones the gui data.

i posted it here:
viewtopic.php?f=7&t=2043&p=20241#p20241

the code is here http://code.google.com/p/multiwii/sourc ... rial_1_gui

i dont know whitch variant is better so maybe alex would like to take a look ;)

it would be good for the atmega32u4 to make serial 1 usable for BT or what ever

regards Felix

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: Use serial port 3 in MEGA too...

Post by Alexinparis »

I will have a look on it ;)
The result is generally simple, but it's not so easy to make things generic from a code patchwork.

ronco wrote:Hi,

i made a similar mod :D .. but for serial 1 .. it may be easy made variable with a define.. to choose the serial port that clones the gui data.

i posted it here:
viewtopic.php?f=7&t=2043&p=20241#p20241

the code is here http://code.google.com/p/multiwii/sourc ... rial_1_gui

i dont know whitch variant is better so maybe alex would like to take a look ;)

it would be good for the atmega32u4 to make serial 1 usable for BT or what ever

regards Felix

Mis
Posts: 203
Joined: Fri Apr 01, 2011 12:23 am

Re: Use serial port 3 in MEGA too...

Post by Mis »

nhadrian:
What OSD you try connect. With Misio-OSD i can use both ports at the same time. Requests from GUI and OSD are parsed separatly by MWC and no problems from this side. The output from MWC is sended by both SERIAL0 and SERIAL3 at the same time. OSD parse the output commands and use it or ignore it. Data requested by OSD is sended to MultiWiiConf too, but MultiwiiConf use it (or ignore - i don't know), and work normally.
In my case Misio-OSD and MultiWiiConf can work in the same time.
I know that this is not perfect solution, but work as I expected.

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: Use serial port 3 in MEGA too...

Post by nhadrian »

I'm using Mobidrone OSD right now. In my oppinion, this is not the really solution.
For me, the final acceptable solution would be two total independent serial port. Not just for my OSD but for any general puropses...

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: Use serial port 3 in MEGA too...

Post by haydent »

maybe instead of cloning the code , couldnt it just run a loop, checking each chosen serial port one after the other ?

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Use serial port 3 in MEGA too...

Post by copterrichie »

haydent wrote:maybe instead of cloning the code , couldnt it just run a loop, checking each chosen serial port one after the other ?


Here is a proposal made for a special mega serial file made back one May 12, 2012 however it seems to have gotten buried.

viewtopic.php?f=8&t=1516&start=50#p13929

Works very well.

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: Use serial port 3 in MEGA too...

Post by Alexinparis »

I will commit a nice improvement about serial port management.
With this mod, each of the 4 Serial port of the mega would be able to handle separately (with an own state for each) a GUI, an OSD, a spektrum sat, or whatever as long it is MSP compatible.

I managed for instance to connect 2 GUI + 1 android phone via bluetooth at the same time, using 3 distinct UART.

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: Use serial port 3 in MEGA too...

Post by Alexinparis »

ronco wrote:it would be good for the atmega32u4 to make serial 1 usable for BT or what ever

regards Felix


I think you will also like the next commit, as it concerns also the UART of the promicro.
I tested it with 2 GUI running at the same time: one via the integrated USB, the other via the UART.

Matt.
Posts: 26
Joined: Sat Dec 31, 2011 11:41 pm
Location: Sydney, NSW, Australia

Re: Use serial port 3 in MEGA too...

Post by Matt. »

Here is a proposal made for a special mega serial file made back one May 12, 2012 however it seems to have gotten buried.

viewtopic.php?f=8&t=1516&start=50#p13929

Works very well.


Do you have a solution that works with the latest protocol as I have tried to add the serial.ino from the post above and it doesn't compile.

Cheers

Matt

ronco
Posts: 317
Joined: Thu Aug 18, 2011 2:58 pm

Re: Use serial port 3 in MEGA too...

Post by ronco »

Alexinparis wrote:
ronco wrote:it would be good for the atmega32u4 to make serial 1 usable for BT or what ever

regards Felix


I think you will also like the next commit, as it concerns also the UART of the promicro.
I tested it with 2 GUI running at the same time: one via the integrated USB, the other via the UART.


sounds good :D

ill test it soon :)

thank you!

regards Felix

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

Re: Use serial port 3 in MEGA too...

Post by crashlander »

Alexinparis wrote:...
I think you will also like the next commit, as it concerns also the UART of the promicro.
I tested it with 2 GUI running at the same time: one via the integrated USB, the other via the UART.

Is it possible to initialize different ports with different baud rates?!
Example: Serial0 and 1 with 115200 (for USB and Bluetooth), Serial3 with 19600 for APC220 telemetry (or XBee)?

Regards Andrej

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: Use serial port 3 in MEGA too...

Post by Alexinparis »

crashlander wrote:
Alexinparis wrote:...
I think you will also like the next commit, as it concerns also the UART of the promicro.
I tested it with 2 GUI running at the same time: one via the integrated USB, the other via the UART.

Is it possible to initialize different ports with different baud rates?!
Example: Serial0 and 1 with 115200 (for USB and Bluetooth), Serial3 with 19600 for APC220 telemetry (or XBee)?

Regards Andrej


Yes, one different baudrate per UART is possible.
Currently, the default is the same for all, but you can tune it easily here in multiwii.ino

Code: Select all

    SerialOpen(0,SERIAL_COM_SPEED);
    #if defined(PROMICRO)
      SerialOpen(1,SERIAL_COM_SPEED);
    #endif
    #if defined(MEGA)
      SerialOpen(1,SERIAL_COM_SPEED);
      SerialOpen(2,SERIAL_COM_SPEED);
      SerialOpen(3,SERIAL_COM_SPEED);
    #endif

jpeti29
Posts: 22
Joined: Wed Mar 07, 2012 9:19 am
Location: Hungary

Re: Use serial port 3 in MEGA too...

Post by jpeti29 »

i have some problem with this function. I'm using this type of board:
viewtopic.php?f=6&t=1672

I'm using I2C flytron gps with it.

i merged the 2.1 code with the r1074 (copy r1074 files to 2.1) but i is't work for me. only serial 0 communicate with the gui, osd, bt.

what's the problem? how can i debug this error?

regard, Peter

Magnetron
Posts: 124
Joined: Tue Jul 05, 2011 4:32 pm

Re: Use serial port 3 in MEGA too...

Post by Magnetron »

Alexinparis wrote:I will commit a nice improvement about serial port management.
With this mod, each of the 4 Serial port of the mega would be able to handle separately (with an own state for each) a GUI, an OSD, a spektrum sat, or whatever as long it is MSP compatible.

I managed for instance to connect 2 GUI + 1 android phone via bluetooth at the same time, using 3 distinct UART.

Alex when it will be available in the code?

Mis
Posts: 203
Joined: Fri Apr 01, 2011 12:23 am

Re: Use serial port 3 in MEGA too...

Post by Mis »

This is available from some days at code.google :
http://code.google.com/p/multiwii/sourc ... Wii_shared

User avatar
KasparsL
Posts: 75
Joined: Wed May 16, 2012 3:31 pm

Re: Use serial port 3 in MEGA too...

Post by KasparsL »

Hi,
please, could some one clarify, what must i do to get wireless link with APC220 working? How exactly i need to setup the code for 57600 operation? And how to compile the MultiwiiConf to work at 57600 too? I would like to use lates rev 1130. Could some one compile it for me?

User avatar
KasparsL
Posts: 75
Joined: Wed May 16, 2012 3:31 pm

Re: Use serial port 3 in MEGA too...

Post by KasparsL »

KasparsL wrote:Hi,
please, could some one clarify, what must i do to get wireless link with APC220 working? How exactly i need to setup the code for 57600 operation? And how to compile the MultiwiiConf to work at 57600 too? I would like to use lates rev 1130. Could some one compile it for me?

Ok, got it compiled and working somehow =]

werty
Posts: 4
Joined: Wed Oct 17, 2012 1:04 pm

Re: Use serial port 3 in MEGA too...

Post by werty »

how did you do it? can you explain for me?

shufflez
Posts: 42
Joined: Sat Nov 19, 2011 5:26 pm
Location: Amsterdam, Netherlands

Re: Use serial port 3 in MEGA too...

Post by shufflez »

I would like to know too :)
Running the Crius Extend Board, Xbee is on serial3.

User avatar
KasparsL
Posts: 75
Joined: Wed May 16, 2012 3:31 pm

Re: Use serial port 3 in MEGA too...

Post by KasparsL »

werty wrote:how did you do it? can you explain for me?

I changed the serial0 speed to be 57600 compiled it. changed the MultiwiiGui serial speed to 57600 and compiled it. To compile Gui by Processing, you need some files next to your*.pde file, I putted all files which were next to executable file and it worked.

shufflez
Posts: 42
Joined: Sat Nov 19, 2011 5:26 pm
Location: Amsterdam, Netherlands

Re: Use serial port 3 in MEGA too...

Post by shufflez »

My Xbee is now working properly on serial3 after fidling with the configuration via X-CTU a little bit more.
Have also activated LCD_TELEMETRY, not sure if this is necessary for Xbee (but would be necessary for my LCD :) )

werty
Posts: 4
Joined: Wed Oct 17, 2012 1:04 pm

Re: Use serial port 3 in MEGA too...

Post by werty »

KasparsL wrote:
werty wrote:how did you do it? can you explain for me?

I changed the serial0 speed to be 57600 compiled it. changed the MultiwiiGui serial speed to 57600 and compiled it. To compile Gui by Processing, you need some files next to your*.pde file, I putted all files which were next to executable file and it worked.


thank you very much ;)

User avatar
alll
Posts: 220
Joined: Fri Dec 07, 2012 9:53 am

Re: Use serial port 3 in MEGA too...

Post by alll »

Is there a release based on v2.1 that make the serial work on a atmega32u4 board (drofly)?
Could i use this one?
http://code.google.com/p/multiwii/sourc ... Wii_shared

thanks,
manu

yeahiii
Posts: 5
Joined: Sun Dec 09, 2012 11:06 am

Re: Use serial port 3 in MEGA too...

Post by yeahiii »

Hey,
ronco released a version with Serial1 working on the 32u4 and committed it to his branch in the multiwii repo.

I am currently flying with the version he posted here http://www.rc-heli-fan.org/post1413559.html#p1413559. It works great so I didn't try the version from the repo.

User avatar
alll
Posts: 220
Joined: Fri Dec 07, 2012 9:53 am

Re: Use serial port 3 in MEGA too...

Post by alll »

Yeahiii!, its working ;)
Thanks a lot!
manu

Post Reply