Multiwii 2.4 as Slave

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download

Multiwii 2.4 as Slave

Postby snow-man-01 » Mon Aug 01, 2016 9:47 am

Hello,

I want to set the Multiwii as Slave. I have another Arduino and I want to sent data from Arduino to Multiwii. Does anybody know where in the Code Multiwii 2.4 I can set the following code for the slave:

#include <Wire.h>

void setup() {
Wire.begin(8); // join i2c bus with address #8
Wire.onReceive(receiveEvent); // register event
Serial.begin(9600); // start serial for output
}

void loop() {
delay(100);
}

// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany) {
while (1 < Wire.available()) { // loop through all but the last
char c = Wire.read(); // receive byte as a character
Serial.print(c); // print the character
}
int x = Wire.read(); // receive byte as an integer
Serial.println(x); // print the integer
}
snow-man-01
 
Posts: 18
Joined: Mon Jul 18, 2016 9:50 am

Re: Multiwii 2.4 as Slave

Postby gregd72002 » Mon Aug 01, 2016 11:18 am

Multiwii uses its own I2C implementation and is not using Wire.h. Combining 2 different i2c approaches is not a good idea and most likely will never work.
gregd72002
 
Posts: 103
Joined: Fri Dec 12, 2014 5:16 pm

Re: Multiwii 2.4 as Slave

Postby snow-man-01 » Mon Aug 01, 2016 12:44 pm

Mh,.. Do you have any idea to solve this problem?
snow-man-01
 
Posts: 18
Joined: Mon Jul 18, 2016 9:50 am

Re: Multiwii 2.4 as Slave

Postby gregd72002 » Mon Aug 01, 2016 1:42 pm

it depends on what you are trying to do. Do you have to use i2c, why not to use serial? What data will you be sending, how much of it....
gregd72002
 
Posts: 103
Joined: Fri Dec 12, 2014 5:16 pm

Re: Multiwii 2.4 as Slave

Postby snow-man-01 » Wed Aug 03, 2016 2:48 pm

Yes, I use i2c. what do you mean with serial? ftdi interface?

I want to send int values from an arduino to multiwii. this arduino is connected with 8 ultrasonic sensor. So the arduino sends values from the sensor to the multiwii. There are 100 values sent per second.

The post ist already working when the multiwii controller does not have the code for the quadcopter.
snow-man-01
 
Posts: 18
Joined: Mon Jul 18, 2016 9:50 am

Re: Multiwii 2.4 as Slave

Postby gregd72002 » Wed Aug 03, 2016 4:13 pm

for arduino to arduino communication over i2c you might want to take a look at I2C_GPS_NAV for and example

I2C_GPS_NAV is an arduino based software that interfaces with Multiwii on one end and GPS on the other:

MultiWii <-------[i2c]------> I2C_GPS_NAV <---------- [serial] ---------> GPS
gregd72002
 
Posts: 103
Joined: Fri Dec 12, 2014 5:16 pm

Re: Multiwii 2.4 as Slave

Postby snow-man-01 » Wed Aug 03, 2016 7:22 pm

I do not want to use the GPS. Or must I only use the I2C_GPS_NAV without using GPS to connent the arduino to multiwii?
snow-man-01
 
Posts: 18
Joined: Mon Jul 18, 2016 9:50 am

Re: Multiwii 2.4 as Slave

Postby gregd72002 » Thu Aug 04, 2016 8:56 am

I2C_GPS_NAV is just an example. You will need to code something yourself.
gregd72002
 
Posts: 103
Joined: Fri Dec 12, 2014 5:16 pm

Re: Multiwii 2.4 as Slave

Postby snow-man-01 » Wed Aug 10, 2016 1:27 pm

can you send me more information (a link) please where I can connect the arduino pro mini to Multiwii? I do not know how I can do that.
snow-man-01
 
Posts: 18
Joined: Mon Jul 18, 2016 9:50 am

Re: Multiwii 2.4 as Slave

Postby Hamburger » Sat Aug 13, 2016 2:26 pm

Use the msp protocol over serial
User avatar
Hamburger
 
Posts: 2557
Joined: Tue Mar 01, 2011 2:14 pm
Location: air

Re: Multiwii 2.4 as Slave

Postby snow-man-01 » Mon Aug 15, 2016 9:25 am

what must I change in the protocoll.cpp? I see two important function: void serialCom and void evaluateCommand.
snow-man-01
 
Posts: 18
Joined: Mon Jul 18, 2016 9:50 am

Re: Multiwii 2.4 as Slave

Postby snow-man-01 » Mon Aug 15, 2016 10:21 am

I added this under the function evaluateCommand:

case MSP_Data_promini
mspAck();
s_struct_w((uint8_t*),);
break;


But do not know what I must add into.
snow-man-01
 
Posts: 18
Joined: Mon Jul 18, 2016 9:50 am

Postby Zviki » Wed Aug 17, 2016 4:15 am

I think that sonar could work through digital input pin... Next time try Google. [URL]Arduino Sonar - Arduino Project Hub
https://create.arduino.cc/projecthub/fa ... dar-69b8fe[/URL]

Sent from my SM-N910C using Tapatalk
Zviki
 
Posts: 25
Joined: Sat May 28, 2016 7:39 pm


Re: Multiwii 2.4 as Slave

Postby snow-man-01 » Wed Aug 17, 2016 9:22 am

Yes, but I want to connect 8 Ultrasonic sensors. There are not enough digital ports.
snow-man-01
 
Posts: 18
Joined: Mon Jul 18, 2016 9:50 am

Multiwii 2.4 as Slave

Postby Zviki » Fri Aug 19, 2016 5:19 am

snow-man-01 wrote:Yes, but I want to connect 8 Ultrasonic sensors. There are not enough digital ports.

You can connect them through I2C. All on the same port. You just need to assign different address for each one. Also, on second link I posted is explained how to connect Arduino to Arduino.

Sent from my SM-N910C using Tapatalk
Zviki
 
Posts: 25
Joined: Sat May 28, 2016 7:39 pm

Postby Zviki » Fri Aug 19, 2016 5:25 am

Here is explained how to and also code is there How to connect more than 10 sensors to Arduino uno r3 - Arduino Stack Exchange
http://arduino.stackexchange.com/questi ... ino-uno-r3

Sent from my SM-N910C using Tapatalk
Zviki
 
Posts: 25
Joined: Sat May 28, 2016 7:39 pm

Postby Zviki » Fri Aug 19, 2016 5:32 am

Or here Raspberry Pi • View topic - Using an I2C expander to connect multiple distance sensors?
https://www.raspberrypi.org/forums/view ... 2&p=934447

Sent from my SM-N910C using Tapatalk
Zviki
 
Posts: 25
Joined: Sat May 28, 2016 7:39 pm


Return to Software development

Who is online

Users browsing this forum: No registered users and 25 guests