Ardupilot goes into the water Part 13

Long time - no sea.

If anybody will tell me about global warming - i will kill him!
We had the coldest (and rainiest) may and june ever.

And August was - the rainiest ever.


Globalization only seems to work in the financial domain, but not for the weather. What about a "weather-transfer" of bad weather to the sahara? They will appreciate the rain there. Despite this fact and the passing away of a close relative, i wished, these months had never happened.

In mid-july, we have seen that this spherical fusion-reactor some eight light-minutes away is still running. I am personally not a fan of nuclear energy, but in this case...

What happened since my last entry?
Not really much.

The new cat has now the same color on both hulls.
The board, that holds the hulls together is now coated with fiber and epoxy to make it more rigid.
The extra battery for the sonar was dropped. The power comes now from the main battery. (-300g of weight)
The cable from the sonar to the transducer was shortened (-100g)

This was really not much, but there are still some challenges out there...

Swimming is not one of my favourite disciplines.
Swimming in bad weather conditions does not even make it better.
Swimming is OK, considering the following conditions:

1. It is summer (I mean that season, when it should be really warm)
2. You have enough time to put on your swimming suit, when the boat starts to react weird.
3. You love swimming
4. No rain

if any of the above is not applicable, staying on the shoreline is the better option.

Swimming is usually caused by:

1. Software
2. Mechanics and Hardware
3. Personal idiocy
4. A combination of the above


To prepare the this year "PID optimization campaign" i decided, to reduce my recovery-swimming exercises to a minimum and thought about Radio Control.

First, i fiddled with my 27MHz RC control from the Jetski model, but found out that this thing is abolutely crappy. Bad range performance, noisy and most of all: no failsafe behaviour. I wanted the software on the ardupilot to decide, whether there is a transmitter controlling the ship or not. And therefore i have to measure the pulses comming out of the Receiver. So far so good, but the 27MHz Rx outputs always some pulses, regardless, if the Tx is on or off (the good old analog era...).

I remembered, that the Ardupilot was originally conceived as a fail-safe
system with an RC option as a fallback for the safe launching and landing
of an airframe.
Why not using this feature for the boat?
Reading the docs and the software showed, that the implementation, which is
in the original version of the Ardupilot was not exactly what i needed.

My requirements were:

1. If the transmitter is OFF or the Receiver is out of reach, the boat shall
be fully controlled by the Ardupilot.

2. If the Transmitter is ON, control shall be passed to the Radio control.

Implementation on the original version was a little bit different,
so i decided to do it my own way.

How to detect if the RF is good or bad?
The only way is to look at the servo pulses, that come out of the Receiver.
Analog RC Systems output always something on the servo channels, even when the Tx is OFF. (see above)
Discrimination between noise and a good signal would be possible by some weird SW algorithms, but i wanted to keep it simple.

A very old friend of mine, who is an RC Dinosaur told me to buy a 2.4GHz RC control.
So i ordered a SPEKTRUM DX5e, which is a fairly priced entry level model.
Reading the manual showed, that the failsafe functionality of the receiver was exactly that what
i needed. Manuals sometimes do not tell the truth, so i oscillographed the servo outputs and found, that
they really told the truth:

1. When the receiver is turned ON without a Transmitter beeing in the air, there is silence on all servo outputs - good.
2. When the Tx is turned ON and the Rx is correctly bound to the Tx, pulses on all channels - good.
3. When the Tx is switched OFF, silence on all channels, but not on the throttle. The throttle channel outputs a pre-programmed default pulse-width. - still good.

From the software point of view, it is very easy to distinguish between silence and "something". So i took the rudder channel to sense the RF.
(Tx ON --> pulses, Tx OFF --> silence)

Technically, all worked fine.

right in the middle: the Receiver.

I have put the code here:


Please note, that the Hardware of the Ardupilot board has to be
modified!
Read the comments in the RC_Control tab.
I have refactured some of the code and added some comments.
WITHOUT testing it. Take the code as a starting point for your own
experiments.


Thats all for today, on the next episode i will tell the experience with the RC control on the lake and why i decided not to use the RC any more.

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • Hi JD,

    what GPS are you using ?
    The code is written for the EM406.
    The only thing i do is to switch the baudrate from default 4800 to 9600 in the startup code. If you try the original code, this feature is not implemented. The EM406 stores this settings for about one week if powered off. If yo are using a different module, this may be a reason for the failure. But, if the blue led is ON, the GPS is OK.
    I still think there is some problem with the throttle output. Try a servo on the throttle output, to see if there is something living. If you have an oscillscope, you can directly look at the pwm pin if there are pulses coming out.
  • Harald, I commented out the entire R/C control tab and the lines of code that switch between R/C and AP. I will test it later today, but to be clear, are you using a "bind plug" or any other special instructions to get the GPS locked when you first turn the power on?

    While trying to the Ardupilot 1.0 code, I was having trouble getting GPS locked.... seems like it happened automatically with your code.
  • Hi JD,
    seems that there is a problem with the Throttle channel. The random movement of the rudder is OK, when the boat is at rest, because the GPS outputs random heading information, when the GPS is not moving.

    You can first try is to move the boat around (on land), when in AP mode. The random movements should stop and the rudder should "force" the boat towards the first waypoint.
    This may look funny if somebody is carrying a boat under his arms and moving around on land, but it helps ;-)

    Second, you have to find out, why the motor stops. There can be several reasons:
    Maybe the PWM Channel of the AP is dead or the ESC did not start up.

    I also had trouble with some ESCs. Mostly, they are in failsafe mode, when powered up. To get them armed, they need a startup procedure. Please look at the manual of your ESC.

    You can write some code to only control the throttle channel and put it in the

    What you can also try is to control the throttle only with the RC (as you already wanted to do). This will show, if the AP is working correct e.g. the boat should find its way to the waypoints. But if you try this, be aware of swimming!

    You also can try to test it by writing some code in the setup() function and fiddling with the pulse_servo_throttle function as in the example below:


    void setup()
    {
    init_ardupilot();
    waypoints = sizeof(wps) / sizeof(LONLAT);

    //ram_info();

    Init_servo();//Initalizing servo, see "Servo_Control" tab.

    test_yaw(); // Just move the servo to see, that there is something living

    // insert your test code from here

    pulse_servo_throttle(xx);
    delay(xx);


    regards
    Harald
  • also, yes I did try the steps on your troubleshooting guide.
  • I uploaded the code and modified the Attiny pin 6 (de-soldered it). I loaded 3 waypoints into the code (very short circle path in lake). Once loaded, I turn on the power to the boat and wait for GPS fix. With blue light on, the R/C system begins to respond and I can control the boat around the lake.
    The problem comes when I turn OFF the R/C transmitter, the boat simply stops in the water, and autopilot mode does not seem to work at all. I have the throttle plugged into In1 and Rudder into In2 - I originally tried with your hardware modification so no failsafe channel was used.

    I was intending to connect the throttle directly to the R/C so I could manually control the boats speed while in autopilot mode, but if I turn Off the transmitter to switch into autopilot mode, I lose the throttle control. The boat runs great in R/C mode, but just random rudder movement in autopilot mode.
  • Hi JD,

    have you tried all of the measures from my trouble shooting guide?
    Pleas note, that the code only works with a valid GPS fix.

    I have tested the code on the last weekend with a flying platform and it worked well. (the code worked well, but the platform crashed :)

    The failsafe function of the ATiny shall work without modification. If i have got it right, the Multiplexer is switched by the ATiny if the control input is connected to the switching channel of your RC (Channel 5 on the DX5e)
    You can check out the Version 1.0 of the original ArduPilot code and have a look, how Jordi has implemented the failsafe..

    Anyway, it makes me wonder, what exactly happens on your system. can you describe how the system behaves ?

    regards
    Harald
  • Harald, would you be willing to modify the code to allow the Attiny to control the failsafe?
    I am having problems getting your code to work.
  • Hi Harald

    Lately I have been doing some tests with the FEZ Domino for another project and have come to the conclusion that I’m replacing my two Arduinos with one FEZ Domino.

    My reasons for doing this is;
    • It’s built on .NET micro framework and is programmed in Visual Studio C#. This IDE is far superior to the Arduino IDE.
    • You can debug directly on the chip and set breakpoints in your code while the program is running (on the chip) and examine variables
    • C# has real string handling functions like .IndexOf .Substring .ToUpper etc.
    • The FEZ has a built in SD with a real file handling system.
    • It has 3 hardware UART so no more software serial. I need one for the GPS, one for the transducer and one for an XBee.
    • It has load of more RAM (62Kb) and flash (148Kb)
    • A built in real time clock
    • It has full threading capabilities and event handled UART’s

    OK, so it’s not real time like the Arduino (how could it with threading?) But it’s lightning fast for my use anyway.

    I’m currently working on this project with the FEZ Domino http://letsmakerobots.com/node/22108
    I’m not saying your should do the same, but if you haven’t heard of the FEZ, take a look here: http://www.tinyclr.com/ They also have the FEZ Panda for an introduction price of $19.95 It’s like the Domino without the SD card and USB host, but with 60 IO-pins and 4 UART.

    Kind regards
    Geir
  • Hello Geir,

    i already had a look at your site some months ago, because somebody gave me the link in the comments on some of my blogs.
    I felt in love with the perfect construction of your hull. It is absolutely awesome!
    I wish to have the time (and skills) to do the same work.

    I just had a (really quick) look at your software. Seems, that it works with a simple P control algorithm, which is almost the same mechanism as on my boat. Actually i am using a PI controller with very little "I". This works now very stable.
    Most of the time went into the debugging of some bugs in the original software, but now i think it works fine.

    Let´s keep in touch with the progress of our works.

    Best regards
    Harald
  • Hello Harald
    A friend of mine over at LMR tipped me about your blog and I see we are doing similar work, so I only wanted to say hi.
    You’ll find a description of my project here http://letsmakerobots.com/node/21098
    Like you I started out with an Ardupilot but as space and weight is no issue for my boat I instead went for two regular Arduino Duemilanove. One is handeling the navigation while the other one is logging GPS and depth as the boat moves along.
    As my max speed is around 3km/h I didn’t need any fancy PID control. So there isn’t really any Ardupilot code left in my setup, still I hope you have the time to take a look.
    Keep up the god work.
This reply was deleted.