Page 1 of 1

bi-copter instability

Posted: Wed Oct 26, 2011 8:49 pm
by LuisFCorreia
Hi all,

this is my first post here.

I've been working on a bicopter, in which I plan to control with an Android phone through a Bluetooth connection.

Here's a video I made with yesterday's trunk and my changes added in.

http://www.youtube.com/watch?v=RVVoygwq1-c

let me know what am I doing wrong, and why the heck is it so unstable.

And btw, there's also a sneek peek of the android app.

Re: bi-copter instability

Posted: Fri Oct 28, 2011 1:27 am
by kataventos
Hi,

there´s a good app in 1.9, nice work. Regarding your problem, did you try another pair of servos?
It looks like bad servos.

Cheers,
Henrique

Update: I have seen the video again and probably the servos are OK! Can you try to run it with a normal TX / RX PPM? what sensors do you have installed?

Re: bi-copter instability

Posted: Fri Oct 28, 2011 8:04 am
by LuisFCorreia
Hi,

I don't have a normat TX/RX setup.
This is my intended setup and I can't see that it makes that much difference. The instability happens even with no RC signal, which to me doesn't seem normal at all.

As for the sensors, I'm using WMP clones at low speed.
I have two, with different chips and both produce the same behaviour, so I think there is some sort of glitch in the software.

I've also read that the 1.7 version is a lot more stable then 1.8 and I might try that one too.

Luis

Re: bi-copter instability

Posted: Fri Oct 28, 2011 8:22 am
by LuisFCorreia
One more thing, I've used the GUI to setup BOXARM (high) in the AUX1 channel, but somehow it isn't working.

So I'm unable to arm the motors to do test flights.

p.s. this project will be presented it it's current form in http://codebits.eu in about 15 days (November 12th) the presentation will be up in a live feed and can be viewed worldwide, although the spoken language will be Portuguese. I really hope to get this ready by then.

Any help is welcome!

Re: bi-copter instability

Posted: Fri Oct 28, 2011 2:18 pm
by kataventos
LuisFCorreia wrote:As for the sensors, I'm using WMP clones at low speed.
I have two, with different chips and both produce the same behaviour, so I think there is some sort of glitch in the software.

I've also read that the 1.7 version is a lot more stable then 1.8 and I might try that one too.


Hi,
try to enable this mode,

Code: Select all

//#define I2C_SPEED 400000L   //400kHz fast mode, it works only with some WMP clones
and remember that WMP and NUNCHUK need 5v not 3.3v. Good luck for your presentation, at this time I´m out of ideas to sort the problem out. 1.7 probably will be the same I dont think that the problem is on the soft at this time, you can see on youtube some BICopters try to ask project owners if they made any changes.

Cheers,
Henrique

PS: Can you post your GUI values or a picture of it?

Re: bi-copter instability

Posted: Fri Oct 28, 2011 2:29 pm
by LuisFCorreia
The fast mode produces even more instability...

I really need to hack more time into it

Re: bi-copter instability

Posted: Mon Oct 31, 2011 10:40 am
by Alexinparis
LuisFCorreia wrote:The fast mode produces even more instability...

I really need to hack more time into it


Hi,
I'm not sure the servo instability is due to a software code.
I would try to use a separate BEC (not those from the ESC) to power properly the servos, with a common ground.

Another thing that make me think your model won't be able to fly: for a bicopter, it's important to tilt 45deg the motors, according to Gary Gress conception. Otherwise, there won't be the needed gyroscopic component to counter the pitch instability.

Re: bi-copter instability

Posted: Mon Oct 31, 2011 2:19 pm
by LuisFCorreia
Hi Alex,

technically, my servos can swing the motors a bit more then 180 degrees (full servo travel).

I've been able to confirm that using one of the servo test programs for the Arduino.

What I really find very strange is that the left servo just twiches and the right servo is tilted forward some 30, 40 degrees.

I'll try to produce some videos of this behaviour tomorrow, as it is a national holiday.

Luis Correia

Re: bi-copter instability

Posted: Tue Nov 01, 2011 1:51 am
by LuisFCorreia
I think there is something fundamentally wrong here.

I have just found out that if I call "computeRC()" in the main loop, the servo position are about 1500 for each side (vertical).
If I don't, then the left servo is set at a twitching pace around 1500 and the right servo is about 1200.

This is with no remote data being fed in at all.

If I fed data, I only see twitching on the left servo and very little movement on the right servo.

As for the received data, I'm filling in these values:

Code: Select all

 
   case 'K': //receive RC data from Bluetooth Serial adapter as a remote
         rcData[THROTTLE] = (Serial.read() * 4) + 1000;
         rcData[ROLL]     = (Serial.read() * 4) + 1000;
         rcData[PITCH]    = (Serial.read() * 4) + 1000;
         rcData[YAW]      = (Serial.read() * 4) + 1000;
         rcData[AUX1]     = (Serial.read() * 4) + 1000;
         Serial.write('K');
      break;


let me know if I'm being a complete dork (which I am, probably)

Re: bi-copter instability

Posted: Tue Nov 01, 2011 2:05 am
by copterrichie
What I would suggest doing is, purchase one of the cheap radio system and get the copter flying. Once it is flying, then you can work out all of the problem with the phone app.

Re: bi-copter instability

Posted: Tue Nov 01, 2011 7:00 am
by PatrikE
I wote for copterrichie...

Start with a basic setup untill you have a perfectly working machine.
It will not fly by it self and and need a bit adjusting before you have everything perfect.

Also have in mind the range and latency with Bluetooth.
what happens if you loose contact?

Can it be the failsafeRoutine who kicks in and causes the servotwitches?
Test to disable the failsafe in config.
Connect the Gui and check if's visible there.

And for testing why not use a dualcommand?
if (AUX1>1500){use serial control data......}
Let your buddy control the radio and can take over at any time.... :o

Re: bi-copter instability

Posted: Tue Nov 01, 2011 10:59 am
by LuisFCorreia
Please explain why a radio system is an option, if the problems I'm experiencing happen without ANY radio control system connected?

(but thanks for the suggestion)

Re: bi-copter instability

Posted: Tue Nov 01, 2011 12:26 pm
by PatrikE
LuisFCorreia wrote:Please explain why a radio system is an option, if the problems I'm experiencing happen without ANY radio control system connected?

(but thanks for the suggestion)


That can be the problem!....

You described someting that sounded like it earlier.
I have just found out that if I call "computeRC()" in the main loop, the servo position are about 1500 for each side (vertical).
If I don't, then the left servo is set at a twitching pace around 1500 and the right servo is about 1200.

This is with no remote data being fed in at all.

If I fed data, I only see twitching on the left servo and very little movement on the right servo.

The system can failure without correcet inputs.

If failsafe is activated and there is no valid input from the radio the system goes in failsafemode.
If you then feed system with Serial data and setting channels after failsafe there can be a conflict.

Make sure to disable failsafe and test without to roul out that.

But that's just my theory...
First get it to fly, then develop..

/Patrik

Re: bi-copter instability

Posted: Tue Nov 01, 2011 2:13 pm
by copterrichie
The reason I suggested purchasing a cheap radio system, is because even a Simplistic copter like a Tricopter is not an easiest tasks to configure. I speak from experience, a bi copter tops the list in complexity. I am using Alex's MultiWiiCopter firmware version 1.7 and it is rock Solid requiring no modifications however I have made a number of changes for my particular modifications to my bicopters. The Copter that you are Attempting to build, the code should work as design. So I suspect there is something within the Bluetooth communication protocol and how it is interfaced with the firmware. In my opinion, the best option is KISS. Start with a cheap radio, get the copter flying, then work on the Bluetooth integration.

Re: bi-copter instability

Posted: Tue Nov 01, 2011 2:53 pm
by zviratko
Without a receiver, MW code will switch to failsafe (activate ACC and start to descend). Or did I miss something here?

Re: bi-copter instability

Posted: Tue Nov 01, 2011 6:24 pm
by LuisFCorreia
I speak from experience, a bi copter tops the list in complexity.


Sadly I now recognize my mistake.

As for the remote control, all I have to say is that: analog systems send pulses with a predefined rate with information for the several channels.
Doing that with Bluetooth is the same thing, sending data over a serial port.

So, other from my own stupidity (which I'm prepared to admit), I can't figure out why I'm failing so miserably.

I've also zeroed out all PID parameters and it no longer twitches, but I also don't see the things I wanted to see :P

Anyway it might well be some latency introduced by the Bluetooth interface, but my project is really ALL about bluetooth, arduino & android.

thanks for all the suggestions and keep them comming.

p.s. no I'm not getting a 'proper' radio setup.

Re: bi-copter instability

Posted: Wed Nov 02, 2011 7:52 am
by zviratko
Yeah, but you're using multiwii code which is built for a classic RX. I don't know how receiver (or loss of signal) is detected, but it did really scary things in my case (when batteries run out, or I disconnected RX signal from MW).

So did you bypass the failsafe in MW code entirely? Normal behaviour is, that once RX is switched off/disconnected, autolevel is activated and failsafe takes over, the same could apply in your case unless you cut it out...

Re: bi-copter instability

Posted: Wed Nov 02, 2011 8:59 am
by LuisFCorreia
Well, for now the problem is not really related to loss of signal, but proper signal interpretation.

It may well be that the serial code isn't called enough times and it misses commands. must investigate the code even more.

Re: bi-copter instability

Posted: Wed Nov 02, 2011 12:24 pm
by PatrikE
I think one problem is that Failsafe is overwriting your serial commands.
So start with to first comment this line in config.

Code: Select all

#define FAILSAFE             // Alex: comment this line if you want to deactivate the failsafe function

Re: bi-copter instability

Posted: Wed Nov 02, 2011 7:38 pm
by LuisFCorreia
PatrikE,

FAILSAFE is already disabled, it must be something else :=)

Luis

Re: bi-copter instability

Posted: Sun Nov 06, 2011 2:06 pm
by PatrikE
Yuo have probably checked that the real serial stream comtains what you expect...
But thats my only id'e right now

Re: bi-copter instability

Posted: Tue Nov 08, 2011 11:18 am
by LuisFCorreia
I've found the root cause!

It was my android app sending in way too much data then the Arduino could cope with.

I'm now sending it in at a 50Hz rate, just like the regular radio systems do.

Now I'm in the tweaking phase, in order to get the thing flyable.

I'm also sensing a new video made today ;)

Re: bi-copter instability

Posted: Wed Nov 09, 2011 12:38 am
by Alexinparis
LuisFCorreia wrote:I've found the root cause!

It was my android app sending in way too much data then the Arduino could cope with.

I'm now sending it in at a 50Hz rate, just like the regular radio systems do.

Now I'm in the tweaking phase, in order to get the thing flyable.

I'm also sensing a new video made today ;)


Fine !
You now have to solve your inline mecanical design ;)
(remember about the need to turn forward 45deg the 2 motors)

Re: bi-copter instability

Posted: Wed Nov 09, 2011 10:15 am
by LuisFCorreia
Alex, about that 45º forward.

My motors are able to do the full 180º swing.

But the expected behaviour on startup is that the motors are vertical on power-on, 90º in relation to the ground, correct?

Re: bi-copter instability

Posted: Mon Mar 12, 2012 6:11 pm
by daws
I am doing something similar where I am using a joystick with pygame to send instructions over an xbee. What values should I be sending? I see you are using one byte for each channel, so I assume that it's 0-255 for each?

So for throttle if I send 0, it will be throttle off and 255 will be full throttle for the first byte? Here's my assumed example with full throttle:

Code: Select all

'K\xff\x00\x00\x00\x00'

Re: bi-copter instability

Posted: Mon Mar 12, 2012 6:25 pm
by daws
Also, can we finish the task and support all the aux channels?

Code: Select all

#ifdef BTSERIAL
    case 'K': //receive RC data from Bluetooth Serial adapter as a remote
      rcData[THROTTLE] = (SerialRead(0) * 4) + 1000;
      rcData[ROLL]     = (SerialRead(0) * 4) + 1000;
      rcData[PITCH]    = (SerialRead(0) * 4) + 1000;
      rcData[YAW]      = (SerialRead(0) * 4) + 1000;
      rcData[AUX1]     = (SerialRead(0) * 4) + 1000;
      rcData[AUX2]     = (SerialRead(0) * 4) + 1000;
      rcData[AUX3]     = (SerialRead(0) * 4) + 1000;
      rcData[AUX4]     = (SerialRead(0) * 4) + 1000;
      break;

Re: bi-copter instability

Posted: Mon Mar 12, 2012 9:47 pm
by daws
I wrote out the full script that will control my quad via xbee from a computer with a joystick. I can't test it till my ESCs and motors come in though.

Code: Select all

#!/usr/bin/env python

import time
from datetime import datetime
import serial

# Allow for multiple joysticks
joy = []

# usbport = '/dev/tty.usbserial-A70064Mh'
usbport = '/dev/tty.usbmodem621'

MIN_PPM = 0
MAX_PPM = 255

AXIS_ROLL = 0
AXIS_PITCH = 1
AXIS_THROTTLE = 3
AXIS_YAW = 2

BUTTON_AUX1 = 0 # Trigger
BUTTON_AUX2 = 1 # Button 2
BUTTON_AUX3 = 2 # Button 3
BUTTON_AUX4 = 3 # Button 4

class ControllerState(object):
    throttle = MIN_PPM
    roll     = MIN_PPM
    pitch    = MIN_PPM
    yaw      = MIN_PPM
    aux1     = MIN_PPM
    aux2     = MIN_PPM
    aux3     = MIN_PPM
    aux4     = MIN_PPM

    def __str__(self):
        return 'Throttle:{0.throttle} Roll:{0.roll} Pitch:{0.pitch} Yaw:{0.yaw} A1:{0.aux1} A2:{0.aux2} A3:{0.aux3} A4:{0.aux4}'.format(self)

    def serial_format(self):
        return 'K' + chr(self.throttle) + chr(self.roll) + chr(self.pitch) + chr(self.yaw) + chr(self.aux1) + \
            chr(self.aux2) + chr(self.aux3) + chr(self.aux4)

    # Joystick Movement
    def handleJoyEvent(self, e):
        # Identify joystick axes and assign events
        if e.type == pygame.JOYAXISMOTION:
            axis = e.dict['axis']
            # Convert -1.0 - +1.0 to 0 - 255
            value = int(e.dict['value'] * (MAX_PPM / 2)) + (MAX_PPM / 2)

            print 'Axis: {}, value: {}'.format(axis, value)

            if axis == AXIS_ROLL:
                self.roll = value
            elif axis == AXIS_PITCH:
                self.pitch = value
            elif axis == AXIS_THROTTLE:
                self.throttle = MAX_PPM - value
            elif axis == AXIS_YAW:
                self.yaw = value

        # Button Presses (toggle)
        elif e.type == pygame.JOYBUTTONDOWN:
            button = e.dict['button']

            print 'Button Down: {}'.format(button)

            if button == BUTTON_AUX1:
                self.aux1 = MAX_PPM if self.aux1 == MIN_PPM else MIN_PPM
            elif button == BUTTON_AUX2:
                self.aux2 = MAX_PPM if self.aux2 == MIN_PPM else MIN_PPM
            elif button == BUTTON_AUX3:
                self.aux3 = MAX_PPM if self.aux3 == MIN_PPM else MIN_PPM
            elif button == BUTTON_AUX4:
                self.aux4 = MAX_PPM if self.aux4 == MIN_PPM else MIN_PPM

        # # Assign actions for Coolie Hat Switch events
        # elif e.type == pygame.JOYHATMOTION:
        #     if (e.dict['value'][0] == -1):
        #         print "Hat Left"
        #         servo.move(4, 0)
        #     if (e.dict['value'][0] == 1):
        #         print "Hat Right"
        #         servo.move(4, 180)
        #     if (e.dict['value'][1] == -1):
        #         print "Hat Down"
        #     if (e.dict['value'][1] == 1):
        #         print "Hat Up"
        #     if (e.dict['value'][0] == 0 and e.dict['value'][1] == 0):
        #         print "Hat Centered"
        #         servo.move(4, 90)

        print self

# Main method
def main():
    with serial.Serial(usbport, 9600, timeout=1) as ser:
        frequency = 1. / 50
        controller_state = ControllerState()

        # Initialize pygame
        pygame.joystick.init()
        pygame.display.init()

        if not pygame.joystick.get_count():
            print "\nPlease connect a joystick and run again.\n"
            quit()
        print "\n%d joystick(s) detected." % pygame.joystick.get_count()
        for i in range(pygame.joystick.get_count()):
            myjoy = pygame.joystick.Joystick(i)
            myjoy.init()
            joy.append(myjoy)
            print "Joystick %d: " % (i) + joy[i].get_name()

        # Run joystick listener loop
        while True:
            poll_started = datetime.now()
            while True:
                e = pygame.event.poll()
                if e.type in (pygame.JOYAXISMOTION, pygame.JOYBUTTONDOWN, pygame.JOYBUTTONUP, pygame.JOYHATMOTION):
                    controller_state.handleJoyEvent(e)
                if e.type == pygame.NOEVENT:
                    break
            poll_ended = datetime.now()
            sleep_time = frequency - ((poll_ended - poll_started).microseconds / 1000000.)

            if sleep_time > 0.:
                time.sleep(sleep_time)
                # print controller_state
                ser.write(controller_state.serial_format())
            write_ended = datetime.now()

            # print 'Loop Time:', (write_ended - poll_started).microseconds

# Allow use as a module or standalone script
if __name__ == "__main__":
    main()




Here's a quick snippet of the results:

Code: Select all

Throttle:0 Roll:127 Pitch:127 Yaw:127 A1:0 A2:0 A3:0 A4:0
Axis: 3, value: 229
Throttle:26 Roll:127 Pitch:127 Yaw:127 A1:0 A2:0 A3:0 A4:0
Button Down: 0
Throttle:26 Roll:127 Pitch:127 Yaw:127 A1:255 A2:0 A3:0 A4:0
Button Down: 1
Throttle:26 Roll:127 Pitch:127 Yaw:127 A1:255 A2:255 A3:0 A4:0
Axis: 1, value: 127
Throttle:26 Roll:127 Pitch:127 Yaw:127 A1:255 A2:255 A3:0 A4:0
Axis: 1, value: 132
Throttle:26 Roll:127 Pitch:132 Yaw:127 A1:255 A2:255 A3:0 A4:0
Axis: 1, value: 137
Throttle:26 Roll:127 Pitch:137 Yaw:127 A1:255 A2:255 A3:0 A4:0
Axis: 0, value: 123
Throttle:26 Roll:123 Pitch:137 Yaw:127 A1:255 A2:255 A3:0 A4:0
Axis: 1, value: 145
Throttle:26 Roll:123 Pitch:145 Yaw:127 A1:255 A2:255 A3:0 A4:0
Throttle:26 Roll:123 Pitch:145 Yaw:127 A1:255 A2:255 A3:0 A4:0
Axis: 0, value: 118
Throttle:26 Roll:118 Pitch:145 Yaw:127 A1:255 A2:255 A3:0 A4:0
Axis: 1, value: 147



Any input would be appreciated

Re: bi-copter instability

Posted: Tue Apr 02, 2013 6:42 pm
by nafix
Sorry to dig up an old thread, but I went down this path too. After many hours, I still cannot achieve flight. Can someone who's gotten this to work provide some tips? I'm using Multiwii 1.7 software. I set up all my board specific defines correctly. I uncomment #BTSERIAL. I change the baudrate to what my xbees are set to (9600 baud). The data is making it inside the serialcom function 'K' switch case (I turn on an led if it gets in there). I've disabled failsafe as well. What else could it be?