Configuring flightmodes ...

This forum is dedicated to all issues and questions related to your individual setups and configurations
Post Reply
Taipan
Posts: 6
Joined: Fri Jan 08, 2016 11:40 am

Configuring flightmodes ...

Post by Taipan »

Hi,

The chart in the Wiki on Flightmodes (http://www.multiwii.com/wiki/index.php? ... lightmodes) lists the sensors that are used in each mode.

Does that mean that if I enable GPS Return to Home that all the required sensors (Gyro, Baro, Accel., GPS, Sonar, Compass) will be automatically used or does it mean that I need to enable each of those sensors too?

In other words, if I am using a 3-position switch on AUX1 to activate RTH in position 3, do I also have to activate BARO, MAG, SONAR in position 3 for RTH to work correctly?

Taipan

Kbev5709
Posts: 451
Joined: Mon Aug 17, 2015 5:56 pm

Re: Configuring flightmodes ...

Post by Kbev5709 »

Taipan wrote:Hi,

The chart in the Wiki on Flightmodes (http://www.multiwii.com/wiki/index.php? ... lightmodes) lists the sensors that are used in each mode.

Does that mean that if I enable GPS Return to Home that all the required sensors (Gyro, Baro, Accel., GPS, Sonar, Compass) will be automatically used or does it mean that I need to enable each of those sensors too?

In other words, if I am using a 3-position switch on AUX1 to activate RTH in position 3, do I also have to activate BARO, MAG, SONAR in position 3 for RTH to work correctly?

Taipan

If you enable GPS, you can only do that when the craft is in angle mode (also called level mode,) or horizon mode. Both of those modes automatically enable both your gyro and acc so you never have to enable them separately in GPS mode.

If you have this statement in your config.h GPS section enabled :
//Navigation engine will takeover BARO mode control
#define NAV_TAKEOVER_BARO 1 //(**)

You will never need to enable the baro by hand when using GPS. On RTH flights I believe that the mag is used whether the mag mode is enabled or not, so a good calibration never hurts. As a matter of fact, the following statement from the wiki page says:

The mag sensor is mandatory for GPS control, but MAG mode is not.

So, in other words, if your FC is mag equipped it will automatically be used in GPS mode when needed. The same wiki also mentions that when you switch the mag on with the TX, it is actually a flight mode of it's own.
Here, the wiki describes the mode:

MAG - Heading lock mode. Can be activated in all flight stabilization methods.
The multirotor will continue to point in the same direction until there is a yaw input. Without this mode, you will still have a light deviation (like a tail gyro in heli).
compared to no MAG offers a drift free tail, just like the difference between heading hold and conventional helicopter gyros.
Needs: gyro + acc + mag sensors (acc is needed also because it is used in heading angle determination)

Answering your second question, no, maybe. When you flip the RTH switch both your mag and baro (if you have the takeover baro statement defined, which is why I said maybe) are automatically used by the Nav section of your GPS. If you don't have the takeover statement enabled I suppose you would need to setup baro on the aux channel, but not the mag.

Last point to relay, sonar is not normally used in RTH and unless you actually have a sonar module hooked up, (it is not on the FC, but a separate module that you need to buy) enabling it will accomplish nothing. As a matter of fact, sonar is only supposed to enable "landing lights" with the code as written in 2.4. Here is an excerpt of the sonar/landing light code:

case 4:
taskOrder=0;
#if SONAR
Sonar_update(); //debug[2] = sonarAlt;
#endif
#ifdef LANDING_LIGHTS_DDR
auto_switch_landing_lights();
#endif

There are some mods to the code out there that actually make sonar work as it should, sort of, by using the cheaper HC SR04, but the actual code is written for the somewhat pricey Devantech SRF line of sensors and not for the less expensive
HC SR04 that most people actually have. Here is the actual config.h code:

/* Sonar */ // for visualization purpose currently - no control code behind
//#define SRF02 // use the Devantech SRF i2c sensors
//#define SRF08
//#define SRF10
//#define SRF23

Taken straight from the config.h
Average price for SRF08? Around $50.00. Is it worth the price for what it does? I personally don't care to have a $50.00 sonar on/off light switch.
HC SR04? $3.00...... :?....I've seen some code on this forum where some developers have written code for generic sensors like this cheapo. I personally have an HC SR04 and it has never worked correctly using those mods in the code. I suspect that my module is toasted though, perhaps because it may have been hooked up in the wrong order with the hot being connected before the ground on a live VIN. That, I found out too late, is a no no with this sensor. The code was supposed to be a fusion mod with the baro so that the quad can switch from sonar to baro once the limit of the sonar has been reached. The verdict has not yet been reached by me on the usefulness of the HC SR04 with this code due to my problems with the sensor and reluctance to bother with it anymore. I have successfully used my baro to fly low level under a meter with almost no problems at all which is the reason for using sonar in the first place. The sonar as incorporated in the code written for the HC SR04 is used at heights of two meters or less for hopefully better terrain following. More than two meters and the baro does the altitude. Since 99.99 percent of my flying is done at altitudes over 6 feet, I find it impractical to waste time and money on something I do very little of. Now, if they could write a really effective collision avoidance code using cheap sonar I might rethink things....

Taipan
Posts: 6
Joined: Fri Jan 08, 2016 11:40 am

Re: Configuring flightmodes ...

Post by Taipan »

Thanks for the very detailed reply.

Yes, the sonar I have is the HC-SR04 and it seems to be working fine. The way I can tell is by using EZ-GUI to report the actual height of the quadcopter above the floor with the SONAR active, and it is accurate to within a cm or so. I assumed that the FC would use the SONAR to land the quadcopter when it is within a couple of meters of the ground because the GPS would not be accurate enough? I had no idea that there was a landing lights option ....

Anyway, I will give it a try and see what happens ... :)

Kbev5709
Posts: 451
Joined: Mon Aug 17, 2015 5:56 pm

Re: Configuring flightmodes ...

Post by Kbev5709 »

Taipan wrote:Thanks for the very detailed reply.

Yes, the sonar I have is the HC-SR04 and it seems to be working fine. The way I can tell is by using EZ-GUI to report the actual height of the quadcopter above the floor with the SONAR active, and it is accurate to within a cm or so. I assumed that the FC would use the SONAR to land the quadcopter when it is within a couple of meters of the ground because the GPS would not be accurate enough? I had no idea that there was a landing lights option ....

Anyway, I will give it a try and see what happens ... :)

I could use some info from you on how the HC SR04 you have is hooked up. What pins do you use? 9 and 10? I would also like to know what code mods you had to do to make it work. The HC SR04 isn't even supposed to work without some mods to the code.
The landing lights are the only thing that the code as written in stock form are supposed to control and that is written for Devantech sensors (which the HC SR04 is not). Without fusing the baro and the sonar, there should be nothing in the code that can make it work as a height sensor. Are you sure your baro isn't giving you those accurate readings? Every example of a working SR04 I've seen reads out heights using the debug windows in the graphs portion of the win gui. Let me in on your secret method. What sensor do you define in the config.h since the HC SR04 is not even in that list? There is no sensor define anywhere in the config.h for that sensor. Also, when I read: /* Sonar */ // for visualization purpose currently - no control code behind, I know that it is not functional for altitude work.
I know from personal experience that the HC SR04 is not plug and play, especially on the HK Pro board because I also own both of those. There is no support written in to the code ANYWHERE for that sensor. I can only assume that your HC SR04 is working miracles or you know something that I don't. I would turn off sonar and recheck your ez gui for altitude info to see if it is the baro unless you have stumbled onto something no one else has. Also, there is nothing in the stock code that allows for landing the craft with sonar. The FC can only do what it is told to do by it's programmer(s). The sonar module works by sending out pings at regular intervals and listening for the return of those pings. In order for it to actually work there needs to be code inserted telling what pins to use for trigger and echo and what the timing of the pings is. When one of these is really operating, you can actually hear little clicks as it sends the ping. Unless you have inserted the code to make the module function, what you are getting is barometer readout on your EZ GUI. If by some miracle you have it clicking by simply plugging it in somewhere, let me in on exactly what you are doing.
Did you build the craft or buy it RTF????? The reason I ask that is because getting sonar to work has never been a priority with the developers and is still not really integrated into the code even in version 2.4. If you built your craft and programmed your FC to actually use that sensor, you should be able to tell me how it's done. Please, let me in on how it's done. If you bought it with everything all ready to fly (RTF) that would explain things somewhat.

Taipan
Posts: 6
Joined: Fri Jan 08, 2016 11:40 am

Re: Configuring flightmodes ...

Post by Taipan »

Kbev5709 wrote:I could use some info from you on how the HC SR04 you have is hooked up. What pins do you use? 9 and 10? I would also like to know what code mods you had to do to make it work. The HC SR04 isn't even supposed to work without some mods to the code.


I used the information and code provided in this thread - viewtopic.php?f=8&t=6282&hilit=%23define+SONAR_GENERIC_TRIGGER_PIN+12+%2F%2F+motor+12 ... :)
The code (MutiWii_Generic_Sonar) is available from https://onedrive.live.com/?authkey=%21A ... FA21482B83

And yes, I used signal pins D9 and D10 and in the code that I downloaded from that thread, I made these changes:

I modified in config.h

#define SONAR_GENERIC_TRIGGER_PIN 9 // motor 12
#define SONAR_GENERIC_ECHO_PIN 10 // motor 11

and in def.h, I edited this entry

#define SONAR_GEP_TriggerPin_PIN_HIGH PORTH |= 1<<6; // WAS: PORTB |= 1<<6;
#define SONAR_GEP_TriggerPin_PIN_LOW PORTH &= ~(1<<6); // WAS: PORTB &= ~(1<<6);
#define SONAR_GEP_EchoPin_PCINT PCINT4 // WAS: PCINT5

I think that was all that I needed to do to make it work with the Hobby King MultiWii Pro board. It is my understanding that the SONAR is used in preference to the BARO when the height is less than 4 meters, but I am yet to test that theory.

Cheers,

Taipan

Kbev5709
Posts: 451
Joined: Mon Aug 17, 2015 5:56 pm

Re: Configuring flightmodes ...

Post by Kbev5709 »

:roll: OK, now it all makes sense. That is the same code mod I have in my Pro board but my HC SR04 is toast and it won't work. Also, you can set the height that you want it to stop working and let the baro takeover. I think 4 meters might be pushing the limits a bit. I believe it is more accurate in the 2 meter range. I wonder how this sensor interacts with the autoland function? I thought you knew something no one else did with that board and sensor. You never said you did the code mods :roll: :lol: :D

Post Reply