Problems with extension port and stabilization

Firmware/software/electronics/mechanics
Post Reply
olaybobby
Beginner
Posts: 2
Joined: Sun Mar 29, 2015 11:52 am

Problems with extension port and stabilization

Post by olaybobby »

Hi, I am now working on Crazyflie 1.0 and I would like to make it as a distress-calling system.
There are 2 questions I am going to arise.

1. I am wondering how can I use the extension ports to control lightening pattern of the LEDs assembled by myself. For example, what is the program controlling the extension ports and which ports should I use.

2. Besides that, my Crazyflie can now fly without using controller when I throw it high. But, it cannot fly stably and it is really easy to lose balance.
I tried to use the code " distributePower(50000, 0, 0, 0); " or " distributePower(50000, eulerRollActual, eulerPitchActual, eulerYawActual); "
How can I do if I want it to fly just like using a controller and give a pure thrust, then, it can fly vertically and stably?

Thank you very much=]
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Problems with extension port and stabilization

Post by arnaud »

Hi olaybobby,

1. There is no program controling the expansion port on Crazyflie 1.0, there are pins available and you have to use them using the STM32 apis (typically it will be GPIOs API in your case). To get started you should try to make a new .c file in the module/src folder. Look at how other modules are implemented: they have a init() function called from system.c.

2. Calling distributePower will set the raw thrust to the motors bypassing the control loops, it is normal that it is not behaving well as a quadcopter is not stable without active stabilization algorithm. You can force an attitude (roll/pitch/yaw) and a thrust in stabilizer.c around https://github.com/bitcraze/crazyflie-f ... zer.c#L197 (the commander is the subsystem that gets data from the ground). For development purpose you can try to modify the python client example ramp.py to set the wanted thrust and attitude for some time. We did some test and controlling the copter with pre-programmed pattern work to some extant and should definitely work for you. See the file escape.py as an example: http://forum.bitcraze.se/viewtopic.php? ... e.py#p7081. That way you can develop the control pattern before modifying the firmware.

BR
olaybobby
Beginner
Posts: 2
Joined: Sun Mar 29, 2015 11:52 am

Re: Problems with extension port and stabilization

Post by olaybobby »

Hi BR,

Thank you for giving me some ideas. For the first question, I can understand I may need to create a .c file to do it. However, I still don't have any idea on where to connect positive and negative levels of the parallel SMD LEDs. And even I looked into the init() of stabilizer.c, I can't really understand how the program connects the hardware with its software. Sorry for my poor knowledge.

As to the second question, I hope that the Crazyflie can still be used even not connecting to the PC client, is modifying escape.py still work? And what I have done is adding some code in stabilizer.c and set different thrusts when the Crazyflie is in different altitude. So, what can I do?

Thank you very much. It is so happy to get your reply=]
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Problems with extension port and stabilization

Post by arnaud »

Hi,

You need to connect the LED to one of the GPIO using a resistor to limit the current. You can find a lot of documentation on the internet about that for example for Arduino: http://arduino.cc/en/Tutorial/Blink. Now depending of the kind of LED you want to use it may be much more complex (power LED needs special circuitry). What you have to do is chosing a GPIO on the expantion boad and connect the LED to it.

For example for driving LED with GPIO look at led.c in the copter source code: https://github.com/bitcraze/crazyflie-f ... /src/led.c. It contains all the code required to setup and set a GPIO from the source code.

As for escape.py it was just a suggestion to help you test your algorithm, eventually you need to implement it in C in the copter by interfacing stabilizer.c (more precisely the *Desired values).
Post Reply