VirtualWire support for Raspberry Pi

FS1000A and XY-MK-5V 433MHz RF modules are very often first choice for cheap and dirty Do It Yourself wireless communication. Pair of those , allowing one way radio communication, const less than 3 dollars or euros. So they are really cheap. Limited range and transmission speed limits their real life usage, but simple assembly and extremely easy programming are additional advantage over more complex solutions. Specially in Arduino world, with VirtualWire library. I will not write about it right now, there is enough on the internet already.

FS1000A and XY-MK-5V 433MHz RF modules for Raspberry Pi

Continue reading VirtualWire support for Raspberry Pi

Smartport telemetry for Cleanflight

With their latest transmitters and receivers FrSky changed telemetry protocol. XJT module, Taranis radios, X8R, X4R and X4RSB are using SmartPort telemetry protocol. And that creates few problems. First of all, SmartPort is a serial protocol. That means, flight controller has to have free serial port to connect S.Port device. Second of all, TX and RX lines shares the same wire. The work in half-duplex mode. Third of all, SmartPort signal levels are inverted: logical 0 is in HIGH state, logical 1 is in high state. All of that combined, connecting SmartPort receiver to flight controller and sending telemetry data is not so easy to archive. Specially on FCs without hardware inverters. That applies to most popular STM32F1 devices like Naze32 and Flip32. Not only numer of UARTs there is limited, but also they lack hardare inverters. Of curse, everything is possible and hardware solution for Cleanflight, Naze32 and SmartPort telemetry can be found here.

Luckily, there is simpler solution for Cleanflight that uses SoftSerial and does not require any hardware hacks besides special wire. Requirements:

  • Cleanflight capable flight controller (STM32F1 or STM32F3),
  • SmartPort enabled receiver: FrSky X8R, X6R, X4R, X4RSB,
  • Possibility to enable SoftSerial. Depending on FC type, different fetures like Parallel PWM, Sonar, LED Strip or Current Meter collides with SoftSerial functionality. Check documentation first. In case of Naze32/Flip32 WS2812b LED strips and Parallel PWM can not be used.

Continue reading Smartport telemetry for Cleanflight

Cleanflight 1.12 released

3 days ago, new version of Cleanflight, STM32F1 and STM32F3 flight controller software has been released. I already wrote few words about it a month ago, but final list of changes and improvements is bigger. Main changes are:

  • Looptime sync to gyro readouts, enabled by default (!),
  • New task scheduler,
  • Air Mode. Finally this awesome feature was merged from Betaflight. If you want to know more what Air Mode is, read this article,
  • Failsafe improvements. And what more important, failsafe can now be configured via Cleanflight Configurator. It has its own tab. To use it you will need Cleanflight 1.12 and Configurator 1.2 or newer,
  • MSP telemetry is gone. It’s replaced with LTM telemetry. Important notice: it is not MSP protocol. Only MSP telemetry was removed, not MSP protocol,
  • New hardware targets,
  • Documentation improvements. OK, this is minor, but I had some input there, and I’m quite pride of it!

I did not installed Cleanflight 1.12 on any of my quads yet, so no idea how it behaves. But 3 days without a path means that there should be no problems. Full release notes are available here

LiPo on fire

It is true what internet writes: LiPo batteries can be dangerous. This is how ended one of my buddy’s batteries during indoor FPV session. Small crash, 2 seconds later cloud of white smoke and flames.

Reason was pretty simple. During crash battery got loose and still spinning propeller has cut 2 cells. Good thing, besides dead LiPo, no damage. We were lucky enough to get that thing outside before it damaged quadcopter or got anything else on fire.

LiPo battery on fire

What is Betaflight Air Mode?

Better late than never, so here is mine explanation what is AirMode implemented in Cleanflights fork Betaflight and hopefully soon available also in Cleanflight. Before we will go to any details, please read this to understand how PID controller works. If you know, you might skip it.

In normal flight mode, No Air Mode, flight controller is not using I term from PID controller when throttle stick is low. Why? To make landing nice and easy. It zeroes it. If it would not do it, drone would want to fight pilot attempts to land. That makes sense, right? I term is also not desired during take off. Why? Gyro error might accumulate in I term even before drone takes off, that would result in spinning motors faster and faster (since machine can not correct anything while still on the ground) and in worst case scenario, drone might flip before going into the air. So, zeroing I term on low throttle is good. Or is it not?

Continue reading What is Betaflight Air Mode?

ESC on fire: Multistar 10A v2 BLheli

What happens when your soldering skills are not as good as you thought they were? Well, usually you end up with something burned. That was exactly what happened to me last week. I replaced damaged motor, soldered wires directly to ESC, just like always, and went flying.

First LiPo, everything good. Second LiPo, no problems. Third LiPo, crash, no damage. Fourth LiPo, still no problems. Fifth LiPo, another crash, minor damage: cable tie holding one of ESC broken. I replaced cable tie, put another LiPo, replaced broken prop and attempted to take off. Quad refused to comply, flipped and popped magical smoke. Second later flame appeared. Fire went down only after disconnecting battery. Damage above repair, PCB burned.

Multistar 10A v2 ESC BLheli burned

Multistar 10A v2 ESC BLheli burned

Time for new ESC…

Is PPM Analog or Digital?

Since I am a huge fan of answering questions when they are asked, here is my answer to “Is PPM Analog or Digita?

The easiest way to determine if electrical signal (and PPM in case of RC usage is electrical) is analog or digital is to check how many voltage levels are used. If signal consists of 2 levels, like 5V and 0V, or 3.3V and 0V it is digital. Two states, HIGH and LOW, 1 and 0, digital.

Is PWM Digital or Analog signal

If, however, number of voltages/levels is bigger, it still does not mean that we are dealing with analog signal. Analog signal should be “smooth”. It’s hard to call signal with 3 levels a smooth one. Computers do not work with analog signals. They do not know how to do it. Signals thay can process are always quantified, represented by countable number of bits. Of course, with enough resultion they will appear analog. I’m pretty sure somewhere in The Internet someone is arguing abouth that the very moment you are reading this sentence. I will not participate. If you want to know more about analog and digital, read this article. Bottom line is: with 2 levels, signal is digital.

So, PPM is digital or analog? In case or RC, PPM is a digital signal (or to be more precise digital modulation) that carries/encodes multiple values (channels). Each value (channel) can vary between around 1000 to around 2000. Value of each channel is encoded as number of microseconds between rising and falling edge in specific timeframe associated with this channel number.

Photo: Wikimedia

Damaged motor: broken off magnet

One of the things that can happen to brushless motors, specially outrunners, is broken off magnet. Stronger crash, or even extensive vibrations, can cause one one small magnets located in motors bell to tear off. After all, they are only glued to rotating part of motor.

Symptoms are:

  1. If magnet stays inside motor, it will either rattle, or more probably block motor completely. It will stop spinning, and will not start again. Do not try to force it, it will only get worse,
  2. If magnet will somehow leave motor interior, motor will usually continue to spin. More, multirotor or a fixed wing plane will be flyable. Of course, motor will loose some power, there might be some jerkiness, excess vibrations, but it will keep to rotate.

When case one happens, you can easily see it happened: motor blocked completely or very rattly. Immediately disconnect power, magical smoke is very near. In case two, motor when pushed with finger will spin, but jumpy, like this:

motor jump with lost magnet

Plus, due to weight imbalance, motor will be a source of huge vibrations.

Can I fix a motor with broken off magnet?

Yes, if you have a magnet, it can be glued in place. If it stayed inside motor, you already have it. Just remove shaft clip and pull motor bell. If you have lost broken off magnet, you could get a new one. Maybe to buy it, but better option will be different damaged motor as a donor. The same type of course.

Multistar 2206 2150KV with teared off magnet Continue reading Damaged motor: broken off magnet

Cleanflight 1.12 is coming to town…

Looks like Cleanflight release cycle is speeding up. Last stable version, 1.11.0, was published in the beginning of December 2015, next stable release, 1.12, can appear any day now. Its Release Candidate is available for testing for more than a week now.

So, what can we expect? First of all, bad news: no improved GPS navigation from iNavFlight yet. iNavFlight is not ready and looks like it’s too big to fit all targets, specially F1 processors. So, we will have to wait a while for it. In the meantime, iNavFlight 1.0 RC4 is ready for testing. And it is very promissing. I’ve been able to do only a few test flights on it before winter, but results were very nice.

In Cleanflight 1.12.0 we can expect few quite important new features:

  1. Looptime sync to gyro readouts. This is something that Betaflight users knows very well. No more looptime as we know it. Control loop processes data as soon as it have it from gyros. Approximately every 1000us, since gyro updates with 1kHz frequency. But, that does not mean that we all will be using looptime of 1000. Not all hardware targets with features like GPS have enough computing performance to handle that. This is why CLI command gyro_sync_denom has been introduced. It tells CF every which gyro update control loop should be executed. Value of 1 results of looptime around 1000us, value of 2 give looptime of 2000us and so on. Important note: by default gyro sync is disabled and CLI set gyro_sync=ON command has to be executed to enable it.
  2. Improved task scheduler. Task scheduler in revious versions of Cleanflight was rather simple. This new implementation will allow for better processing of pheripherials like GPS. Users probably will not see much (if any) difference, but this is required for future features like better GPS navigation,

In addition to that: faster computations and better gyro filtering, bugfixes, documentation updates (to which I contributed too) and smaller improvements. See release notes for full list.

Programming ATtiny85 and ATtiny45 with Arduino IDE

What is ATtiny

ATtiny is a fimily of microcontrollers by Atmel, the same company that provides ATmega series used widely in "real" Arduinos. Comparing to ATmega, ATtinys are much simpler, smaller (usually), with less features. But also cheaper, easier to connect, using less energy, and trust me, in many many cases you do not need 32kB of flash memory. If, for example, you want to build a device that will beep every 10 minutes which microcontroller would you use: huge DIP-28 ATmega328P from Arduino UNO R3 or small DIP-8 ATtiny25 that ususes way less power and costs around 1EUR? I would use ATtiny.

ATtiny85 as light sensor with I2C bus

There are many microcontrollers in ATtiny family. In this tutorial and all future in this series I will concentrate on ATtiny85 with 8kB of flash memory. There are 2 simpler versions of it: ATtiny25 and ATtiny45 with respectively 2kB and 4kB of flash, but price difference between them is so small, that I see no point of trying to use them. When buoght from China, it might be even possible to buy ATtiny85 cheaper than its smaller brothers. Continue reading Programming ATtiny85 and ATtiny45 with Arduino IDE