Sprinkle

Here’s a quick demo of something I quickly jammed together over the weekend for my Dad. More info to come, along with additional pictures, circuitry, and some proper screenshots

Basically it’s an iOS app to control solenoid valves via a Raspberry Pi over a JSONRPC interface.

Quadcopter Update

It’s been a while since my last quadcopter post – mainly because i’ve been in the UK and didn’t take it with me.

The day that I left for the UK, the new frame that I ordered for the quad arrived.  Every time I upgrade to a new frame, the quad seems to shrink in size.

This new frame has quite a small wingspan, resulting in a downsize in propellors to a smaller 5″ diameter. It does however have a much lower weight footprint. Weighing in at only 58g, it’s 20g lighter than the old frame and has much more room for cable management and a nice place underneath (which I’ve modified) to hold the battery safely during flight.

Overall, I’m pretty happy with the new frame, however do hope it will be wide enough to still be able to freely manoeuvre the quad.

A Brilliant Explanation of PID

DIY Quad Frame

I just ordered a cheap $30 56g lightweight frame off ebay, however, I need something in the mean time to get set up with. Instead of using the ugly and heavy (~250g) wooden frame, I have built this frame from some spare materials I found in the garage.

Next up, I will need to make all the electronic connections and determine where to house the RPi and battery on the quad. I am going to have to now be careful about positioning of the electronics as the entire frame is conductive :S

Here are a couple of picture of the new frame’s construction

Quadcopter Arrived! (Most of it)

Today a majority of the electronic components of my quadcopter arrived. I received an email from the online shop saying that my order had been dispatched today and they included a tracking number. Upon checking the tracking, it turned out it had actually been posted on the 13th and it was “Delivered”. Being curious, I went downstairs, and there it was, a package on my door step. Excellent.

So it was a given I was going to have the rest of the afternoon off study – now that I had a new fun thing to play with.

As I am not building this from a kit, I had ordered all my parts individually and hoping for the best. For someone with such little hobby RC knowledge, google has definitely been my friend.

My package contained:

  • 4x 10A ESC Combo Kits with a 1700Kv motor (not Kilovolts, RPM in K per volt)
  • 1x Lipoly Balance Charger (For charging my Lipoly battery)
  • 1x 2100mAh Lipoly Battery (2S, 30C)
  • 1x Wooden Frame (Only cost $5, thought it would be worthwhile)
  • 3x Different packs of Propellors
  • 1x Power Distribution (Which I stupidly bought the one with the wrong plug)
IMG_0003

The contents of my package, laid out

So, Let’s get started. What on earth do all those numbers mean? I didn’t know – until I started looking them up. So, let me explain the motors to begin with.

Components

Motors

In quadcopters, you really do need to use brushless motors. This allows you to get maximum efficiency. Unfortunately, to run these, you need a ESC (Electronic Speed Controller). This turns a PWM signal into a voltage which is used to drive the motors. Conveniently, I found a kit which included an ESC and a motor of which were of a decent specification. I will cover connecting the ESC to a Raspberry Pi in a later section

Battery & Power

In newer RC, everyone is making the switch to Lipoly (Lithium Polymer) batteries. These are similar to those which are found in your phone – Lithium Ion. Unfortunately, they require a great deal of care when handling. We have seen many mobile phone explosions over the years due to Lithium Ion batteries exploding – This risk is just as, and even more evident in RC using Lithium Polymer batteries. This is due to the risky nature of the batteries. Very high capacity, in a high risk environment. Any puncture or shock to a battery can cause it to explode. See here

The charging process of a Lipoly battery is the same as Li-ion batteries. You will require a special charger. Most modern chargers and batteries have balance plugs, which makes charging safer and simpler. Older technology required you to balance the cells before charging and after charging. Failure to do so could lead to explosion.

Raspberry Pi

I already had a Raspberry Pi, which is great, and I plan to use it to drive the ESC’s, however it needs a source of power. I am contemplating connecting it to the ESC +5v output, however still deciding whether or not this is a good idea.

Propellors

There is so much choice when it comes to propellor choice. I chose 3 different kits each with 3x CCW and 3x CW props. This is required as the opposite rotation of the quad needs to be offset otherwise you will get unwanted yaw. The kits were to the following specs: 1x 7×4.5, 1x 7×6, 1x 6×5.

Other Things To Come

I’m still waiting on the brains of the quad. I still need to receive my I2c Altitude/Barometer/Temperature sensor as well as my I2C Gyro/Magnetometer/Accelerometer. Once they arrive, I will be ready to start writing the software. In the mean time, it’s a matter of assembling the hardware and doing all the connections.

Software

I lied, I actually did start writing some software today. It was only a basic python program to interface with the ESC’s via PWM on the GPIO pins on my Raspberry Pi.

It was a time consuming process learning how to communicate with the ESC’s via PWM. It’s practically undocumented as I suppose this is just a known thing in the Hobby RC world.

Basically to send a speed control to the ESC you need to use Pulse Width Modulation. This is a signal of a square wave. It has two variable parameters; the period and the duty. The period is the frequency and the duty is how long a pulse is to stay high for.

I knew all about how this worked, but had no clue how on earth to communicate within the range the ESC understood. After some light googling, I found out the range around ESC’s PWM signal. A width of 700 – 2000 microseconds is within the working range of a generic ESC.  However the next issue was how to communicate using python using a value of microseconds. I’m lazy, and using math to turn this into a frequency in Hz unfortunate. Instead it turns out Python/RPi.GPIO has a class in PWM for a servo. It lets you set the value of microseconds directly. Awesome. Here’s a snippet of my code:

from RPIO import PWM
import time

max_PWM = 2000
min_PWM = 700

MOTOR_1_PIN = 25

servo = PWM.Servo()
time.sleep(2)

servo.set_servo(MOTOR_1_PIN, max_PWM)
time.sleep(5)
servo.set_servo(MOTOR_1_PIN, min_PWM)

time.sleep(3)
print("Servo Set Up")

while True:
 try:
 print("Enter New PWM Value:")
 ins = int(raw_input())
 servo.set_servo(MOTOR_1_PIN, ins)

 except KeyboardInterrupt:
 break

servo.stop_servo(MOTOR_1_PIN)
PWM.cleanup()

Unfortunately, that didn’t work. After much head scratching I still hadn’t worked out how to calibrate the PWM signal to the ESC.

To do a calibration process, you must turn on the GPIO PWM to the maximum signal, then switch on the ESC, then turn the PWM signal to minimum. After this occurs, you are now ready to start sending it PWM signal.

I modified my program to be more basic and let me give it any value i wished without the broken calibration code

from RPIO import PWM
import time

MOTOR_1_PIN = 25

servo = PWM.Servo()

while True:
 try:
 print("Enter New PWM Value:")
 ins = int(raw_input())
 servo.set_servo(MOTOR_1_PIN, ins)

 except KeyboardInterrupt:
 break

servo.stop_servo(MOTOR_1_PIN)
PWM.cleanup()

To do all this magic with the software I did need to connect everything up, so here are a few images of the current set up

IMG_0005

Breadboarding, connecting GPIO to the ESC via an old IDE cable.

 

IMG_0007

Cheap and nasty wooden frame – soon to be replaced

Anyway, that’s all for now, hopefully much more to come once everything is hooked up and ready to go!

Exams! / New Phone / QuadCopter

Horray, what a brilliant time of year.

Tomorrow I will be sitting my first of many exams in my time at uni. Since finishing High School I haven’t really done any proper study, so sitting down and forcing myself to put pen to paper and practise math is getting a bit frustrating. I’ve found myself procrastinating and somehow doing things that are not study – such as eating…

Anyway, in the midst of procrastination, I have managed to somehow go shopping. (online shopping lol).

Over the weekend I decided I would use my old RaspBerry Pi to create a quadcopter. On Monday I ordered all the parts, such as ESC’s (Electronic Speed Controllers – they convert PWM to a big electric current for the energy sucking motors), Motors, Batteries, and electronic components such as a gyro/accelerometer/magnometer and a barometer/temperature/altitude meter. These will all connect to the RaspBerry Pi via I2C (I squared C).

So far, although I haven’t even recieved anything in the mail, just the process of gathering parts has taught me so much – Mostly in the electronics, like understanding that I won’t be able to get enough power out of using a standard speed control IC chip, and instead will need a ESC to give power to the motors.

As the project continues, I will continue to blog about the progress and all sorts of the things relating to the project. One stage I am particularly looking forward to within the project is developing a PID software to do the balance of the drone.

In other news, I also managed to buy a Galaxy S5. This does mean that I will be ditching my iPhone 5. Bye bye apple. :’)

Picaxe Microcontroller

This week was my last week for the semester at uni. At our last computing lecture our lecturer told us there would be a micro controller question as part of the test. He did state that if we wrote a micro controller emulator in C and shared it, it would be allowed into the test. This is greatly useful for checking machine code during the exam.

I decided I would set about writing up an emulator. I finished the task with no issues. I’m very happy with my emulator (of a fictional microprocessor).

The microprocessor is noted as the “8005” chip. A chip with 256 bytes of memory. It’s got about 17 different instructions. The sorts of programs we have written in machine code for these are amazing, we have written halving functions, as well as wondrous number generators. I’m certainly amazed.

Now, whilst writing the emulator, I remembered I had a picaxe micro controller stored away in my cupboard. I brought it down after I was done and started playing. My interest in this also comes about due to my father wanting to read RS232 data off our solar panel inverter and viewing it on his iPad. This is my challenge tomorrow – this was just the warm up.

I hooked up the picaxe on a breadboard, and wrote a basic program. However it’s made me surprisingly happy. I can control a LED via serial communication from my computer.