- Posts: 208
Extra inputs for Devo Tx's
- Richard96816
- Offline
Deal57 wrote: When you are discussing S.bus and SPI, today aren't you really talking about the "output" side of the Transmitter system, that is, how the TX tells our peripherals (RX, voice prompter, etc.) to work? Can we look just at "input"?
You do it all the time with SPI. Transmitter to receiver.
Please Log in or Create an account to join the conversation.
- mwm
- Topic Author
- Offline
In particular, the PPM that's used as input for the trainer port that we're piggy-backing this on is also used by an Rx to talk to flight controllers. This is how the wireless trainer mod talked about here works. The newer protocols like S.Bus and SRXL can also do all that, except we don't have an S.Bus interface in deviation.
All of these protocols describe a collection of channels as a packet that can be sent over the wire somehow. So you could, in theory, have a "trainer" port that does one of those protocols, and also have an extra inputs box that used them instead of PPM. I'm not sure if you could do it on the PPM port or not, as I haven't looked at the hardware details yet.
As far as I know, nobody is actually doing this. The latest hotness is wireless interfaces using the same protocols that are being used to talk to Rx's, so that way you don't need another rf module in the Tx. The universal module is going to have a bluetooth chip on it, so you could in theory use that to add controls on a phone or table or even a bluetooth game controller.
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.
- Richard96816
- Offline
- Posts: 208
mwm wrote: Actually, no. SPI is what's used for intermodule communications inside the Tx. S.Bus and similar are used for talking between an Rx and other components.
True. But in this case we've got two modules that both know how to speak SPI. Why put more complexity and delay between them? Especially since we're in control of the software side of the protocols too ...
Please Log in or Create an account to join the conversation.
- mwm
- Topic Author
- Offline
The advantage of using one of the extant protocols means you can find Rx's to build a wireless trainer module, if nothing else. While CPPM has serious problems, S.Bus and SRXL both have more channels and a shorter frame than any CPPM system I'm aware of, and in general avoid it's problems. I'm not convinced that they are more complex than an SPI protocol would be, but can't really judge because there's no proposed standard for the latter. I suspect they are simpler to use, because you'll find open source libraries to just drop into your code - though I haven't looked for them yet - rather than having to design and code the packet-level protocol from scratch.
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.
- Richard96816
- Offline
- Posts: 208
mwm wrote: For external communications (i.e. - from the Tx to a collection of other devices), you have to have a packet-level protocol somewhere. SPI doesn't provide that. Sure you could build one on top of it, but you'd also have to build all the devices you were going to use.
'Extra inputs' was about internal communications. The item simply grew a little too large for the Devo case -- it's still closely coupled. Attached, actually. And having closely coupled multiple processors talking to each other is the direction things seem to be going with Deviationtx. I see your points. But I also find possible coupling of STM and Arduino (or other STMs) via SPI to be worth exploring. Or at least discussing ...
Please Log in or Create an account to join the conversation.
- mwm
- Topic Author
- Offline
I suspect the determining factor in choice of a protocol for use in a devo 7E is going to be what hardware is available. PPM got used because there was already both hardware and software in place. So what hardware can be used for SPI, or whatever?Is it possible to do one of the async protocols over the current PPM line? That would let you do everything we're doing with PPM: deviation/deviation trainer, wireless trainers with the appropriate Rx, and adding devices - with less delay and more channels than PPM. I think it'd be a win, but it may not be possible.
If you want to do SPI, you need to find an enable line for it, so you'd have to replace one of the RF modules. Possibly using the multi-module code extended to deal with extra input devices. But that buys you less than using one of the serial protocols, because you'd have to figure out how to do trainer mode with it. And I don't think a wireless trainer mode will be possible, because it runs into the same issues as doing it in deviation with the existing hardware does. And while SPI would be faster than any of the serial protocols, I don't think it would matter since we can't send samples faster than an RF channel in any case.
I wonder if anyone has done a Tx that can use one of the serial protocols as a "trainer" protocol, or if there's head tracking gear that does such, or anything similar? This really is "external", so SPI wouldn't be appropriate. Oh dear. Since these are strictly external, why not use the USB port? That ought to be better than bluetooth, which is SOP for video gamers these days.
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.
- davidwyl
- Offline
- Posts: 26
But not i want to add 2 pots, i have near zero knowledge on Arduino.
So from what i understand in this post, i need:
1. ATmega328P Nano V3
2. 2x 5k potentiometer (must be 5k pot? or any value will work?)
what else component do i need?
im interested to add 2 pot into my D7E, so can i use @Cereal_Killer in page2??
Please Log in or Create an account to join the conversation.
- Epyon
- Offline
- Posts: 57
davidwyl wrote: So from what i understand in this post, i need:
1. ATmega328P Nano V3
2. 2x 5k potentiometer (must be 5k pot? or any value will work?)
what else component do i need?
Any value pot will do. I'm currently using 10k's, these , but will be switching them out with these as they're smaller and I'm gonna cram as much as I can into my poor 7e.
A couple small capacitors would be a good idea on the power into the Nano & and definitely one on the power out to the pots. It helps with jitter.
If you're anything like me, it won't end at 2 pots. You'll be thinking up all sorts of possible switches and mods. OLED displays, audio boards, real time clock, 9DOF module, etc.
Please Log in or Create an account to join the conversation.
- davidwyl
- Offline
- Posts: 26
Please Log in or Create an account to join the conversation.
- Epyon
- Offline
- Posts: 57
For only 2 pots, this is all you'll need code-wise.
// Devo 7e PPM input
// For use with Arduino Nano V3.0
// Based on sketch by Ian Johnston
int AI_Pin_A1 = 2; // 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 = 10; // PPM out on digital pin 10
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
}
Here's my current code for 2 pots, a 6-way switch, a 3-way switch, and a piezo buzzer.
// Devo 7e PPM input
// For use with Arduino Nano V3.0
// Based on sketch by Ian Johnston
int AI_Pin_A1 = 2; // 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 sw1_uS = 750; // 6-way switch
int sw2_uS = 750; // 3-way switch
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 = 10; // PPM out on digital pin 10
int inPinD1 = 2; // 6-way inputs: digital pin 2
int inPinD2 = 3; // digital pin 3
int inPinD3 = 4; // digital pin 4
int inPinD4 = 5; // digital pin 5
int inPinD5 = 6; // digital pin 6
int inPinD6 = 7; // digital pin 7
int inPinD7 = 8; // 3-way inputs: digital pin 8
int inPinD8 = 9; // digital pin 9
int piezoPin = 13; // piezo buzzer on digital pin 13
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;
ISR(TIMER1_COMPA_vect) {
ppmoutput(); // Jump to ppmoutput subroutine
}
void setup() {
// Serial.begin(9600) ; // Test
pinMode(outPinPPM, OUTPUT); // sets the digital pin as output
pinMode(inPinD1, INPUT); // sets the digital pin as input
digitalWrite(inPinD1, HIGH); // turn on pull-up resistor
pinMode(inPinD2, INPUT);
digitalWrite(inPinD2, HIGH);
pinMode(inPinD3, INPUT);
digitalWrite(inPinD3, HIGH);
pinMode(inPinD4, INPUT);
digitalWrite(inPinD4, HIGH);
pinMode(inPinD5, INPUT);
digitalWrite(inPinD5, HIGH);
pinMode(inPinD6, INPUT);
digitalWrite(inPinD6, HIGH);
pinMode(inPinD7, INPUT);
digitalWrite(inPinD7, HIGH);
pinMode(inPinD8, INPUT);
digitalWrite(inPinD8, HIGH);
// 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
// Channel 3 - 6-way switch
digitalWrite(outPinPPM, LOW);
delayMicroseconds(Fixed_uS); // Hold
digitalWrite(outPinPPM, HIGH);
delayMicroseconds(sw1_uS); // Hold for sw1_uS microseconds
// Channel 4 - 3-way switch
digitalWrite(outPinPPM, LOW);
delayMicroseconds(Fixed_uS); // Hold
digitalWrite(outPinPPM, HIGH);
delayMicroseconds(sw2_uS); // Hold for sw2_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
if (digitalRead(inPinD1) == 0) { // Switch 1
sw1_uS = 750;
if (Beep1 == false)
tone(piezoPin, 2450, 50);
delay(50);
Beep1 = true;
} else {
noTone(piezoPin);
Beep1 = false;
}
if (digitalRead(inPinD2) == 0) { // Switch 2
sw1_uS = 910;
if (Beep2 == false)
tone(piezoPin, 2550, 50);
delay(50);
Beep2 = true;
} else {
noTone(piezoPin);
Beep2 = false;
}
if (digitalRead(inPinD3) == 0) { // Switch 3
sw1_uS = 1120;
if (Beep3 == false)
tone(piezoPin, 2650, 50);
delay(50);
Beep3 = true;
} else {
noTone(piezoPin);
Beep3 = false;
}
if (digitalRead(inPinD4) == 0) { // Switch 4
sw1_uS = 1330;
if (Beep4 == false)
tone(piezoPin, 2750, 50);
delay(50);
Beep4 = true;
} else {
noTone(piezoPin);
Beep4 = false;
}
if (digitalRead(inPinD5) == 0) { // Switch 5
sw1_uS = 1540;
if (Beep5 == false)
tone(piezoPin, 2850, 50);
delay(50);
Beep5 = true;
} else {
noTone(piezoPin);
Beep5 = false;
}
if (digitalRead(inPinD6) == 0) { // Switch 6
sw1_uS = 1620;
tone(piezoPin, 2850, 100);
delay(100);
tone(piezoPin, 2700, 100);
delay(100);
tone(piezoPin, 2600, 100);
delay(100);
}
if (digitalRead(inPinD7) == 0) { // Switch 7
sw2_uS = 750;
if (Beep7 == false)
tone(piezoPin, 2450, 50);
delay(50);
Beep7 = true;
} else {
noTone(piezoPin);
Beep7 = false;
}
if ((digitalRead(inPinD7) == 1) && (digitalRead(inPinD8) == 1)) { // Switch 8
sw2_uS = 1190;
if (Beep8 == false)
tone(piezoPin, 2250, 50);
delay(50);
Beep8 = true;
} else {
noTone(piezoPin);
Beep8 = false;
}
if (digitalRead(inPinD8) == 0) { // Switch 9
sw2_uS = 1620;
if (Beep9 == false)
tone(piezoPin, 2450, 50);
delay(50);
Beep9 = true;
} else {
noTone(piezoPin);
Beep9 = false;
}
}
Please Log in or Create an account to join the conversation.
- davidwyl
- Offline
- Posts: 26
Epyon wrote: e small capacitors would be a good idea on the power into the Nano & and definitely one on the power out to the pots. It helps with jitter.
.
what sort of capacitor value for the nano in and the pot?
just connect in series with the power?
Please Log in or Create an account to join the conversation.
- Epyon
- Offline
- Posts: 57
For the pot power (5v) use around a 25uf, not much higher.
The caps connect from vin to ground & 5v to ground.
Please Log in or Create an account to join the conversation.
- davidwyl
- Offline
- Posts: 26
just look thorough the Nano v3 datasheet, found out that the Vin recommended is 7-12v, but devo 7e doesnt provide voltage higher than 5v,Epyon wrote: Any size on the Nano power (vin) bigger can't hurt.
For the pot power (5v) use around a 25uf, not much higher.
The caps connect from vin to ground & 5v to ground.
1.does it mean i have to use external power (ie: 9v battery)??
2.Arduino Pro Mini is a better choice for this mod?? (since it will run on 3.3v / 5v)
Please Log in or Create an account to join the conversation.
- Epyon
- Offline
- Posts: 57
Please Log in or Create an account to join the conversation.
- Richard96816
- Offline
- Posts: 208
Please Log in or Create an account to join the conversation.
- aMax
- Offline
- Posts: 776
These are nice, but seem to have a drawback, with the CH340G on board they only can work at 12Mhz...or is this wrong?Epyon wrote: You can get Nano clones that run @ 5v www.ebay.com/itm/261892696222?_trksid=p2...e=STRK%3AMEBIDX%3AIT I've got several in use and have been happy with them. I'd stick with a Nano since it's not much bigger than a Pro Mini and includes USB.
Devo7e, TaranisQ X7, R9M , 4in1 MM, Futaba FC18plusV3.2 & DFT/FLD-02
Please Log in or Create an account to join the conversation.
- Goossens
- Offline
- Posts: 6
I work with Arduino on most of my projects. If you want to add more switches to the board you can use an analog port and some resistors.
You can easily hook 6 switches to 1 analog port.
Here is an example.
www.instructables.com/id/How-to-access-5...-buttons-on-one-pin/
Please Log in or Create an account to join the conversation.
- Deal57
- Offline
- Posts: 857
I used this Frsky 6-position rotary switch into an analog port on the Arduino, and it works nicely. There are two ways to use it: you can use it as shipped, with the resistance values of -100, 0, 33, 50, 61 and 100. You can also move a resistor (they're really tiny... like 0403 size!) and get a more linear curve but I used it as shipped. This goes into my Arduino and I convert the resistance to a Flight Mode value, then put that value onto a PPM channel. For example in position 1 Arduino sees 0, position 2 is 450, position 3 is 600, and so on scale of 0-1023). If analog read is 450, FM=2. If FM=2 the PPM period is 1295 microseconds.
It works. I added a bigger knob which makes it easier for my fat fingers. I can send you an Arduino sketch if you want to see an example.
I have another way to do this that I'll write up once I get it built.
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.
- Cereal_Killer
- Offline
aMax wrote:
These are nice, but seem to have a drawback, with the CH340G on board they only can work at 12Mhz...or is this wrong?Epyon wrote: You can get Nano clones that run @ 5v www.ebay.com/itm/261892696222?_trksid=p2...e=STRK%3AMEBIDX%3AIT I've got several in use and have been happy with them. I'd stick with a Nano since it's not much bigger than a Pro Mini and includes USB.
Definitely incorrect. The clone nano V3's with the CH340G are my favorite arduinos, they for sure run at 16mhz @ 5V. The really cool thing is that the CH340G has a built in 3V3 regulator so you input raw battery (to the Arduino's RAW pin) then you have both 5V (from the on-board LDO) AND you have 3.3V from the LDO built into the CH340G available!
I liked them so much I no have several stand alone CH340G boards for TTL converters that I like more than FDTI's.
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.
- davidwyl
- Offline
- Posts: 26
I ripped my sck pin today, so now I cant solder any module to mainboard bcos sck track ripped off.
Hope someone can help.
Please Log in or Create an account to join the conversation.
- Home
- Forum
- Development
- Development
- Extra inputs for Devo Tx's