Extra inputs for Devo Tx's

More
14 Dec 2015 02:51 #40905 by Cereal_Killer
Replied by Cereal_Killer on topic Extra inputs for Devo Tx's
Can I get a link to what you guys are using as 6-position switches? Is my best option the Taranis replacement one wired as an analog input (it replaces the pot and output's 6 different reaistances) or some other type of rotary switch wired as 6 digital input's?
I'm a new APM user and find myself needing a single 6-position switch so I don't have to use up 3 switches for a mixer.

Taranis X9E | DEVO 10 | Devo U7E | Taranis Q7

What I do in real life: rivergoequestrian.com/

Please Log in or Create an account to join the conversation.

More
14 Dec 2015 15:22 #40917 by Deal57
Replied by Deal57 on topic Extra inputs for Devo Tx's
In post 37361 (page 6 of this thread) I listed the FRSKY 6-position switch, and I've included it in my external controller add-on.

Honestly I don't use it. With APM, I tend to move between three or four modes in a given flight and the transition isn't always linear. So if I have to go to RTL right now, I don't want to overshoot or miss the setting mark. I'm very comfortable with the two switch approach.

Deviation Devo7e 3way switch mod, A7105, NRF24L01
Devo6s 2x2 switch mod, trim mod, haptic, multimodule, A7105, NRF24L01, CC2500
Devo12e 4-in-1 with voice mod -- it speaks!!

Please Log in or Create an account to join the conversation.

More
15 Dec 2015 05:40 #40943 by Richard96816
Replied by Richard96816 on topic Extra inputs for Devo Tx's

Deal57 wrote: In post 37361 (page 6 of this thread) I listed the FRSKY 6-position switch, and I've included it in my external controller add-on.

Honestly I don't use it. With APM, I tend to move between three or four modes in a given flight and the transition isn't always linear. So if I have to go to RTL right now, I don't want to overshoot or miss the setting mark. I'm very comfortable with the two switch approach.


Seems like a 6-position switch should have some extra debouncing. Perhaps a full second or so in a new position before the change takes effect. Or you could use some sort of trigger or detent to signal that the new position has been verified.

Please Log in or Create an account to join the conversation.

More
15 Dec 2015 12:32 #40953 by Deal57
Replied by Deal57 on topic Extra inputs for Devo Tx's
The switch itself wasn't really the problem for me; I just had trouble remembering which stop meant which mode. When I added six LEDs to indicate the mode, the results were much better! But at the same time I added a bank of six buttons and the overall user experience was so much better.

It seems that the rotary switch is used by a lot of people, so I don't mean to dismiss it; it's just that alternative buttons and better feedback overshadow the rotary's effectiveness.

Deviation Devo7e 3way switch mod, A7105, NRF24L01
Devo6s 2x2 switch mod, trim mod, haptic, multimodule, A7105, NRF24L01, CC2500
Devo12e 4-in-1 with voice mod -- it speaks!!

Please Log in or Create an account to join the conversation.

More
05 Feb 2016 01:30 #42608 by yoodog
Replied by yoodog on topic Extra inputs for Devo Tx's
Hey people! I might give it a second live, but I do not believe my case has been touched here... I'm not as far advance as some are here, but here is my situation.
- I have devo 8s with latest deviation FW. (stable)
- I'm have taken a part my UHF radio and connected it internally to trainer port, (PPM-in is NONE, Protocol is PPM - this gives me 10 channels instead of 8) nice and clean


Now I need
- 6 position switch(knob would work)
- additional joystick

My questions:
- Can I switch one of the unused 2-way (or 3-way if it matters) switches for this 6point knob? Any manual on wiring it?? - the goal is to use one channel for all 6 flight modes on pixhawk

- Can I disconnect two 2-way switches (or trims??) and rewire them into a analog joystick ([url=http://http://www.banggood.com/PS2-Game-Joystick-Module-For-Arduino-p-76465.html]PS2 joystick[/url] for example?) or am I miss understanding it?


I know that is not exactly adding channels, but it will free my a channel and keep according with KISS (keep it stupidly simple)
Hope some one can help, need to put order soon...

Please Log in or Create an account to join the conversation.

More
05 Feb 2016 08:52 #42619 by mwm
Replied by mwm on topic Extra inputs for Devo Tx's
This thread is about using the existing PPM input to add extra inputs to any deviation transmitter. I'm not sure you can do that and still used the PPM out, but my gut says no. Possibly someone on this thread had done it, though.

One thing about this is that it doesn't replace any of the switches or inputs on the transmitter. Well, it doesn't have to. You could reuse the mounting points, but you don't need the electrical connections - the extra inputs go to a microcontroller that translates them to PPM to input into deviation.

You can already used one channel for all six flight modes on pixhawk. There are a number of threads about programming that with a 2-way and a 3-way switch.

Your link to the joystick is broken. If it's a four or five position joystick (that is, it uses switches and not real analog inputs) you could wire it's four switches up to the four switches in the two extra trims on the 8, but I suspect that wouldn't provide a good experience. That's the only thing you've mentioned that could work without a custom build of deviation, though.

Do not ask me questions via PM. Ask in the forums, where I'll answer if I can.

My remotely piloted vehicle ("drone") is a yacht.

Please Log in or Create an account to join the conversation.

More
09 Feb 2016 03:36 #42819 by Cereal_Killer
Replied by Cereal_Killer on topic Extra inputs for Devo Tx's
Hi again, exploring the add-on arduino option on my new-to-me 10, if I can get the functionality improvements [for APM] You're talking about I'd like to jump on that for this flying season (you're all right, the mixing on analog switches for APM flight modes is a PITA!)

Can you share the arduino sketch in which you use the 6 switches for flight modes and use the oled to display the currently selected mode?
Thanks!

Epyon wrote:

Cereal_Killer wrote: Off topic but where can I read about the OLED / get code for it?


Just search for "ssd1306", that's the driver chip most used. You can get displays that run I2c and/or SPI. Depending on the particular display (there are many, many clones) you may need to change the I2c address.
I'm using a library from Adafruit. Makes it real easy. learn.adafruit.com/monochrome-oled-break...library-and-examples
The library will work as-is with the 128x64 or 128x32 displays, I2C or SPI. I've also got a 64x48 (tiny!) display to run off the library by altering it a little. Also dabbled with the U8glib library.


Taranis X9E | DEVO 10 | Devo U7E | Taranis Q7

What I do in real life: rivergoequestrian.com/

Please Log in or Create an account to join the conversation.

More
09 Feb 2016 07:04 #42827 by Epyon
Replied by Epyon on topic Extra inputs for Devo Tx's

Cereal_Killer wrote: Hi again, exploring the add-on arduino option on my new-to-me 10, if I can get the functionality improvements [for APM] You're talking about I'd like to jump on that for this flying season (you're all right, the mixing on analog switches for APM flight modes is a PITA!)

Can you share the arduino sketch in which you use the 6 switches for flight modes and use the oled to display the currently selected mode?
Thanks!


This isn't quite my current sketch, I switched to an 8-way rotary switch now. This, I believe, was the most refined with the 6-way. It's also before I had the voltage/current sensor and Real Time Clock installed, so there's some non-functional display elements for the OLED.
// Devo 7e PPM input
// For use with Arduino Nano V3.0
// Based on sketch by Ian Johnston

#include <Wire.h>
#include <TimerFreeTone.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 display(0);

// Analog pin assignments
int AI_Pin_A1 = 2;
int AI_Pin_A2 = 3;
int AI_Pin_A3 = 6;
int AI_Pin_A4 = 7;
int AI_Raw_A1;        // Analog In raw variable - 0->1023....
int AI_Raw_A2;
int AI_Raw_A3;
int AI_Raw_A4;
int A1_uS = 750;      // Potentiometer - left BIG knob
int A2_uS = 750;      // Potentiometer - left small knob
int A3_uS = 750;      // Potentiometer - right small knob
int A4_uS = 750;      // 6-way switch
int sw1_uS = 750;     // 3-way switch #1 - right side
int sw2_uS = 750;     // 2-way switch - left side
int sw3_uS = 750;     // 3-way switch #2 - left side
int sw4_uS = 750;     // 3-way switch #3 - right side inner

int Fixed_uS = 300;   // PPM frame fixed LOW phase

// Digital pin assignments
int LEDpin0 = 0;        // Blue LED 1
int LEDpin1 = 1;        // Blue LED 2
int outPinPPM = 10;     // PPM out
int TonePin = 13;       // Piezo buzzer
int inPinD2 = 2;        // 3-way switch #1 right-side sideways
int inPinD3 = 3;
int inPinD4 = 4;        // 2-way switch left-side
int inPinD6 = 6;        // 3-way switch #2 left-side inner
int inPinD7 = 7;
int inPinD8 = 8;        // Bottom right-side momentary button
int inPinD9 = 9;        // Top right-side momentary button
int inPinD11 = 11;      // Booster high power
int inPinD12 = 12;      // Booster low power
int BoosterPin = 5;     // Booster trigger
int inPinA0 = A0;       // 3-way switch #3 right-side inner
int inPinA1 = A1;

// 6-way rotary switch debounce
int DB_uS = 750;
int Last_us = 750;
long lastDebounceTime = 0;
long debounceDelay = 200;

// Flight mode beeps
boolean fBeep1 = false;
boolean fBeep2 = false;
boolean fBeep3 = false;
boolean fBeep4 = false;
boolean fBeep5 = false;
boolean fBeep6 = false;

// Switch beeps
boolean Beep1 = false;
boolean Beep2 = false;
boolean Beep3 = false;
boolean Beep4 = false;
boolean Beep5 = false;
boolean Beep6 = false;
boolean Beep7 = false;
boolean Beep8 = false;
boolean Beep9 = false;
boolean Beep10 = false;
boolean Beep11 = false;
boolean Beep12 = false;
boolean Beep13 = false;
boolean Beep14 = false;

// Clock
int ColonBlink = 1;      // Blinking colon
String Hours = (" "); 
String Minutes = (" "); 
String AM_PM = (" ");

// OLED text display variables
int Model = 1;       // Model#
int TwoDMode = 1;    // 2D Mode animated icon
int RTH = 1;         // Return to home scroll
int CenterStick = 1; // Center stick scroll
int Flip = 1;        // 3D/Acro Mode animated icon
int CartScroll = 1;  // Cartesian Mode scroll
int BatSwitch = 1;   // Battery/Current switch
int BoosterOff = 1;  // Blinking OFF
String Battery = (" "); 
String Current = (" ");
String BatCur = (" ");
String Colon = (" ");
String Alert = (" ");
String Booster = (" ");
String fMode1 = (" ");
String fMode2 = (" ");
String fMode3 = (" ");
String fMode4 = (" ");
String fMode5 = (" ");
String fMode6 = (" ");

const unsigned char PROGMEM Deviation [] = {
0x00, 0x07, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x03, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x18, 0x80, 0x00, 0x1C, 0x0C, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x1C, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x1C, 0x0B, 0x80, 0x00, 0x00, 0x80, 0x00,
0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x1C, 0x0B, 0x80, 0x00, 0x00, 0x80, 0x00,
0x00, 0x03, 0x80, 0x00, 0x01, 0x00, 0x0D, 0x00, 0x00, 0x1C, 0x05, 0x80, 0x00, 0x00, 0x80, 0x00,
0x00, 0x03, 0x80, 0x00, 0x02, 0x1E, 0x00, 0x00, 0xE0, 0x1F, 0xF0, 0x00, 0x00, 0x01, 0x80, 0x00,
0x00, 0x03, 0x80, 0x00, 0x06, 0x3F, 0x00, 0x01, 0xF8, 0x1F, 0x80, 0x00, 0x00, 0x01, 0x87, 0x00,
0x00, 0x03, 0x80, 0x7C, 0x0E, 0x63, 0x9F, 0xE3, 0x3C, 0xFC, 0x0F, 0xF0, 0x7C, 0x03, 0x8F, 0x80,
0x01, 0xFB, 0x00, 0xCE, 0x3C, 0xFD, 0x9F, 0x02, 0x1C, 0xD8, 0x0F, 0x80, 0xDE, 0x0F, 0x99, 0xC0,
0x03, 0xFF, 0x01, 0x87, 0x7C, 0xD5, 0xC6, 0x06, 0x1C, 0x18, 0x07, 0x01, 0xB7, 0x01, 0xB0, 0xE0,
0x07, 0x8F, 0x03, 0x03, 0xFC, 0xE5, 0xC6, 0x07, 0x9C, 0x18, 0x07, 0x03, 0x53, 0x81, 0xE0, 0x70,
0x0F, 0x07, 0x03, 0x63, 0x9C, 0xFD, 0xC6, 0x0F, 0xDC, 0x18, 0x07, 0x03, 0x79, 0x81, 0xC0, 0x70,
0x1E, 0x03, 0x07, 0xF1, 0x8E, 0x79, 0xC6, 0x0F, 0xDC, 0x18, 0x07, 0x06, 0x79, 0xC1, 0xC0, 0x78,
0x1E, 0x03, 0x07, 0xB1, 0x8E, 0x31, 0xC6, 0x0E, 0xDC, 0x18, 0x03, 0x0E, 0x78, 0xC1, 0xC0, 0x38,
0x3C, 0x03, 0x0F, 0xB3, 0x06, 0x01, 0xC6, 0x06, 0x9C, 0x18, 0x03, 0x0E, 0x70, 0xE1, 0x80, 0x38,
0x3C, 0x03, 0x0E, 0xE6, 0x07, 0x01, 0x86, 0x03, 0x1C, 0x30, 0x03, 0x0E, 0x00, 0xE1, 0x80, 0x38,
0x3C, 0x03, 0x0E, 0x7C, 0x07, 0x01, 0x06, 0x00, 0x18, 0x30, 0x03, 0x0E, 0x00, 0xE1, 0x80, 0x38,
0x3C, 0x03, 0x0E, 0x00, 0x03, 0x03, 0x06, 0x00, 0x18, 0x30, 0x03, 0x0E, 0x00, 0xE1, 0x80, 0x38,
0x3C, 0x3B, 0x0E, 0x00, 0x03, 0x02, 0x06, 0x00, 0x30, 0x30, 0x03, 0x0E, 0x00, 0xE1, 0x80, 0x38,
0x3C, 0xFF, 0x0E, 0x0E, 0x03, 0x86, 0x06, 0x07, 0xF0, 0x33, 0x83, 0x0E, 0x00, 0xC1, 0x80, 0x30,
0x3E, 0xF7, 0x0E, 0x1F, 0x01, 0x84, 0x06, 0x0F, 0x20, 0x36, 0xC3, 0x06, 0x00, 0xC1, 0x80, 0x30,
0x1E, 0x97, 0x07, 0x13, 0x01, 0x8C, 0x06, 0x1E, 0x20, 0x37, 0xC3, 0x06, 0x01, 0x81, 0x87, 0x20,
0x0F, 0xF7, 0x03, 0x1D, 0x00, 0x98, 0x06, 0x1E, 0x60, 0x36, 0xC3, 0x03, 0x01, 0x81, 0x8D, 0x20,
0x07, 0x07, 0x03, 0x9D, 0x00, 0xD0, 0x06, 0x1E, 0x40, 0x30, 0xC3, 0x03, 0x83, 0x01, 0x8F, 0x40,
0x03, 0xFB, 0x01, 0xC3, 0x00, 0xF0, 0x06, 0x1F, 0xC0, 0x10, 0xC3, 0x01, 0xC6, 0x01, 0x8C, 0xC0,
0x01, 0xF1, 0x80, 0xFE, 0x00, 0x60, 0x07, 0xCF, 0x40, 0x0F, 0x83, 0xC0, 0x7E, 0x07, 0xC7, 0x80,
0x00, 0x00, 0x80, 0x3C, 0x00, 0x40, 0x1F, 0xC0, 0x40, 0x07, 0x0F, 0xC0, 0x3C, 0x07, 0x83, 0x00
};

const unsigned char PROGMEM Flip1 [] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x1F, 0x20, 0x04, 0x27, 0xE4,
0x1F, 0xF8, 0x08, 0x10, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

const unsigned char PROGMEM Flip2 [] = {
0x00, 0x20, 0x00, 0x20, 0x00, 0xE0, 0x05, 0x20, 0x03, 0x20, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80,
0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x03, 0x20, 0x05, 0x20, 0x00, 0xE0, 0x00, 0x20, 0x00, 0x20
};

const unsigned char PROGMEM Flip3 [] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x08, 0x10, 0x1F, 0xF8,
0x27, 0xE4, 0x20, 0x04, 0xF8, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

const unsigned char PROGMEM Flip4 [] = {
0x04, 0x00, 0x04, 0x00, 0x07, 0x00, 0x04, 0xA0, 0x04, 0xC0, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80,
0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x04, 0xC0, 0x04, 0xA0, 0x07, 0x00, 0x04, 0x00, 0x04, 0x00
};


ISR(TIMER1_COMPA_vect) {
    ppmoutput(); // Jump to ppmoutput subroutine
}

////////////////////////// Setup //////////////////////////////////
void setup() {
//  Serial.begin(9600);
  
  pinMode(outPinPPM, OUTPUT);       // Sets the digital pin as output
  pinMode(LEDpin0, OUTPUT);
  pinMode(LEDpin1, OUTPUT);
  pinMode(BoosterPin, OUTPUT);      // Sets digital pin as output for booster trigger
  pinMode(inPinD2, INPUT_PULLUP);   // Set the digital pin as input & turn on pull-up resistor
  pinMode(inPinD3, INPUT_PULLUP);
  pinMode(inPinD4, INPUT_PULLUP);
  pinMode(inPinD6, INPUT_PULLUP);
  pinMode(inPinD7, INPUT_PULLUP);
  pinMode(inPinD8, INPUT_PULLUP);
  pinMode(inPinD9, INPUT_PULLUP);
  pinMode(inPinD11, INPUT_PULLUP);
  pinMode(inPinD12, INPUT_PULLUP);
  pinMode(inPinA0, INPUT_PULLUP);  // Sets analog pin as digital input
  pinMode(inPinA1, INPUT_PULLUP);
  
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // Initialize OLED with the I2C address 0x3C
  
  display.setRotation(2); // Flip OLED 180 degrees
  
// Splash screen
  display.clearDisplay();
  display.drawBitmap(0, 0, Deviation, 128, 32, 1);
  display.display();
  delay(1800);
  display.clearDisplay();

// PPM 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 = 22000; // 22mS PPM output refresh
  OCR1B = 1000;
  
// Jump to Model select subroutine
  ModelSelect();
}

void setRotation(uint8_t rotation);

// Model selection subroutine
void ModelSelect() {
 while ((digitalRead(inPinD8) == 1) && (digitalRead(inPinD9) == 1)) {
   TimerFreeTone(TonePin, 2500, 200);
   display.setTextSize(2);
   display.setTextColor(WHITE);
   display.setCursor(0,0);
   display.println("  Choose     model");
   display.display();
 }
 if (digitalRead(inPinD8) == 0) {
   TimerFreeTone(TonePin, 3000, 100);
   display.clearDisplay();
   display.setTextSize(2);
   display.setTextColor(WHITE);
   display.setCursor(0,4);
   display.println("JUPITER X3");
   display.display();
   Model = 1;
   delay(800);
 }
 if (digitalRead(inPinD9) == 0) {
   TimerFreeTone(TonePin, 3000, 100);
   display.clearDisplay();
   display.setTextSize(2);
   display.setTextColor(WHITE);
   display.setCursor(0,4);
   display.println("M250-C30");
   display.display();
   Model = 2;
   delay(800);
 }
 
if (Model == 1) {
  fMode1 = ("2D MODE");
  fMode2 = ("Center Stick Mode");
  fMode3 = ("3D MODE");
  fMode4 = ("Cartesian");
  fMode5 = ("Loiter");
  fMode6 = ("Return To Home");
}
if (Model == 2) {
  fMode1 = ("Rates/PIDs");
  fMode2 = ("Stability1");
  fMode3 = ("Stability2");
  fMode4 = ("Rate Mode1");
  fMode5 = ("Rate Mode2");
  fMode6 = ("ACRO");
}
}

// PPM output subroutine
void ppmoutput() {

 // Channel 1 - Analog 1
  digitalWrite(outPinPPM, LOW);
  delayMicroseconds(Fixed_uS);    // Hold
  digitalWrite(outPinPPM, HIGH);
  delayMicroseconds(A1_uS);       // Hold for A1_uS microseconds      

 // Channel 2 - Analog 2
  digitalWrite(outPinPPM, LOW);
  delayMicroseconds(Fixed_uS);    // Hold
  digitalWrite(outPinPPM, HIGH);
  delayMicroseconds(A2_uS);       // Hold for A2_uS microseconds

 // Channel 3 - Analog 3
  digitalWrite(outPinPPM, LOW);
  delayMicroseconds(Fixed_uS);    // Hold
  digitalWrite(outPinPPM, HIGH);
  delayMicroseconds(A3_uS);       // Hold for A3_uS microseconds
 
 // Channel 4 - Analog 4
  digitalWrite(outPinPPM, LOW);
  delayMicroseconds(Fixed_uS);    // Hold
  digitalWrite(outPinPPM, HIGH);
  delayMicroseconds(A4_uS);       // Hold for A4_uS microseconds 

// Channel 5 - 3-way switch #1
  digitalWrite(outPinPPM, LOW);
  delayMicroseconds(Fixed_uS);    // Hold
  digitalWrite(outPinPPM, HIGH);
  delayMicroseconds(sw1_uS);     // Hold for sw1_uS microseconds 

// Channel 6 - 3-way switch #2
  digitalWrite(outPinPPM, LOW);
  delayMicroseconds(Fixed_uS);    // Hold
  digitalWrite(outPinPPM, HIGH);
  delayMicroseconds(sw2_uS);     // Hold for sw2_uS microseconds
  
// Channel 7 - 3-way switch #3
  digitalWrite(outPinPPM, LOW);
  delayMicroseconds(Fixed_uS);    // Hold
  digitalWrite(outPinPPM, HIGH);
  delayMicroseconds(sw3_uS);     // Hold for sw3_uS microseconds
  
// Channel 8 - Right-side momentary buttons
  digitalWrite(outPinPPM, LOW);
  delayMicroseconds(Fixed_uS);    // Hold
  digitalWrite(outPinPPM, HIGH);
  delayMicroseconds(sw4_uS);     // Hold for sw4_uS microseconds

// Synchro pulse
  digitalWrite(outPinPPM, LOW);
  delayMicroseconds(Fixed_uS);    // Hold
  digitalWrite(outPinPPM, HIGH);  // Start Synchro pulse
}

///////////////////////// Main loop /////////////////////////////////
void loop() {
  display.clearDisplay();

 // Read analog pins
   AI_Raw_A1 = analogRead(AI_Pin_A1);
   AI_Raw_A2 = analogRead(AI_Pin_A2);
   AI_Raw_A3 = analogRead(AI_Pin_A3);
   AI_Raw_A4 = analogRead(AI_Pin_A4);
   
 // Map analog inputs to PPM rates for each of the channels
   A1_uS = AI_Raw_A1 + 625;
   A2_uS = AI_Raw_A2 + 625;
   A3_uS = AI_Raw_A3 + 625;

 // Potentiometer limits
  if (A1_uS <= 750) A1_uS = 750;     // Min
  if (A1_uS >= 1625) A1_uS = 1625;   // Max   
  if (A2_uS <= 750) A2_uS = 750;
  if (A2_uS >= 1625) A2_uS = 1625;
  if (A3_uS <= 750) A3_uS = 750;
  if (A3_uS >= 1625) A3_uS = 1625;

///////////////// 6-way switch//////////////////
// Analog corrections
if (AI_Raw_A4 <= 150) {
    DB_uS = 750;
}
if ((AI_Raw_A4 >= 170) && (AI_Raw_A4 <=230)) {
    DB_uS = 910;
}
if ((AI_Raw_A4 >= 245) && (AI_Raw_A4 <= 270)) {
    DB_uS = 1120;
}
if ((AI_Raw_A4 >= 325) && (AI_Raw_A4 <= 360)) {
    DB_uS = 1330;
}
if ((AI_Raw_A4 >= 470) && (AI_Raw_A4 <= 550)) {
    DB_uS = 1380;
}
if (AI_Raw_A4 >= 750) {
    DB_uS = 1625;
}
///////////////////Debounce////////////////////////////////////
 int Debounce_us = DB_uS;

  if (Debounce_us != Last_us) {
     lastDebounceTime = millis();
  } 
  if ((millis() - lastDebounceTime) > debounceDelay) {
    A4_uS = Debounce_us;
  }
///////////////////////////////////////////////////////////////

// Position 1
  if (A4_uS == 750) {
    Alert = fMode1;
   if (Model == 1) {
    switch (TwoDMode) {
     case 1:
      display.drawBitmap(100, 20, Flip1, 16, 16, 1);
      TwoDMode = 2;
      break;
     case 2:
      display.drawBitmap(102, 18, Flip1, 16, 16, 1);
      TwoDMode = 3;
      break;
     case 3:
      display.drawBitmap(100, 16, Flip1, 16, 16, 1);
      TwoDMode = 4;
      break;
     case 4:
      display.drawBitmap(102, 14, Flip1, 16, 16, 1);
      TwoDMode = 5;
      break;
     case 5:
      display.drawBitmap(100, 12, Flip1, 16, 16, 1);
      TwoDMode = 6;
      break;
     case 6:
      display.drawBitmap(102, 14, Flip1, 16, 16, 1);
      TwoDMode = 7;
      break;
     case 7:
      display.drawBitmap(100, 16, Flip1, 16, 16, 1);
      TwoDMode = 8;
      break;
     case 8:
      display.drawBitmap(102, 18, Flip1, 16, 16, 1);
      TwoDMode = 1;
      break;
    }
   }
    Battery = ("100%");
    if (fBeep1 == false)
            TimerFreeTone(TonePin, 2450, 100);
            fBeep1 = true;
  } else {
           fBeep1 = false;
  }
  
// Position 2
  if (A4_uS == 910) {
    Alert = fMode2;
   if (Model == 1) {
    switch (CenterStick) {
     case 1:
     fMode2 = ("Center Stic");
     CenterStick = 2;
     break;
     case 2:
     fMode2 = ("enter Stick");
     CenterStick = 3;
     break;
     case 3:
     fMode2 = ("nter Stick ");
     CenterStick = 4;
     break;
     case 4:
     fMode2 = ("ter Stick  ");
     CenterStick = 5;
     break;
     case 5:
     fMode2 = ("er Stick   ");
     CenterStick = 6;
     break;
     case 6:
     fMode2 = ("r Stick   C");
     CenterStick = 7;
     break;
     case 7:
     fMode2 = (" Stick   Ce");
     CenterStick = 8;
     break;
     case 8:
     fMode2 = ("Stick   Cen");
     CenterStick = 9;
     break;
     case 9:
     fMode2 = ("tick   Cent");
     CenterStick = 10;
     break;
     case 10:
     fMode2 = ("ick   Cente");
     CenterStick = 11;
     break;
     case 11:
     fMode2 = ("ck   Center");
     CenterStick = 12;
     break;
     case 12:
     fMode2 = ("k   Center ");
     CenterStick = 13;
     break;
     case 13:
     fMode2 = ("   Center S");
     CenterStick = 14;
     break;
     case 14:
     fMode2 = ("  Center St");
     CenterStick = 15;
     break;
     case 15:
     fMode2 = (" Center Sti");
     CenterStick = 1;
     break;
    }
   } 
    Battery = (" 90%");
    if (fBeep2 == false)
            TimerFreeTone(TonePin, 2450, 100);
            fBeep2 = true;
  } else {
           fBeep2 = false;  
  }
  
// Position 3
  if (A4_uS == 1120) {
    Alert = fMode3;
   if (Model == 1) {
    switch (Flip) {
     case 1:
      display.drawBitmap(100, 16, Flip1, 16, 16, 1);
      Flip = 2;
      break;
     case 2:
      display.drawBitmap(103, 16, Flip2, 16, 16, 1);
      Flip = 3;
      break;
     case 3:
      display.drawBitmap(106, 16, Flip3, 16, 16, 1);
      Flip = 4;
      break;
     case 4:
      display.drawBitmap(109, 16, Flip4, 16, 16, 1);
      Flip = 5;
      break;
     case 5:
      display.drawBitmap(112, 16, Flip1, 16, 16, 1);
      Flip = 6;
      break;
     case 6:
      display.drawBitmap(112, 16, Flip1, 16, 16, 1);
      Flip = 7;
      break;
     case 7:
      display.drawBitmap(109, 16, Flip4, 16, 16, 1);
      Flip = 8;
      break;
     case 8:
      display.drawBitmap(106, 16, Flip3, 16, 16, 1);
      Flip = 9;
      break;
     case 9:
      display.drawBitmap(103, 16, Flip2, 16, 16, 1);
      Flip = 10;
      break;
     case 10:
      display.drawBitmap(100, 16, Flip1, 16, 16, 1);
      Flip = 1;
      break;
    }
   }
    Battery = (" 80%");
    if (fBeep3 == false)
            TimerFreeTone(TonePin, 2450, 100);
            fBeep3 = true;
  } else {
           fBeep3 = false;
  }
  
// Position 4
  if (A4_uS == 1330) {
    Alert = fMode4;
/*   if (Model == 1) {
   switch (CartScroll) {
     case 1:
      fMode4 = ("Cartesia");
      display.drawBitmap(100, 16, Flip1, 16, 16, 1);
      CartScroll = 2;
      break;
     case 2:
      fMode4 = ("artesian");
      display.drawBitmap(100, 18, Flip1, 16, 16, 1);
      CartScroll = 3;
      break;
     case 3:
      fMode4 = ("rtesian ");
      display.drawBitmap(102, 18, Flip1, 16, 16, 1);
      CartScroll = 4;
      break;
     case 4:
      fMode4 = ("tesian M");
      display.drawBitmap(104, 18, Flip1, 16, 16, 1);
      CartScroll = 5;
      break;
     case 5:
      fMode4 = ("esian Mo");
      display.drawBitmap(106, 18, Flip1, 16, 16, 1);
      CartScroll = 6;
      break;
     case 6:
      fMode4 = ("sian Mod");
      display.drawBitmap(108, 18, Flip1, 16, 16, 1);
      CartScroll = 7;
      break;
     case 7:
      fMode4 = ("ian Mode");
      display.drawBitmap(108, 16, Flip1, 16, 16, 1);
      CartScroll = 8;
      break;
     case 8:
      fMode4 = ("an Mode ");
      display.drawBitmap(108, 14, Flip1, 16, 16, 1);
      CartScroll = 9;
      break;
     case 9:
      fMode4 = ("n Mode  ");
      display.drawBitmap(108, 12, Flip1, 16, 16, 1);
      CartScroll = 10;
      break;
     case 10:
      fMode4 = (" Mode   ");
      display.drawBitmap(108, 10, Flip1, 16, 16, 1);
      CartScroll = 11;
      break;
     case 11:
      fMode4 = ("Mode   C");
      display.drawBitmap(108, 8, Flip1, 16, 16, 1);
      CartScroll = 12;
      break;
     case 12:
      fMode4 = ("ode   Ca");
      display.drawBitmap(106, 8, Flip1, 16, 16, 1);
      CartScroll = 13;
      break;
     case 13:
      fMode4 = ("de   Car");
      display.drawBitmap(104, 8, Flip1, 16, 16, 1);
      CartScroll = 14;
      break;
     case 14:
      fMode4 = ("e   Cart");
      display.drawBitmap(102, 8, Flip1, 16, 16, 1);
      CartScroll = 15;
      break;
     case 15:
      fMode4 = ("   Carte");
      display.drawBitmap(100, 8, Flip1, 16, 16, 1);
      CartScroll = 16;
      break;
     case 16:
      fMode4 = ("  Cartes");
      display.drawBitmap(100, 10, Flip1, 16, 16, 1);
      CartScroll = 17;
      break;  
     case 17:
      fMode4 = (" Cartesi");
      display.drawBitmap(100, 12, Flip1, 16, 16, 1);
      CartScroll = 18;
      break;  
     case 18:
      fMode4 = ("Cartesia");
      display.drawBitmap(100, 14, Flip1, 16, 16, 1);
      CartScroll = 1;
      break;
    }
   }
*/   
    Battery = (" 70%");
    if (fBeep4 == false)
            TimerFreeTone(TonePin, 2450, 100);
            fBeep4 = true;
  } else {
           fBeep4 = false;
  }
  
// Position 5
  if (A4_uS == 1380) {
   Alert = fMode5;
   Battery = (" 60%");
   if (fBeep5 == false)
            TimerFreeTone(TonePin, 2450, 100);
            fBeep5 = true;
  } else {
           fBeep5 = false;
  }
  
// Position 6
  if (A4_uS == 1625) {
    Alert = fMode6;
   if (Model == 1) {
    switch (RTH) {
     case 1:
     fMode6 = ("RETURN TO H");
     RTH = 2;
     break;
     case 2:
     fMode6 = ("ETURN TO HO");
     RTH = 3;
     break;
     case 3:
     fMode6 = ("TURN TO HOM");
     RTH = 4;
     break;
     case 4:
     fMode6 = ("URN TO HOME");
     RTH = 5;
     break;
     case 5:
     fMode6 = ("RN TO HOME ");
     RTH = 6;
     break;
     case 6:
     fMode6 = ("N TO HOME  ");
     RTH = 7;
     break;
     case 7:
     fMode6 = (" TO HOME   ");
     RTH = 8;
     break;
     case 8:
     fMode6 = ("TO HOME    ");
     RTH = 9;
     break;
     case 9:
     fMode6 = ("O HOME    R");
     RTH = 10;
     break;
     case 10:
     fMode6 = (" HOME    RE");
     RTH = 11;
     break;
     case 11:
     fMode6 = ("HOME    RET");
     RTH = 12;
     break;
     case 12:
     fMode6 = ("OME    RETU");
     RTH = 13;
     break;
     case 13:
     fMode6 = ("ME    RETUR");
     RTH = 14;
     break;
     case 14:
     fMode6 = ("E    RETURN");
     RTH = 15;
     break;
     case 15:
     fMode6 = ("    RETURN ");
     RTH = 16;
     break;
     case 16:
     fMode6 = ("   RETURN T");
     RTH = 17;
     break;
     case 17:
     fMode6 = ("  RETURN TO");
     RTH = 18;
     break;
     case 18:
     fMode6 = (" RETURN TO ");
     RTH = 1;
     break;
   }
  }
  if (Model == 2) {
    switch (Flip) {
     case 1:
      break;
     case 2:
      display.drawBitmap(100, 16, Flip1, 16, 16, 1);
      Flip = 3;
      break;
     case 3:
      display.drawBitmap(103, 16, Flip2, 16, 16, 1);
      Flip = 4;
      break;
     case 4:
      display.drawBitmap(106, 16, Flip3, 16, 16, 1);
      Flip = 5;
      break;
     case 5:
      display.drawBitmap(109, 16, Flip4, 16, 16, 1);
      Flip = 6;
      break;
     case 6:
      display.drawBitmap(112, 16, Flip1, 16, 16, 1);
      Flip = 7;
      break;
     case 7:
      display.drawBitmap(112, 16, Flip1, 16, 16, 1);
      Flip = 8;
      break;
     case 8:
      display.drawBitmap(109, 16, Flip4, 16, 16, 1);
      Flip = 9;
      break;
     case 9:
      display.drawBitmap(106, 16, Flip3, 16, 16, 1);
      Flip = 10;
      break;
     case 10:
      display.drawBitmap(103, 16, Flip2, 16, 16, 1);
      Flip = 11;
      break;
     case 11:
      display.drawBitmap(100, 16, Flip1, 16, 16, 1);
      Flip = 2;
      break;
   }
  }
    Battery = (" 50%");
           if (fBeep6 == false)
            TimerFreeTone(TonePin, 2450, 100);
            fBeep6 = true;
  } else {
           fBeep6 = false;
 }
  
// 3-way switch #1
  if (digitalRead(inPinD2) == 0) {
           sw1_uS = 750;
           if (Beep1 == false)
            TimerFreeTone(TonePin, 2450, 50);
            Beep1 = true;
            Current = ("0.25A");  
 } else {
           Beep1 = false;  
 }
  if ((digitalRead(inPinD2) == 1) && (digitalRead(inPinD3) == 1)) {
           sw1_uS = 1190;
           if (Beep2 == false)
            TimerFreeTone(TonePin, 2250, 50);
            Beep2 = true;
            Current = ("0.35A");    
 } else {
           Beep2 = false;  
 }
  if (digitalRead(inPinD3) == 0) {
           sw1_uS = 1625;
           if (Beep3 == false)
            TimerFreeTone(TonePin, 2450, 50);
            Beep3 = true;
            Current = ("0.50A");    
 } else {
           Beep3 = false;  
 }

// 2-way switch
  if (digitalRead(inPinD4) == 0) {
           sw2_uS = 750;
           AM_PM = ("pm");
           if (Beep4 == false)
            TimerFreeTone(TonePin, 2450, 100);
            Beep4 = true;    
 } else {
           Beep4 = false;  
 }
  if (digitalRead(inPinD4) == 1) {
           sw2_uS = 1625;
           AM_PM = ("am");
           if (Beep5 == false)
            TimerFreeTone(TonePin, 2200, 50);
            Beep5 = true;    
 } else {
           Beep5 = false;  
 }
 
// 3-way switch #2
  if (digitalRead(inPinD6) == 0) {
           sw3_uS = 1190;
           Minutes = ("00");
           if (Beep6 == false)
            TimerFreeTone(TonePin, 2250, 50);
            Beep6 = true;    
 } else {
           Beep6 = false;  
 }
  if ((digitalRead(inPinD6) == 1) && (digitalRead(inPinD7) == 1)) {
           sw3_uS = 750;
           Minutes = ("30");
           if (Beep7 == false)
            TimerFreeTone(TonePin, 2450, 50);
            Beep7 = true;    
 } else {
           Beep7 = false;  
 }
  if (digitalRead(inPinD7) == 0) {
           sw3_uS = 1625;
           Minutes = ("59");
           if (Beep8 == false)
            TimerFreeTone(TonePin, 2750, 50);
            Beep8 = true;    
 } else {
           Beep8 = false;  
 }
 
// 3-way switch #3
  if (digitalRead(inPinA1) == 0) {
           sw4_uS = 1190;
           Hours = (" 1");
           if (Beep9 == false)
            TimerFreeTone(TonePin, 2250, 50);
            Beep9 = true;    
 } else {
           Beep9 = false;  
 }
  if ((digitalRead(inPinA0) == 1) && (digitalRead(inPinA1) == 1)) {
           sw4_uS = 750;
           Hours = (" 6");
           if (Beep10 == false)
            TimerFreeTone(TonePin, 2450, 50);
            Beep10 = true;    
 } else {
           Beep10 = false;  
 }
  if (digitalRead(inPinA0) == 0) {
           sw4_uS = 1625;
           Hours = ("12");
           if (Beep11 == false)
            TimerFreeTone(TonePin, 2750, 50);
            Beep11 = true;    
 } else {
           Beep11 = false;  
 }
 
// Right-side momentary buttons
  if (digitalRead(inPinD8) == 0) {
            TimerFreeTone(TonePin, 3100, 100);
 }
  if (digitalRead(inPinD9) == 0) {
            TimerFreeTone(TonePin, 2900, 100);
            if (Model == 1) {
              Alert = ("VECTOR OSD");
              A4_uS = 750;
              delay(20);
              A4_uS = 1120;
              delay(20);
              A4_uS = 750;
              delay(30);
              A4_uS = 1120;
              delay(20);
              A4_uS = 750;
            }
 }
 
// Booster state/3-way switch #4
  if (digitalRead(inPinD11) == 0) {
    digitalWrite(BoosterPin, HIGH);  // Turn booster on HIGH power
    digitalWrite(LEDpin0, HIGH);
    digitalWrite(LEDpin1, HIGH);
    Booster = ("HIGH");
           if (Beep12 == false)
            TimerFreeTone(TonePin, 2950, 100);
            Beep12 = true;    
 } else {
           Beep12 = false;  
 }
  if ((digitalRead(inPinD11) == 1) && (digitalRead(inPinD12) == 1)) {
    digitalWrite(BoosterPin, HIGH);  // Turn booster on LOW power
    digitalWrite(LEDpin0, LOW);
    digitalWrite(LEDpin1, HIGH);
    Booster = (" LOW");
           if (Beep13 == false)
            TimerFreeTone(TonePin, 2550, 100);
            Beep13 = true;    
 } else {
           Beep13 = false;  
 }
  if (digitalRead(inPinD12) == 0) {
    digitalWrite(BoosterPin, LOW);  // Turn booster off
    digitalWrite(LEDpin0, LOW);
    digitalWrite(LEDpin1, LOW);
   if (BoosterOff == 1) {           // Blink
      Booster = (" OFF");
      BoosterOff = 0;
   } else {
      Booster = (" ");
      BoosterOff = 1;
   }
           if (Beep14 == false)
            TimerFreeTone(TonePin, 2000, 100);
            Beep14 = true;    
 } else {
           Beep14 = false;  
 }
 
// OLED display
  display.fillRect(2, 2, 12, 8, WHITE);
  display.fillRect(14, 4, 2, 4, WHITE);
  display.drawLine(128, 11, 0, 11, WHITE);
  display.drawLine(128, 0, 0, 0, WHITE);
  display.drawLine(0, 10, 0, 0, WHITE);
  display.fillRect(49, 1, 40, 10, WHITE);
  display.drawLine(92, 9, 92, 8, WHITE);
  display.drawLine(94, 9, 94, 6, WHITE);
  display.drawLine(96, 9, 96, 4, WHITE);
  display.drawLine(98, 9, 98, 2, WHITE);
  display.drawLine(127, 10, 127, 0, WHITE);
  
  switch (BatSwitch) {
    case 1:
     BatCur = Battery;
     BatSwitch = 2;
     break;
    case 2:
     BatCur = Battery;
     BatSwitch = 3;
     break;
    case 3:
     BatCur = Battery;
     BatSwitch = 4;
     break;
    case 4:
     BatCur = Battery;
     BatSwitch = 5;
     break;
    case 5:
     BatCur = Battery;
     BatSwitch = 6;
     break;
    case 6:
     BatCur = Current;
     BatSwitch = 7;
     break;
    case 7:
     BatCur = Current;
     BatSwitch = 1;
     break;
  }
  
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(18,2);
  display.println(BatCur);
  
  display.setTextSize(1);
  display.setTextColor(BLACK);
  display.setCursor(50,2);
  display.println(Hours);
  
  display.setTextSize(1);
  display.setTextColor(BLACK);
  display.setCursor(64,2);
  display.println(Minutes);
  
  display.setTextSize(1);
  display.setTextColor(BLACK);
  display.setCursor(76,3);
  display.println(AM_PM);
  
 if (ColonBlink == 1) {
  Colon = (":");
  ColonBlink = 0;
 } else {
   Colon = (" ");
   ColonBlink = 1;
 }
  
  display.setTextSize(1);
  display.setTextColor(BLACK);
  display.setCursor(60,2);
  display.println(Colon);
  
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(102,2);
  display.println(Booster);
  
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0,16);
  display.println(Alert);
  display.display();
  
///////////////////Debounce////////////////////////////////////
  Last_us = Debounce_us;
///////////////////////////////////////////////////////////////
}

Please Log in or Create an account to join the conversation.

More
09 Feb 2016 13:58 - 09 Feb 2016 14:00 #42840 by Cereal_Killer
Replied by Cereal_Killer on topic Extra inputs for Devo Tx's
Wow, you wrote that?!

I have an i2C RTC, can I just change the address and it'll work?

I've got parts orderee, the 128x32 i2C oled, lots of different buttons to try and switches to use. Can't wait to get this thing together. I'm going to try to install some finger tip switches in the back of the body like that honey badger guy did (from the FT episode we've talked about before)

Can we see a pretty picture of your setup with all this cool stuff installed (external pic of how display is mounted)?

Taranis X9E | DEVO 10 | Devo U7E | Taranis Q7

What I do in real life: rivergoequestrian.com/
Last edit: 09 Feb 2016 14:00 by Cereal_Killer.

Please Log in or Create an account to join the conversation.

More
09 Feb 2016 17:50 #42853 by Epyon
Replied by Epyon on topic Extra inputs for Devo Tx's

Cereal_Killer wrote: Wow, you wrote that?!

Not so much "wrote" as copy/pasted/altered to my needs, lol.

Cereal_Killer wrote: I have an i2C RTC, can I just change the address and it'll work?

If it uses the DS1307 chip, then it should for sure.

Cereal_Killer wrote: Can we see a pretty picture of your setup with all this cool stuff installed (external pic of how display is mounted)?

Most current pics & vids of 7e & 8 are back on pages 9 & 10 respectfully. I'll get some up-to-date ones asap.

Please Log in or Create an account to join the conversation.

More
09 Feb 2016 21:10 #42875 by Epitaph
Replied by Epitaph on topic Extra inputs for Devo Tx's
Hi guys!!

I finally received my Arduino Nano and have it installed no problem with 2 pots (didn't need any more inputs and I can add more later if I need to). But I seem to have found one small problem, and that is that the pots start fine on the full left throw (-100), but when turning them they go up to the full +100 on the monitor when they are only about 2/3rds through their travel, meaning the final 3rd is just dead band. I've tried inverting the positive and negative and it does the same the other way, so it's not the pots which are causing this. Also, centre of the pot is on +50 rather than 0. Is this just basically trimming in the transmitter or is it something to do with the sketch?

This is the sketch used in the end
// Devo 7e PPM input
// For use with Arduino Nano V3.0
// Based on sketch by Ian Johnston

int AI_Pin_A1 = 0;    // Analog In 1
int AI_Pin_A2 = 1;    // Analog In 2
int AI_Raw_A1;        // Analog In raw var - 0->1023
int AI_Raw_A2;        // Analog In raw var - 0->1023
int A1_uS = 750;     // Analog 1 uS var
int A2_uS = 750;     // Analog 2 uS var

int Fixed_uS = 300;       // PPM frame fixed LOW phase
int pulseMin = 750;       // pulse minimum width minus start in uS
int pulseMax = 1700;      // pulse maximum width in uS

int outPinPPM = 5;       // PPM out on digital pin 5

ISR(TIMER1_COMPA_vect) {
    ppmoutput(); // Jump to ppmoutput subroutine
}

void setup() {

  // Serial.begin(9600) ; // Test

  pinMode(outPinPPM, OUTPUT);   // sets the digital pin as output

   // 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 = 22000; // 22mS PPM output refresh
  OCR1B = 1000;
}

void ppmoutput() { // PPM output sub

 // Channel 1 - Analog 1
  digitalWrite(outPinPPM, LOW);
  delayMicroseconds(Fixed_uS);    // Hold
  digitalWrite(outPinPPM, HIGH);
  delayMicroseconds(A1_uS);  // Hold for A1_uS microseconds      

 // Channel 2 - Analog 2
  digitalWrite(outPinPPM, LOW);
  delayMicroseconds(Fixed_uS);    // Hold
  digitalWrite(outPinPPM, HIGH);
  delayMicroseconds(A2_uS); // Hold for A2_uS microseconds      

// Synchro pulse
  digitalWrite(outPinPPM, LOW);
  delayMicroseconds(Fixed_uS);    // Hold
  digitalWrite(outPinPPM, HIGH);  // Start Synchro pulse
}

void loop() { // Main loop

 // Read analog pins
   AI_Raw_A1 = analogRead(AI_Pin_A1);
   AI_Raw_A2 = analogRead(AI_Pin_A2);
   
 // Map analog inputs to PPM rates for each of the channels
   A1_uS = AI_Raw_A1 + pulseMin;
   A2_uS = AI_Raw_A2 + pulseMin;

 // Check limits
  if (A1_uS <= 750) A1_uS = 750;     // Min
  if (A1_uS >= 1700) A1_uS = 1620;   // Max   
  if (A2_uS <= 750) A2_uS = 750;   // Min
  if (A2_uS >= 1700) A2_uS = 1620; // Max 
}

Please Log in or Create an account to join the conversation.

More
09 Feb 2016 21:24 - 09 Feb 2016 21:25 #42876 by Epitaph
Replied by Epitaph on topic Extra inputs for Devo Tx's
Here's how I ended up installing it, with some heatshrink over the entire lot, although the USP port is still accesible



Here is where the knob is at +100 on the channel monitor. I only have one knob, the other one didn't arrive, so that's why there's one missing, but it is giving the same issue on both the pots. It seems to have the problem on the GND end of the pot, no problem on the +5V end...



And here is the actual end of the knob's travel. As I said, I tried reversing the +5V and GND pins on the pot, and it just does the same thing the other way, so it's not the pot that is giving the problem.

Last edit: 09 Feb 2016 21:25 by Epitaph.

Please Log in or Create an account to join the conversation.

More
09 Feb 2016 22:07 #42881 by Deal57
Replied by Deal57 on topic Extra inputs for Devo Tx's
There is a better way to code the range and limits of the pots. Here's what I am using now. So instead of:
// Map analog inputs to PPM rates for each of the channels
   A1_uS = AI_Raw_A1 + pulseMin;
   A2_uS = AI_Raw_A2 + pulseMin;

 // Check limits
  if (A1_uS <= 750) A1_uS = 750;     // Min
  if (A1_uS >= 1700) A1_uS = 1620;   // Max   
  if (A2_uS <= 750) A2_uS = 750;   // Min
  if (A2_uS >= 1700) A2_uS = 1620; // Max 

Use the MAP and Constrain functions to change that to:
// Map analog inputs to PPM rates for each of the channels
 //  compensate for analog 0-1023 vs expected 750-1700
 //  TEST with the MAP command
   A1_uS = map (AI_Raw_A1,0,1023,pulseMin,pulseMax);
   A2_uS = map (AI_Raw_A2,0,1023,pulseMin,pulseMax);

 // Check limits
  A1_uS = constrain (A1_uS, pulseMin, pulseMax);
  A2_uS = constrain (A2_uS, pulseMin, pulseMax);

Deviation Devo7e 3way switch mod, A7105, NRF24L01
Devo6s 2x2 switch mod, trim mod, haptic, multimodule, A7105, NRF24L01, CC2500
Devo12e 4-in-1 with voice mod -- it speaks!!

Please Log in or Create an account to join the conversation.

More
09 Feb 2016 22:21 #42884 by Epitaph
Replied by Epitaph on topic Extra inputs for Devo Tx's
So, just changing over those last lines of code from one to another it improves the input? I mean, the input I got from here, and it works good, it just doesn't reach the full range. OK, I'll try that out tomorrow, it's a bit late right now to start opening the transmitter up again.

Thanks, I'll let you know how it goes!!

Please Log in or Create an account to join the conversation.

More
09 Feb 2016 22:57 #42891 by Deal57
Replied by Deal57 on topic Extra inputs for Devo Tx's
Looking a little closer, you also need to set your limits to match the pwm values you need. I think you need to set the upper limit to 1750 (pulsemax). In any case, the min and max of your range constraints range need to match pulsemin and pulsemax.

Deviation Devo7e 3way switch mod, A7105, NRF24L01
Devo6s 2x2 switch mod, trim mod, haptic, multimodule, A7105, NRF24L01, CC2500
Devo12e 4-in-1 with voice mod -- it speaks!!

Please Log in or Create an account to join the conversation.

More
09 Feb 2016 23:16 #42893 by Epitaph
Replied by Epitaph on topic Extra inputs for Devo Tx's
Just change the 1700 to 1750 then? Is that change in all the lines of 1700?

Please Log in or Create an account to join the conversation.

More
09 Feb 2016 23:34 - 09 Feb 2016 23:36 #42894 by Deal57
Replied by Deal57 on topic Extra inputs for Devo Tx's
Yes, that would do it. In my own code I usually declare the values so if I need to change them later there is just one place to make a change. Whatever way works for you!
int Fixed_uS = 300;       // PPM frame fixed LOW phase
int pulseMin = 750;       // pulse minimum width minus start in uS
int pulseMax = 1700;      // pulse maximum width in uS

Hmm... just noticed that the range I used in my last build went to 1700. So that should be a good value for you.

You are using Linear pots, right?

Deviation Devo7e 3way switch mod, A7105, NRF24L01
Devo6s 2x2 switch mod, trim mod, haptic, multimodule, A7105, NRF24L01, CC2500
Devo12e 4-in-1 with voice mod -- it speaks!!
Last edit: 09 Feb 2016 23:36 by Deal57.

Please Log in or Create an account to join the conversation.

More
09 Feb 2016 23:37 #42896 by Epitaph
Replied by Epitaph on topic Extra inputs for Devo Tx's
OK, I'll try it out tomorrow... although I don't know if 1750 will do it, I mean, there is a LOT of deadband!! When the pot is exactly half way, on a scale from -100 to 100, it displays 50!! But I guess it's just a case of trial and error, try out new values until I find the one that works!!

Thanks!!

Please Log in or Create an account to join the conversation.

More
09 Feb 2016 23:39 - 09 Feb 2016 23:40 #42897 by Epitaph
Replied by Epitaph on topic Extra inputs for Devo Tx's
They are just your average everyday 5k pots I got off ebay... they are linear in that the value change is constant as you turn it (like no "expo")...

1700 is what I already have if you look at the code I posted...
Last edit: 09 Feb 2016 23:40 by Epitaph.

Please Log in or Create an account to join the conversation.

More
10 Feb 2016 00:16 #42902 by Deal57
Replied by Deal57 on topic Extra inputs for Devo Tx's
You are setting the max to 1620us but the fact that you get there quicker on the Pot tells me that's probably not the problem.

Are you setting any Max/Min limits or scalar in your model.ini? Or maybe subtrim? Also, what is the setting for your PPM-In? I think it starts at center PW 1100, Delta 400, Notch 400 and Frame size 22500. You might try adjusting the center up a bit.

Deviation Devo7e 3way switch mod, A7105, NRF24L01
Devo6s 2x2 switch mod, trim mod, haptic, multimodule, A7105, NRF24L01, CC2500
Devo12e 4-in-1 with voice mod -- it speaks!!

Please Log in or Create an account to join the conversation.

Time to create page: 0.098 seconds
Powered by Kunena Forum