samdevolder
Posts: 9
Joined: Thu Nov 03, 2016 2:21 pm

Raspberry pi zero rc control

Thu Nov 03, 2016 2:25 pm

Hey guys,

For my thesis I am making some kind of a zeppelin.
I'm gonna do this with a raspberry pi zero because its weight is so low.
I found some motor controller boards for the zero already.
But i am having trouble on how to rc control the pi zero.
At my university we have dx7 transmitter. (https://www.spektrumrc.com/Products/Def ... Id=SPM2710)
Do you guys have any idea how I receive this signal with my raspberry pi zero ?

Thanks a lot,
Kind regards
Sam Devolder

texy
Forum Moderator
Forum Moderator
Posts: 5161
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Raspberry pi zero rc control

Thu Nov 03, 2016 3:00 pm

Hi,
you'll need to feed the output of the receiver into a GPIO pin of the pin, however the voltage will need level conversion to the 3.3V Pi requirement.
Then you will need to analysis the pulse width of that signal and act upon it.
For every channel you wish to use for you zeppelin......

Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

scotty101
Posts: 3958
Joined: Fri Jun 08, 2012 6:03 pm

Re: Raspberry pi zero rc control

Thu Nov 03, 2016 3:31 pm

Depending on what range you need, you might find it easier to communicate with the Pi Zero via WiFi or Bluetooth.

As texy says, each channel of the RC reciever, outputs a PPM signal which you need to read in. It might be easier to offload the burden to a microcontroller and send that data to the Pi Zero via i2c or SPI.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

PiGraham
Posts: 3971
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Raspberry pi zero rc control

Thu Nov 03, 2016 3:54 pm

samdevolder wrote:Hey guys,

For my thesis I am making some kind of a zeppelin.
I'm gonna do this with a raspberry pi zero because its weight is so low.
I found some motor controller boards for the zero already.
But i am having trouble on how to rc control the pi zero.
At my university we have dx7 transmitter. (https://www.spektrumrc.com/Products/Def ... Id=SPM2710)
Do you guys have any idea how I receive this signal with my raspberry pi zero ?

Thanks a lot,
Kind regards
Sam Devolder
What are you trying to do, make an autonomous airship with manual override? A good starting point would be to use an RC receiver and control it directly at first. That allows you to test flight systems without worrying about code. Have you done that?

If you want to have a manual override there are ways to do that. Basically you want the Rc signals to get through if the Pi fails in any way. A watchdog timer that switched a multiplexer chip is one way. If your code bombs and stops resetting the watchdog the multiplexer will flip over and pass the RC signals.

More risky you could read the RC signals into the Pi (read PWM) and choose on the Pi whether to output those values or your s/w values. If the code crashes so does your ship.

aBUGSworstnightmare
Posts: 2014
Joined: Tue Jun 30, 2015 1:35 pm

Re: Raspberry pi zero rc control

Thu Nov 03, 2016 6:47 pm

samdevolder wrote:Hey guys,

For my thesis I am making some kind of a zeppelin.
I'm gonna do this with a raspberry pi zero because its weight is so low.
I found some motor controller boards for the zero already.
But i am having trouble on how to rc control the pi zero.
At my university we have dx7 transmitter. (https://www.spektrumrc.com/Products/Def ... Id=SPM2710)
Do you guys have any idea how I receive this signal with my raspberry pi zero ?

Thanks a lot,
Kind regards
Sam Devolder
Spektrum satellite receivers have a UART interface at 115kbaud --> connect them to the RPI UART-RX, get some code for decoding the serial channel data and you're done. I would recommend to use AR7700 receiver (http://www.spektrumrc.com/Products/Defa ... =SPMAR7700) - here the SRXL PORT is the one you're interested in - since it has some advantages (comes with a second sat, able to decode up to 20 channels on SRXL).

Here's an example in C how to decode the data (source: AUTOQUAD project, added decoding for additional channels; refer to http://forum.autoquad.org/viewtopic.php ... 387#p35387)

Code: Select all

            
    uint8_t *buf = spektrumData.rawBuf;
    uint8_t ret = 0;
    int addr;
    int val;
    int i;

    // additions for X-Plus channel decoding
    int packetid = 0;

    // check over frame to make sure everything looks legit
    for (i = 0; i < 7; i++) {
        uint8_t *b = &buf[2 + i*2];

        // empty channel
        if (b[0] == 0xff && b[1] == 0xff)
            continue;

        // channels (other than first) should have MSB reset
        if (i != 0 && (b[0] & 0x80) != 0)
            return 0;
    }

for (i = 0; i < 7; i++) {
                uint8_t *b = &buf[2 + i*2];

                // empty channel
                if (b[0] == 0xff && b[1] == 0xff)
                    continue;

                // X-Plus channel - check if first or second data package (MSB only TRUE in channel 0!)
                if (((b[0] & 0x80)>>7) == 1)
                      packetid = 1;     // Channel 12 contains X-Plus channels X+5 to X+8 when transmitted in second package

                addr = (b[0]>>3) & 0x0f;
                val = ((b[0] & 0x07)<<8) | b[1];

                // throttle
                if (addr == (int)p[RADIO_THRO_CH]) 
                    val -= 338;
                else
                    val -= 1024;

                // X-Plus channel decoding
                if (addr == 12) {
                    // check in which packed X-Plus channel was transmitted
                    if (packetid == 1) {                  //  X-Plus channels X+5 to X+8
                        addr = ((b[0]>>1) & 0x03) + 14;
                        val =  ((((b[0] & 0x01)<<8) | b[1]) *2 ) - 512;
                                                          //  correction for +/- range swing and interpolation
                        // clear data package marker
                        packetid = 0;
                    }

                    else {                                //  X-Plus channels X+1 to X+4
                        addr = ((b[0]>>1) & 0x03);
                        if (addr == 0 || addr == 1)
                            continue;                     // X+1 and X+2 are duplicates of channel 10 and 11
                                                          // skip these channels due to lower resolution of 
                                                          // X-Plus channels
                        else {
                            addr += 10;  
                            val =  ((((b[0] & 0x01)<<8) | b[1]) *2 ) - 512;
                                                          //  correction for +/- range swing and interpolation
                        }
                    }
                }

                r->channels[addr] = val;

samdevolder
Posts: 9
Joined: Thu Nov 03, 2016 2:21 pm

Re: Raspberry pi zero rc control

Fri Nov 04, 2016 8:56 am

Hello,

Thanks for all the reactions so fast !

I'm gonna start with wifi/bluetooth to control the motors.
When I am done with this, I am gonne try to make it autonomous.

Do you guys maybe have an idea to let your rasberry pi zero know the height of the balloon ?

Thanks
Kind Regards
Sam Devolder

scotty101
Posts: 3958
Joined: Fri Jun 08, 2012 6:03 pm

Re: Raspberry pi zero rc control

Fri Nov 04, 2016 9:17 am

samdevolder wrote:
Do you guys maybe have an idea to let your rasberry pi zero know the height of the balloon ?
Depends on the level of accuracy that you are looking for.
Sonar - Limited range but cheap. Good for the first few meters off the ground.
Air Pressure - Used by regular aircraft. Again relatively cheap but needs some calibration and is dependant on local weather conditions. Good for detecting big changes in altitude.
Laser - More expensive but very accurate. There are hobby range finding modules.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

aBUGSworstnightmare
Posts: 2014
Joined: Tue Jun 30, 2015 1:35 pm

Re: Raspberry pi zero rc control

Fri Nov 04, 2016 10:08 am

samdevolder wrote: Do you guys maybe have an idea to let your rasberry pi zero know the height of the balloon ?
look at this - https://www.raspberrypi.org/documentati ... /README.md

Sounds like you have little to no idea how to sense orientation/height of an object in space.

PiGraham
Posts: 3971
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Raspberry pi zero rc control

Fri Nov 04, 2016 10:29 am

samdevolder wrote:Do you guys have any idea how I receive this signal with my raspberry pi zero ?
Simplest is probably an air pressure sensor. If you expect long flights you could compensate for weather consitions by measuring air pressure at ground level as well. The difference in pressure will be mostly due to altitude.
The sensors for this are cheap and easy to use.

Another option is GPS

An oldschool option is a theodolite. Sight the ship and read the angle from two known ground positions. Some trigonometry gives you the height of the triangle.

User avatar
DougieLawson
Posts: 39304
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Raspberry pi zero rc control

Fri Nov 04, 2016 6:54 pm

PiGraham wrote: Simplest is probably an air pressure sensor. If you expect long flights you could compensate for weather consitions by measuring air pressure at ground level as well. The difference in pressure will be mostly due to altitude.
The sensors for this are cheap and easy to use.
You need two sensors that have matching calibration. Then relative elevation above your ground datum is easy to calculate with the standard formula.

Code: Select all

import math
print "Elevation:",(44330.0*(1-pow(args.elev/args.datum,1/5.255)))
where args.elev is the pressure reading on the dirigible and args.datum is the pressure reading at your datum point.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

samdevolder
Posts: 9
Joined: Thu Nov 03, 2016 2:21 pm

Re: Raspberry pi zero rc control

Mon Nov 07, 2016 3:56 pm

Hello guys,

I am working on a zeppelin/blimp with a rapsberry pi zero.

Now I am looking for the best motor controller board for this project.
I would like to control 3 or 4 motors, but later when I want to make the project autonomous I want to control some servo motors.
It can also not be to heavy and I would also like to use a ultrasonic sensor on it.
Last point is that I want to control the motor speed by wifi.
Here are the ones I am thinking about.
Picon Zero ( can only control 2 motors... ) http://4tronix.co.uk/store/index.php?rt ... uct_id=552
Zeroborg ( https://www.piborg.org/zeroborg )
Motozero ( https://thepihut.com/products/motozero )
PXFmini (little expensive though) http://erlerobotics.com/blog/product/pxfmini/

Are there other good options ?
It is for on a pi zero.

Thanks !
Sam Devolder

IanS
Posts: 251
Joined: Wed Jun 20, 2012 2:51 pm
Location: Southampton, England

Re: Raspberry pi zero rc control

Mon Nov 07, 2016 5:36 pm

The MotoZero and others like it based on a L293D with no heatsink might be a little too weak for the motors you need. 600mA will not power very much motor. The next step up would be a double L298N board with heatsinks, although obviously the heatsinks add a small extra weight. I have something similar to http://www.ebay.co.uk/itm/L298N-4-Chann ... 2304331186. As well as the control of four DC motors there is a ULN2003A which you can use for on/off control of up to four devices, and a servo motor connection block. For the servos you still need to provide the PWM pulses, but it makes integrating the Vcc and Gnd connections easier. The USB connection is just one of the ways 5V can be supplied to the board, it cannot be used for control. 5V can also come from a wire block connector or from a regulator linked to the motor power supply (which should be over about 7V in that case). Do not link the board to the RPi 5V pin if you use an external supply.
The main drawback with cheap ebay sourced controllers like this (as well as the shipping delay from China) is that they never include instructions, but that just makes it a learning experience!

Return to “Troubleshooting”