Quadcopter sensor questions

Greetings...

trying to create a Quadcopter here and I have many questions about my sensors. I appreciate anything you can say as this project is for my University (paper - the full project will be published in a year) so I need a theoretically knowledge too.

The following quad is a DIY quad and consists of:

4 Emax motors MT2213
4 ESCHobbypower 30A
1 power distribution system
1 battery 3000mah
KK Multicopter FC v5

Graupner mx12 TX and Orona RX
Arduino UNO
4 2m max distance UltraSensors
1 Gyroscope(extra)

the basic IDEA is to make it autonomous. I am thinking to make it autonomous but with a stick in TX from 1 to 0 I can take control. So thats why I need TX RX and FC.

The quad will be moving as the arduino will programmed and when i want to take contorl I use TX RX and the FC. Got it?

Firstly I need information about the ESC. I know that I can give ~40-80 PMW and spin a motor using arduino but what exactly is that value? what exactly is pmw? Also, which is the best way to communicate with the ESC? And what exactly BEC is? Do I need it? thank you in advance. Asap this is answered I can ask more question i hope... :slight_smile:

enjoy and fly! :slight_smile:

I know that I can give ~40-80 PMW and spin a motor using arduino but what exactly is that value? what exactly is pmw?

Maybe google would be more helpful if you spelled the abbreviation correctly - "PWM"

And what exactly BEC is? Do I need it?

Battery Eliminator Circuit. It means you can run the radio gear off the main battery, instead of needing a separate 6V pack.
Do you need a BEC?
You tell us.

Hey,

a ESC (Electronic Speed Controller) is needed to interface with brushless motors since you can't simply apply current to it's phases like you would do with a two phases dc motor.
A brushless motor needs to be controlled with a commutation sequence to make it spin. The faster you go through the steps of the commutation sequence the faster the motor spins. However this works only theoretically. To make it spin smoothly you need to change the step at a certain moment, otherwise the motor would stop and accelerate again, which would cause vibration or worse.

One approach to get the timing wright is to use hall sensors to detect the position of the rotor. The other one, which is used for rc, is to drive the motor with only two phases at a time and use the third to measure the inductance. This technique is called bemf (back electromagnetic force).

So the ESC basically generates the signal for the motors considering the current position of the motor and the desired speed.

The speed can be controlled with a signal, but usually a PPM (Pulse-position modulation) signal is used. Maybe a PWM signal will work too in some cases since PWM and PPM a quite similar (afaik the arduino stepper motor library uses PPM).

What a BEC is was already explained by AWOL. However, I'd like to add that the current from a BEC tends to be jerky and therefore to power the Arduino and the FC another way of transforming the battery voltage should be used.

In case you need to know more, you can write me a pm.

~Josua

The speed can be controlled with a signal, but usually a PPM (Pulse-position modulation) signal is used. Maybe a PWM signal will work too in some cases since PWM and PPM a quite similar (afaik the arduino stepper motor library uses PPM).

No, PPM is used to multiplex several PWM channels between R/C transmitter and receiver.
Howvever, the PWM here is low frequency (50Hz), low duty-cycle (5-10%) servo/ESC control PWM, not the higher frequency (400Hz and up), full range (0-100%) PWM generated by an ESC or an Arduino analogWrite used to drive a motor.

Firstly, @AWOL I dotn know if I need a BEC. Why should I need it? I guess no. My main battery power everything. Actually I find it useless. Please tell me why I am wrong.

Hello can you please tell me if this way of communication is good?

https://github.com/BillyTziv/Jarvis/blob/master/flightController.ino

I mean it is working. I know, but since you know more than me maybe you can see things that I dont. Future problems or maybe there is an easier solution than using the servo lib.

Hey,

using the servo library is the easy solution. It gives you all the hardware abstraction you can expect from a library. The other way would be to write something similar yourself.

However, I don't know if its relevant, but when you need higher resolution (10bit, 16bit) you'll need to write it yourself.

Can I communicate with Distance ultra sensors using servo lib? Currently I am using pulses...but its harded to understand. :/Any ideas?

Can I communicate with Distance ultra sensors using servo lib?

If you mean "can I communicate with ultrasonic distance sensors using the Servo library" then the answer is "no".

So there is only one way of doing that. Ok thank you. So I will use servo lib for ESC Pulses for the UltraSonic sensors.

Maybe you missed one post

"Firstly, @AWOL I dotn know if I need a BEC. Why should I need it? I guess no. My main battery power everything. Actually I find it useless. Please tell me why I am wrong."

can you tell me your opinion please?

So I will use servo lib for ESC Pulses for the UltraSonic sensors.

No, you won't.

"Firstly, @AWOL I dotn know if I need a BEC. Why should I need it? I guess no. My main battery power everything. Actually I find it useless. Please tell me why I am wrong."

You have the hardware there, so if you think you don't need the BEC, that's fine.

No I wont? What? From all the discussion this is what i understood. Can you please make this clear? Which is the best way to communicate with Ultrasonic distance sensors and which with the ESC?!

About the BEC, yes i do. I have the hardware here. However I am not pro, it may can be used in a way that I dont have thought yet. Thats why I am asking you to tell me a case where you can use BEC.

thanks

No I wont? What? From all the discussion this is what i understood. Can you please make this clear?

See reply #8

Thats why I am asking you to tell me a case where you can use BEC.

I thought you were asking where you can use the BEC.
I have no interest whatsoever in using your BEC.

xmarkx:
Thats why I am asking you to tell me a case where you can use BEC.

Maybe it would be more explanatory for you if you knew a bit of history and why BECs came about:

Back in the dark ages of the RC hobby, there would typically be two separate batteries used on the vehicle being controlled. One battery would be for the receiver and the servos, and would typically be a 6 volt battery composed of four alkaline AA batteries (and latter, 5 cell NiCd or NiMh); the other battery was typically larger in size and voltage output, meant to drive the main propulsion motor. Control of speed was either done in an electro-mechanical manner - via a servo switch resistors to control voltage to the motor - think of it as a mechanically switched voltage divider with large resistors - or sometimes a high-wattage potentiometer. Later, electronic PWM controls were introduced.

The problem was that - mainly for electric flight airplanes and helicopters - having two batteries on-board meant that you had to lift extra weight, which cut down on flight time. So some method was needed to convert the higher voltage main battery to a voltage level sufficient for the receiver and the servos (again, generally 6 volts).

Enter the BEC: Simple BECs were simply 7806 linear voltage regulation circuits, not unlike the 5 volt regulator on the Arduino. These weren't the most efficient of devices - plus you had to have heat-sinking and such to be able to handled the needed current of the servos. As technology improved, though, switch-mode BECs became more commonplace; although you can still find el-cheapo linear regulator BECs around, most are of the switch mode variety.

What this meant was that by using a BEC, you could eliminate the second battery, and power everything off the main battery - saving weight and increasing the running time. It brought up it's own issues, though - because as the system was now using a single battery for everything, if the battery got too low - the BEC might not work - and control of the device would be impaired. When that device is an RC airplane or helicopter, you can imagine that would be a bad thing! So, further systems had to be devised to sense this condition, and shut off the main power source while leaving the controls intact. Further improvements were made for audio feedback for the operator of an impending shutdown, among others.

So - you will may certainly need to use a BEC on a quad-copter depending on what you are planning on running on that machine. If it's just a basic quad, then you might not need it at all - depending on the voltage of your main battery, what voltages your radio receiver or whatnot can tolerate, and how large of a voltage drop to your controller system (Arduino or arduino-based, I presume) will be needed - and whether the on-board voltage regulator of that device can handle the drop and any generated heat.

That's something you'll have to figure out.

@cr0sh I appreciate everything you wrote. Now it is 100% clear to me and I fully understand what is going wrong...really thanks for all that stuff mate :slight_smile:

Ok guys can I ask something else? I got a HC-SR04 ultrasonic sensor. Distance is calculated from the duration of the pulse to come back. I saw somewhere

digitalWrite(trigPin, LOW); 
 delayMicroseconds(2); 
 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10); 
 digitalWrite(trigPin, LOW);
 
 duration = pulseIn(echoPin, HIGH);
 
 //Calculate the distance (in cm) based on the speed of sound.
 distance = duration/58.2;

the above is fixed? I mean I must send 2 ms LOW then 10ms HIGH always? Can I change these values? If yes what would be the difference? Also, aftr that he divides duration with 58.2. This is fixed ? How he came up with this number(58.2)?

thank you very much for any answer! I appreciate your time :slight_smile:

I mean I must send 2 ms LOW then 10ms HIGH always?

Read it again.
Those are microseconds, not milliseconds.

Also, aftr that he divides duration with 58.2

It's the round-trip time for a sound wave to travel 1cm (and back) in microseconds, assuming the speed of sound is around 340metres per second.

Thank you for the answer. Ok its microseconds. However I still want to learn if 2 and 10 are fixed values or I can 'play' with them...change them... and what will eb the result if I change them.

Are there any other Ultrasonic sensors that need less than 58.2 to send and get the signal?

However I still want to learn if 2 and 10 are fixed values or I can 'play' with them...change them... and what will eb the result if I change them.

They're the recommended timings so that the microcontroller on the sonar sensor knows you want to initiate a reading. Shortening the timings may still work, but since those are the recommendations, why would you want to play with them?

I just want to know every line of my code so I can easily debug later. Default values are ok, thank you...