Sunday, November 19, 2017

Open-Source Drone Developer's Platform

I use this direct-drive, sub-250-gram helicopter for IOT/MQTT research. See attached pictures. 4S 14.8 volts lifts the 249 gram(excluding Raspberry Pi Zero) craft with 2806 sized motor. The fuselage is Blade 230 sized heli(Blade BSR). Tail motor is 1306 sized 3100kv, tail prop is bull-nose cut from a 5040 prop , which produces counter-torque thrust of 33 grams for cruising.

The result is a combination of quad copter and helicopter. The helicopter fuselage is cheaper, at less than 7 dollars including shipping. The quadcopter motors and props are cheaper. The complexity of the system is about the same as a quadcopter with 4 pairs of folding blades. Either this helicopter or DJI Mavic Pro has exactly 16 moving parts of the vehicle. They are the main motor, tail motor, 3 CCPM servos, 2 folding blades, 2 grips, 2 halves of the swashplate, 5 linkage rods. And on the DJI Mavic Pro, they are 4 motors, 4 folding arms, 2 folding blades for each motor. So, the math is 2+3+2+2+2+5 = 16 = 4+4+2x4 .



The cost is about 1 dollar per gram, including shipping cost, break downs in the bottom table. Shipping discount for multiple items from a vendor has been applied. No volume discounts are used. The on-board computer is not included in the calculation.

My goal is to do a Trump tower diving with it, like this video below,
, using the alternative small prop blades noted in the breakdown table to evade authorities. And then the craft can perform military and industrial applications when using the proper prop blades with Raspberry Pi. 


And this setup allows forward compatibility when old helicopter parts run out and future replacements come. In the following picture, the fuselage, swashplate, and anti-rotation bracket are replaced with Blade 230s parts. The trick to allow different sizes of control balls to fit the 180 CFX main grips is at the DFC linkage. The threaded rod and the lower half of the linkage is the servo rod of 230s for 230s swashplate, while the lower attachment is the pitch control attachment of the BSR for BSR swashplate. The helicopters in either configuration look identical in the side view.

Sunday, August 6, 2017

Keeping Your IOT Drone Under 250 Grams


Nothing requiring government registration can become mass consumer product

So are drones. Helicopters offers better hover duration than quads. But, Blade 200S is moving away from the 250 gram realm of Blade 200SRX. Luckily there is a quick fix. Use Blade 200SRX and common quad parts on top of the 200S body. And I reduce it to 236 grams. The weight reduction is 1.7 grams from common quad components tail section, 1.6 grams from home-made ESC-BEC, 3.6 grams from Xtreme 8-degree blades, 3.4 grams from EC2 2mm banana plugs, 2.3 grams from Microheli main shaft, and 2.1 grams from removing battery strap and jacket. The 200S body gains 2.3 grams . CC3D Revo Flight board with FS-A8S receiver make the electronics reduces 0.2 grams weight from stock AR636H +AS3X .
246.6 - 1.6 - 3.4 - 3.6 - 2.3 - 1.7 - 2.1 - 0.2 + 2.3 = 234.0
Comparison to stock components follow,

Modified
256.8 - 22.8(stool) = 234

Stock
202.1 + 68.9(battery) - 24.4(stool) = 246.6
.

Breakdowns of the weight loss

The tail weight is 2.6(fin+screws) + 17.5(motor+mount+wires+screw+prop) + 3.8(boom) + 0.7(female part of 2mm EC2 banana plugs) = 24.6 . The stock tail weight is 1.9 (fin+screws) + 17.9 (motor+mount+wires+prop) + 2.9(boom) + 2.5(support booms) + 0.4 (horizontal fin) + 0.7 (male servo plug not pictured) = 26.3 .
Modified
Stock
The kit has a standalone shaft tightening bolt (upper left corner). But the kid does 
not need prop holder because the push configuration presses prop down.
Stock does not have separate tightening bolt.

Second layer breakdown of the motor+bracket+wires+screw+prop in the tail section follows.






Prop is 0.2 grams lighter in my modification. Motor is also 0.2 grams lighter then stock.

ESC without main banana plugs is 16 - 0.7 = 15.3 . Stock ESC without main banana plugs is 19.4 - 2.5 = 16.9 .




Xtreme blade has hollowed body underneath the decal skin.



EC2 2mm banana plugs is less than 1/3 the weight of stock 3.5mm banana plugs





Carbon fiber main shaft is less than half of stock steel shaft.




Battery strap and jacket removed from stock configuration


New 200S's body gains some weight



Here the retail AR636 is 11.5 . CC3D(8.8)+A8X(2.5) is 11.3 .


. And CC3D settings follow,








. The bug in CC3D prevents me from using vehicle type "FP" fixed-pitch. If I select FP, INPUT in the flight data tab is put in orange, vehicle not flyable.

Sunday, July 16, 2017

C Programming Raspberry Pi MQTT Drone PWM



Drones commonly require real time programming because a split second control delay of a tail rotor can mean 180 degrees difference of a helicopter's heading.  For this reason, flight controller programming is often done with C language on a micro controller, where control logic can be optimized on a per-CPU-instruction basis.

However, a new trend has emerged to use Raspberry Pi Zero as a robotic controller to take advantage of the ubiquitous Linux programming, which the OS hides the underlying custom circuitry of micro controllers and presents the abstract programming interface to the programmers so that a program can be portable between different hardware systems. Adafruit has many tutorials focus on the Python library for the I2C devices. But, again, few resources provide the comprehensive view of the requirement of real time C programming. So, as soon as I found a hint of a C library controlling I2C servos, I have to jump in and test drive its performance.

The solution is https://github.com/Reinbert/pca9685 . Steps I took:
  1. "Burn" SD Card with 2017-06-21-raspbian-jessie-lite.img , which is public downloadable from raspberrypi official site. After first powering on with the "burned" SD, wait for the disk expansion to finish in a few minutes while green LED light busy flashes.
  2. Wire up as the following diagram, 
  3. The usual IP connectivity chores. First thing is to get UART access through USB-FTDI adapter. Raspberry Pi Kernel side needs "enable_uart=1" in /boot/config.txt . To do so, insert the SD in to my PC to mount it .  
  4.  Then try to get IP access. Comment out the wlan entries in /etc/network/interfaces , and replaces it with my AP access credential,
    auto wlan0
    iface wlan0 inet static
    address 192.168.43.5
    netmask 255.255.255.0
    gateway 192.168.43.1
    wpa-ssid "pc36000"
    wpa-psk "A...."
    Then, systemctl enable ssh , and reboot. Once IP SSH access is successful, apt install vim , and comment out the "enable_uart=1" .
  5. apt-get install git-core
    git clone git://git.drogon.net/wiringPi
    cd wiringPi/
    ./build
  6. git clone https://github.com/Reinbert/pca9685.git
    cd pca9685/src/
    sudo make install
  7. cd; mkdir mqtt-pizero
    cd mqtt-pizero
  8. vim servo-check.c ; The content follows,
    #include <pca9685.h>
    #include <stdio.h>

    int calcTicks(float impulseMs, int hertz)
    {
    float cycleMs = 1000.0f / hertz;
    return (int)(4096 * impulseMs / cycleMs + 0.5f);
    }

    int main()
    {
    int fd = pca9685Setup(300, 0x40, 50);
    pca9685PWMReset(fd);

    float millis = 1.5;
    int tick = calcTicks(millis, 50);
    pwmWrite(300, tick);

    while (1)
    {
    delay(1000);
    millis = 1.8;
    tick = calcTicks(millis, 50);
    pwmWrite(300, tick);

    delay(1000);
    millis = 1.2;
    tick = calcTicks(millis, 50);
    pwmWrite(300, tick);
    }
    }
  9. gcc servo-check.c -o servo-check -l wiringPiPca9685 -l wiringPi
  10. apt install i2c-tools
  11. sudo vim /boot/config.txt ;  uncomment the following line,
    dtparam=i2c_arm=on
  12. sudo vim /etc/modules; content follows,
    i2c-dev
    i2c-bcm2708
  13. sudo vim /etc/modules-load.d/modules.conf; content follows,
    i2c-dev
    i2c-bcm2708
  14. sudo sync ; sudo reboot
  15. Once rebooted, check i2c device is at 0x40 by gpio readall ; then cd mqtt-pizero/ ; ./servo-check

Friday, May 19, 2017

Inbound And Outbound Dialings Are "Institutional"


Why are there inbound and outbound boundaries with phones but not with Facebook/Google/Apple voice chats? Can we answer that question by looking at the smallest bits and pieces ourselves? I think so. But, what is the implication behind all these?

OK. In my diagram above, when lines, connections touch, it means they are associated. The purple inbound dialings do not touch any trunk lines, which means the inbound dialings are not associated with any particular trunk line. The orange PBX outbound dialing does not touch any phone line and is not associated with any phone protocol. The PBX outbound dialing, however, does touch SIP trunk line, which means it only goes out on the SIP trunk and not H323 protocol. So, all that means is that an inbound dialing does not care what the outbound trunk or protocol will be; an outbound dialing does not care what the inbound phone or protocol is. This is the essence of the PSTN call leg and the essence of VOIP.
For the green VOIP signal dash lines, the corresponding configs are in pjsip.aor.conf ,
[101]
type=aor

[102]

type=aor
[SIP-to-CUCM]
type=aor
contact=sip:10.1.10.76:5060


, and in ooh323.conf ,
[10.1.10.76]
type=friend
context=from-trunk
host=10.1.10.76
port=1720
[ekiga223]
IP=10.1.10.223
port = 1720
type=peer
context=from-external
. The purple inbound dialings are in extensions_additional.conf ,
[ext-did-0002]
exten => 18001231101,1,Set(__DIRECTION=INBOUND)
exten => 18001231101,n(dest-ext),Goto(from-did-direct,101,1)

exten => 18001231102,1,Set(__DIRECTION=INBOUND)
exten => 18001231102,n(dest-ext),Goto(from-did-direct,102,1)

exten => 18004561203,1,Set(__DIRECTION=INBOUND)
exten => 18004561203,n(dest-ext),Goto(from-did-direct,203,1)
, and outbound dialings are also in extensions_additional.conf
[outrt-1] ; siptrunk
exten => _1800321XXXX,1,Macro(user-callerid,LIMIT,EXTERNAL,)
exten => _1800321XXXX,n,Macro(dialout-trunk,2,${EXTEN:7},,off)

[outrt-2] ; h323trunk
exten => _1800654XXXX,1,Macro(user-callerid,LIMIT,EXTERNAL,)
exten => _1800654XXXX,n,Macro(dialout-trunk,1,${EXTEN:7},,off)

. The FreePBX GUI generates the entire extensions_additional.conf and pjsip_aor.conf . ooh323.conf is entirely manually created. All configurations are downloadable here, https://drive.google.com/file/d/0B2NfHoyfFf1aTWR6QUxQQVhkQWc .
The GUI dialogs are







The voice-vlan enabled router configuration is as  https://drive.google.com/file/d/0B2NfHoyfFf1aNXRhMnJyU01Zb0E .
The CUCM GUI screenshots are 


So, a call leg becomes a proxy in the TCP/IP/HTTP world so that the destination and source phones do not know the IP address of each other. The very definition of protocol proxy. It provides some isolation("does not care") of parts of the network while requiring the border routers to have the insights into the protocol. Speaking of proxy, do you know that this very page you are viewing is a proxy'ed page when you are at blog.mpls-phone.com, which is 34.225.89.249 . The true IP address of the web server is google's blogger web server IP address. That will be yet another posting about the Apache configuration that made the proxy.