How do I change the Channel values in code?

This forum is dedicated to all issues and questions related to your individual setups and configurations
Post Reply
Spacenaut
Posts: 6
Joined: Fri May 08, 2015 7:12 am

How do I change the Channel values in code?

Post by Spacenaut »

I'm new to this and I'm trying to use multiwii with bluetooth. Rather than connecting the bluetooth to multiwii through ppm, I'd rather have it independent and be able to change the value of the channels (Throttle,yaw,roll,pitch etc) through software but I cant find a way to edit the channel variables. Could someone please help me with this.
Last edited by Spacenaut on Tue May 12, 2015 12:12 am, edited 1 time in total.

Cereal_Killer
Posts: 221
Joined: Fri Mar 06, 2015 5:44 am

Re: How do I change the Channel values in software?

Post by Cereal_Killer »

I'm afraid you're confused about what BT is used for on multiwii...

BT connects to the serial port and is used for configuring / setup / telemetry, no RC data is transmitted from the phone over BT and into the MW. Also there's no way to get a PPM steam out of the BT module.

MaxTakeoff
Posts: 19
Joined: Fri Apr 24, 2015 1:29 pm

Re: How do I change the Channel values in software?

Post by MaxTakeoff »

IIUC you want to use bluetooth to transmit the RC controls, like using a PS3 controller to fly the copter? I think the bluetooth range is only about 30ft, is that going to be a problem for you? If not, I think the default sketch reads the rx information on pins 2,4,5,6 for throttle, ailerons, elevators and yaw, you would have to alter it to instead read the values sent over bluetooth. Sorry, I have quickly reached the edge of my knowledgebase but you probably need to search through the whole sketch to find where the rc inputs are defined.
I just had a quick look in MW version 2.0 that I am gaining familiarity with and found this in the MultiWii_2_0 file,
/*********** RC alias *****************/
#define ROLL 0
#define PITCH 1
#define YAW 2
#define THROTTLE 3
#define AUX1 4
#define AUX2 5
#define AUX3 6
#define AUX4 7

You'd need to follow those variables and see what happens with them but it could be they refer to pin inputs and you need to point them to your BT variables?? Unfortunately, my experience seems to suggest that I could be massively over-simplifying things!

Cereal_Killer
Posts: 221
Joined: Fri Mar 06, 2015 5:44 am

Re: How do I change the Channel values in software?

Post by Cereal_Killer »

I think, if he's dead set on BT control, that he should definitely use PPM, getting individual data streams will be flat out impossible, the BT module just isnt setup for that. It will be a lot easier to get the BT to output PPM data because*, as setup (and as designed). the BT module only has one output (the serial line). The BT chip doesnt support (or even have) 4-6 output pins to utilize...

I just dont think it's possible. What you'd have to do (which is to alter how the BT module works at it's most basic level by changing the serial output to a PPM stream) is somehow hack the BT chip to totally rewrite how it works, as-is they're not designed for what you're wanting to do.

*By easier I still mean with TONS AND TONS OF CODING!

MaxTakeoff
Posts: 19
Joined: Fri Apr 24, 2015 1:29 pm

Re: How do I change the Channel values in software?

Post by MaxTakeoff »

I think there is a fair bit of information around on how to hook up a PS3 controller to an ardino over bluetooth to use as an RC controller, I have seen an article on a guy that connected his tablet to his rc car over bluetooth and was able to steer it by tilting the tablet. Some rxs output a single ppm stream with all the channel data contained within it - from the special receivers section of config.h MW 2.0,
"The following lines apply only for specific receiver with only one PPM sum signal"
So no need for more BT pins, but you might have to find the code for how to generate the ppm signals. If you're comfortable with coding, I don't think tons and tons would be required, but to Cereal_Killer's point, you should decide whether your outcome would be worth all the effort as opposed to simply hooking up a regular tx rx system.

Spacenaut
Posts: 6
Joined: Fri May 08, 2015 7:12 am

Re: How do I change the Channel values in software?

Post by Spacenaut »

What I'm trying to do is find the variable that stores the values for the channels and beable to change them through code rather than the rc pins. If I can figure out that, I can setup a pseudo ppm method of changing them through the bluetooh.

Also, how does the RC inputs work? Is it a PWM or serial signal on each wire. I've tried just having the arduino analog write to a pin and connecting it to the throttle pin(A8) but nothing changes in the gui.

And finally, Im confused with how the pin assignments work. If I change these under the mega types in def.h to the analog pins:

Code: Select all

  #define THROTTLEPIN                62  //PIN 62 =  PIN A8
  #define ROLLPIN                    63  //PIN 63 =  PIN A9
  #define PITCHPIN                   64  //PIN 64 =  PIN A10
  #define YAWPIN                     65  //PIN 65 =  PIN A11
  #define AUX1PIN                    66  //PIN 66 =  PIN A12
  #define AUX2PIN                    67  //PIN 67 =  PIN A13
  #define AUX3PIN                    68  //PIN 68 =  PIN A14
  #define AUX4PIN                    69 //PIN 69 =  PIN A15


Somehow the IMU is controlling AUX4 even though AUX4 should be on A15 and the IMU is on pins 20 and 21.

Cereal_Killer
Posts: 221
Joined: Fri Mar 06, 2015 5:44 am

Re: How do I change the Channel values in code?

Post by Cereal_Killer »

It's neither Seial nor PWM, arduino's analogwrite WILL NOT work. The signal is a form of PPM, it's actually a simple servo signal (that's th basics of how an RC Rx works; it output's a variable duration pulse between 1-2k uSec). The length of the on pulse controls the event.

Do you have a logic analyzer? Are you against the idea of using a stand-alone arduino connected to the BT module as a serial to PPM SUM converter? You could set that up rather easily and then have that second arduino (you could easily use a 168 based mini) decode the bt's serial output into a standard PPM input to the MW Arduino. I think that may be easiest.

Note usually I recommend people not use use arduino based controllers for their multicopters but I think as long as you understand the limits of BT (a sub 50' range) and you plan on only flying small / indoor models it should be ok. Using a second arduino as a PPM decoder is nothing new.

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: How do I change the Channel values in code?

Post by Alexinparis »

Hi,

It's possible to modify RC input directly via a free UART.
There is a specific message in the MSP protocol to do this.
see this project:
viewtopic.php?f=8&t=3101

Post Reply