Show Posts
Pages: 1 ... 4 5 [6]
76  Forum 2005-2010 (read only) / Exhibition / Re: Arduino-Controlled RC Transmitter on: August 04, 2010, 02:32:56 pm
Hi sonicj!
Unfortunatly pin 10 is required, as it is the output from the hardware timer. The way I have programmed it it uses both compare registeres to produce the waveform, but yeh final output if from compare b which is hardwired to pin 10.
Sorry.

Chris
77  Forum 2005-2010 (read only) / Exhibition / Re: Arduino-Controlled RC Transmitter on: April 23, 2010, 08:42:17 pm
Hi Ian,

I'm at work at the mo, but when I get home I'll have a shot at re-writing it.

Chris
78  Forum 2005-2010 (read only) / Exhibition / Re: Arduino-Controlled RC Transmitter on: April 22, 2010, 05:42:08 pm
Hi Ian,

At the moment switches 3 and 4 don't do anything. They are there to be used as you like and can be read with get_switch_state(switch number)

At current I am using outputs 0,1,2,3 with 4 used for differential ailerons, but feel free to remap them however you like.
You can use PPM5 and 6 by simply updating the pulse array with the required pulse length in microseconds. Bare in mind that the channels are numbered from 0, not from 1!
[edit]Alternativly you can set the requoired values as a persentage offset from center in the channels array, this might be better as it allows you to use the throw adjustment and reverse functions built into the ouput processor[/edit]

At the moment trims are hard set in the code, as the trims on my current transmitter are mechanical rather than electronic. If you look in the sticks_include.h file you will find the lines:
Code:
int stick_trims[4] = {
  0,0,0,0}; //stick trims
The values used for the trims should be the trim offset from center, as measured by the ADC (which gives values bewteen 0 and 1023)

The stick limits: The range of values is 0 to 1023 as read by the ADC.

To set the throw limits on the servo you can change the OUTPUT_TOP, OUTPUT_CENTER and OUTPUT_BOTTOM values, which are set in microseconds.

With the help of Santiago Saldana I have developed a better exponential function if you need it:
Code:
int expo(float pos, float amount)
{
  pos = pos / 100;
  amount = amount / 100;
  if (amount < 0) {
    float temp = pow((float)pos,(float)(1.0/3.0));
    return (((1-amount)*pos)+((amount*temp)))*100;
  } else {
    return (((1-amount)*pos)+((amount*pow(pos,3))))*100;
  }
}

Any other questions, don't hesitate to post.
I am really pleased that my code is proving usefull.

I am currently working on version 2 of the code, and I will post it as and when.

Chris

[edit]
Oh yeah, I forgot: Where the processing is done on a timer induced loop, if you want to add your own functions to be run automatically then add calls to them in the process_loop() function in the main file, just add them before run_outputs(); if you are setting output values using the channels array or after run_outputs() if you are setting the output values directly to the pulses array
[/edit]
79  Forum 2005-2010 (read only) / Exhibition / Re: Arduino-Controlled RC Transmitter on: April 06, 2010, 07:03:54 am
Sounds good. Let us know how you get on!

Chris
80  Forum 2005-2010 (read only) / Exhibition / Re: Arduino-Controlled RC Transmitter on: March 30, 2010, 07:48:36 am
Quote
Thanks Ian, I will check that out. I don't trust me to get it right first time tho, so I will still make one by hand first, as (so far) it is only single sided.

Chris
81  Forum 2005-2010 (read only) / Exhibition / Re: Arduino-Controlled RC Transmitter on: March 30, 2010, 07:30:48 am
Isn't that just the way it always goes?

I took delivery of some ferric chloride this morning so I am hoping to make the PPM boad in the next few days. Eagle files coming soon! smiley

The new code also includes functions for saving settings to EEPROM and reading them again. It isn't very well documented yet, but it will be soon.

I am currently working on a serial programming interface for it as well, so that you can make changes to the setup without having to re-upload the whole program. As soon as I have done I will upload the new code.

Chris
82  Forum 2005-2010 (read only) / Exhibition / Re: Arduino-Controlled RC Transmitter on: March 30, 2010, 06:46:01 am
Hi Ian,

The missing timer file would certainly explain why is wasn't working!

If your code works then it isn't a hack, it's a solution! smiley-grin

I have re-uploaded my code if you want to give it another go. This is the version that is currently working for me.

http://www.miselph.co.uk/arduino/Version_0_2.zip
83  Forum 2005-2010 (read only) / Exhibition / Re: Arduino-Controlled RC Transmitter on: March 28, 2010, 10:39:12 am
The output should be on pin 10.
Make sure that you have set pinMode(10, OUTPUT); or it won't work.

The chip should be the same, just a different package.

Try running this:

Code:

void setup()
{
   setup_timer();
}


void setup_timer()
{
   TCCR1A = B00110001; // Compare register B used in mode '3'
   TCCR1B = B00010010; // WGM13 and CS11 set to 1
   TCCR1C = B00000000; // All set to 0
   TIMSK1 = B00000010; // Interrupt on compare B
   TIFR1  = B00000010; // Interrupt on compare B
   OCR1A = 20000;
   OCR1B = 10000;

   pinMode(10, OUTPUT);
}

void loop()
{

}

I haven't tested it, but that should output a nice square waveform at 50hz. If it doesn't work then there is an issue with how I have set the timers. The normal way to set the timers is by using statements like:
Code:
TCCR1B = _BV(WGM13) | _BV(CS11);
which allow portability across different chips where the registeres might be slightly different, but according to the data sheet our processors are the same.

Let me know how you get on.
84  Forum 2005-2010 (read only) / Exhibition / Re: Arduino-Controlled RC Transmitter on: March 27, 2010, 06:05:30 pm
Hi Ian,

Hardware mapping:

If you open the sketch and look at the sticks_include.h tab and look at line 21 you sould find:

Code:
int stick_inputs[4] = {0,1,2,3}; //input ports for the sticks

and in switches_include.h on line 6

Code:
int switch_pins[number_of_switches] = {11,12,13,8};

The stick ranges are set in the sticks_include.h file, right at the top.
Code:
const int stick_limits[4][3] = { //stick limits, given as top, center and bottom
  {
    604, 501, 396            }
  ,
  {
    620, 501, 396            }
  ,
  {
    617, 511, 398            }
  ,
  {
    649, 480, 368            }
};

I have also changed the PPM generation timings slightly, they should be:

Code:
#define OUTPUT_TOP 2000 - timer_pause
#define OUTPUT_CENTER 1500 - timer_pause
#define OUTPUT_BOTTOM 1000 - timer_pause
in the output_include.h file

Does that help?
85  Forum 2005-2010 (read only) / Exhibition / Re: Arduino-Controlled RC Transmitter on: March 25, 2010, 02:50:40 pm
Hi Ian,

If you want to use the 16 x 2 LCD as I have you might like the library I have written to control it via a shift register (so it uses less pins smiley ).
All the info, including vero-board layout and library can be found on my blog:

http://cjparish.blogspot.com/

Let me know how you get one with it!

Chris
86  Forum 2005-2010 (read only) / Exhibition / Re: Arduino-Controlled RC Transmitter on: March 25, 2010, 12:54:42 pm
Hi guys!
Thanks for the positive comments.

CrashingDuchman:
The code already includes both dual rates and exponential smiley-grin The exponential isn't brilliant, I need to find a better equation, but it does work.
The sticks are connected to analog pins 0,1,2 and 3 and the switches are connected to pins 8,11,12 and 13 (I didn't use 9 or 10 because they are the output pins from timer1)
As the code stands, switches 0 and 1 are set up to activate the rates on the ailerons and elevators.

Here is a piccit:


In this picture the yellow wires are the switches (my farnell order only arrived this morning, and I haven't got tound to wiring them up) and connecting any one of them to ground changes the switch state. The green leads trailing off to the right are the connection points for the oscilloscope.

I am using the original RF board from the Micron transmitter, which is a sub-board attached to the base of the antenna. However, this required me to use a FET attached to the pulse output pin (pin 10) to create a transistor NOT gate so as to facillitate switching of a higher voltage as the RF board runs at 9.5v

My long(er) term goals for this project include an on-transmitter (or plug in, as my tx case is quite small) lcd display and buttons for changing settings without having to reload the firmware, and upgrading the RF section to 2.4gHz.

I am planning on building this into my Mircon transmitter case, and when I do I will post more pics and upload the eagle schematics.

Chris
87  Forum 2005-2010 (read only) / Exhibition / Re: Arduino-Controlled RC Transmitter on: March 25, 2010, 02:21:10 am
Hi Folks,

I know this is quite an old thread, but I thought you might be interested in this.

I decided to replace the PPM encoder board in my old Micron transmitter that I built from a kit some 15+ years ago with an arduino based solution.

This solution reads the four sticks, along with four switches and encodes them into the appropreate PPM pulse train. I have also included code for v-tail, differential and delta mixing.

The way my code differs from yours is in the way I generate the pulse train: I have used the 16bit timer (timer 1) set to phase and frequency correct PWM to generate the pulse train from an array of values.

The timer settings are:
Code:
  TCCR1A = B00110001; // Compare register B used in mode '3'
   TCCR1B = B00010010; // WGM13 and CS11 set to 1
   TCCR1C = B00000000; // All set to 0
   TIMSK1 = B00000010; // Interrupt on compare B
   TIFR1  = B00000010; // Interrupt on compare B
   OCR1A = timer_framelength;
   OCR1B = timer_pause;

and the ISR code is:

Code:
ISR(TIMER1_COMPA_vect)
{
  if (timer_ptr == number_of_outputs) {
    timer_ptr = 0;  //reset the pointer to 0
    OCR1A = timer_framelength - (timer_accumulator * timer_correction_factor); //calculate the padding
    timer_accumulator = 0;  //set the accumulator to 0
  }
  else {
    OCR1A = (pulses[timer_ptr] + timer_pause) * timer_correction_factor; //set the pulse length
    timer_accumulator += pulses[timer_ptr] + timer_pause; //add the pulse length to the accumulator
    timer_ptr++;  //increment the pointer
  }
}

and the required variables and constants are:

Code:
#define timer_correction_factor 1.09                        //timer correction factor. This is needed if your arduino is too fast or slow, like mine. :(
#define timer_framelength 20000 * timer_correction_factor   //Maximum framelength in counter ticks
#define timer_pause 300 * timer_correction_factor           //Pause between pluses in counter ticks

int timer_accumulator = 0;         //accumulator. Used to calculate the frame padding
int timer_ptr = 0;                 //timer array pointer
int pulses[7];

To generate the pulse train, enter values into the array corrisponding to the channel pulse in micro seconds, so for a 2000 micro seconds pulse enter 2000. The frame padding is calculated automatically.

If anyone would like to take a look at the complete source code, feel free to download it; it's just too big to post here:
http://www.miselph.co.uk/arduino/Version_0_2.zip

I hope this can be of use to someone. When I have finished the project I will post the details on this forum.

If anyone needs any help with timers, I have become quite adept at dealing with them and would be more than happy to help

Chris
88  Forum 2005-2010 (read only) / Exhibition / Re: Arduino RC Transmitter on: April 14, 2010, 05:32:07 am
Ah.... looks like a permissions problem! I'll chmod the files to 777 and re-upload!
89  Forum 2005-2010 (read only) / Exhibition / Arduino RC Transmitter on: April 11, 2010, 06:28:55 pm
Hi Folks,

I have posted bits about this project on here before, but now version 1 is complete I figured it could be added to the exhibition.

I have built a seven channel RC transmitter by creating a new PPM board for my old 35mHz transmitter.




I haven't yet flown with it as I don't currently have a flight worthy aircraft, but I am working on it!

The firmware currently caters for:

    * Four sticks mapped to 4 output channels according to the 'mode' that the flyer uses.
    * Dual rates on elevator and ailerons activated by two of the switches
    * Exponential available (but I am not currently using it)
    * V-tail mixer for coupling elevator and rudder on vtail models
    * Differential ailerons
    * Delta mixing with differential ailerons.
    * Battery voltage sensing with visual level representation using two LED's (red and green)
    * Test mode that sweeps one output channel. Good for range testing on your own!
    * Ability to save the current settings to EEPROM and load them again (not in use yet, but will be soon)
    * Servo reversing
    * Servo center point and end point adjustment

The code can be downloaded here:
http://www.gaffertapeandcableties.co.uk/downloads/Version_1.zip

I have written a blog article on the whole thing is you want to know more
http://www.gaffertapeandcableties.co.uk/?p=4

Chris
Pages: 1 ... 4 5 [6]