Surface Radio FPV, 2 pots and a head tracker

Status
Not open for further replies.

davidw

New member
I am a newbie to all of this. If I violate some protocol in my communications, I apologize in advance. I have read FAQ and a lot of messages to learn how to use the forum but I still may err.

I have many years of sailing experience and twelve years racing RC sailboats. I have a tremor in my left thumb and use a pistol grip rather than an aircraft two stick Tx. As part of my FPV design, I have not been able to find a pistol grip Tx with a buddy port to accept the head tracker signal so I am building one.

The project is to make one of my RC sailboats FPV by muxing the two pots in my radio with the three channel signal from a Trinity Head tracker using a Teensy 3.2. The design calls for two analog in channels (Throttle (Ch1) and Rudder (Ch2) ) two blank channels and three digital in channels (pan (Ch5),tilt (Ch6),roll (Ch7) from the tracker followed by a blank channel -- a total of eight to be sent through a FrSky DHT 8ch DIY Telemetry Compatible Transmitter Module to a compatible Rx on the boat. I am at the breadboard stage. I do not have an Oscope and do not know how to use one anyway.

Last night I got the code to compile for the first time. I have successfully tested analogread to uSec to serial monitor for the two pots (THR and RUD). The uS outputs are correct. The googles accept and display the signal from the boat camera.

My problem is the digital signal in and out. The googles have their own battery. The signal provides wiring are ground and signal only which I put in pin 6 and ground on the breadboard.


Here is the result from the serial monitor.
5473 : 1527.19 1527.19 1527.17 1527.19 1528.19 1529.19 1530.19 1527.19
5474 : 1527.17 1527.19 1527.19 1527.19 1528.19 1529.19 1530.17 1527.19
5475 : 1527.19 1527.19 1527.19 1527.17 1528.19 1529.19 1530.19 1527.19 (etc. etc.)

The voltage from the ground/signal is steady at 2.7v until I turn on the head tracker and move the googles at which time is varies up 2.71, 2.58, 2,68v etc.
My code is posted.

Question 1. Does the code require the timer code or is built into the library?
Question 2. Any pointers for me to get the Head Tracker feed into the Teensy correctly?
Question 3. Any suggestions on the setup and code to generate the PPMout signal?

CODE:
#include <PulsePosition.h>


// this would not be possible, for me, with out the pulseposition library provided by the generous efforts of Paul Stoffregen.and "whimisical"
// Please visit his site and give thanks http://forum.pjrc.com/forums/5-General-Discussion
// The library takes care of all I/O so all that is needed is to write the time value to the output or read from the input.
// If tracker is unpluged it will just continue to output the last valid data. plugging the tracker back in
// it will resume as if nothing had happened.

// this will run on a Teensy 3.2 Arm M4 so visit paul and buy 1, they are not expensive, $20.
// to compile properly Arduino needs to have the Teensyduino extensions available from the Teensy site
// https://www.pjrc.com/teensy/index.html
// library at http://www.pjrc.com/teensy/td_libs_PulsePosition.html


// this project reads throttle and rudder pots and the 3 axis from a Trinity head tracker.
// this outputs the combined 8 channel PPM to a FrSky Tx for transmission.

PulsePositionOutput stream (RISING); //combined tracker THR and RUD output
PulsePositionInput tracker; // tracker input

//////////////////////CONFIGURATION///////////////////////////////
#define channel_number 8 //set the number of chanels
#define default_servo_value 1500 //set the default servo value
#define PPM_FrLen 22500 //set the PPM frame length in microseconds (1ms = 1000µs)
#define PPM_PulseLen 300 //set the pulse length
#define onState 1 //set polarity of the pulses: 1 is positive, 0 is negative
#define sigPin 10 //set PPM signal output pin on the arduino
//////////////////////////////////////////////////////////////////

//Name and Set to Analog input pins
const int THR_Pin = 2; // Throttle on Pin 2
const int RUD_Pin = 3; // Rudder on Pin 3
const int led = 13; // set led for Teensy 3.2 on pin 13
int THR = 0; // THR pot value
int RUD = 0; // RUD pot value

float val = 0;
int count = 0;
int i;
int num;
int numout;

void setup()
{
// PPM IN tracker pin 6
// PPM OUT streeam pin 9
stream.begin(9); // start the PPM output stream on pin 9
tracker.begin(6); //start the PPM input stream on pin 6
analogReadAveraging(32); // average 8 readings to smooth jitters
Serial.begin(38400); // opens serial port, sets data rate to 38400 bps.
}

void loop()
{

// Everytime tracker data arrives, print it to
// Arduino Serial Monitor
int i;
int num =0 ;

num = tracker.available();

// Serial.print("num");
// Serial.print(num);
// Serial.println();
if (num > 0) {
count = count + 1;
Serial.print(count);
Serial.print(" : ");
for (i = 1; i <= num; i++) {
float val = tracker.read(i);
Serial.print(val);
Serial.print(" ");
}
Serial.println();
}

// WHen data arrives write it to stream output
THR = analogRead (THR_Pin);
THR = map(THR, 0, 1023, 1000, 2000);
stream.write(1, THR);
RUD = analogRead(RUD_Pin);
RUD = map(RUD, 0, 1023, 1000, 2000);
stream.write(2, RUD);
stream.write(3, 1000);
stream.write(4, 1000);
val = tracker.read(1);
stream.write(5, val);
val = tracker.read(2);
stream.write(6, val);
val = tracker.read(3);
stream.write(7, val);
stream.write(8, 1000);

}
 
UPDATE: Working tonight I found that the Head tracker was not set up correctly. I fixed it, the digital channels are being received by the Teensy. I have all five channels in the Teensy. Yeah!! Now I need to work on placing the inputs in the array properly and generating the Pulseout. More news to come.
 
Code Complete! now I am working on circuitry.

UPDATE: Working tonight I found that the Head tracker was not set up correctly. I fixed it, the digital channels are being received by the Teensy. I have all five channels in the Teensy. Yeah!! Now I need to work on placing the inputs in the array properly and generating the Pulseout. More news to come.
Circuitry is new to me.I do not know who to ask. There are three basic parts to the project, the Teensy 3.2 which as of now is powered by the USB connection, the head tracker is powered by the googles and generates a 2.7v signal and the transmitter which will be connected to the Teensy (out) and requires 7v (I have a voltage stepupthat that outputs 7.4v) The pistol grip of the Tx holds four AA (4 x 1.5) I have verified each one individually but now I have to put it all together (at once!). How do I figure out the needed circuits from the pistol grip to power the Teensy and the transmitter without frying the Teensy? Is some from of circuit protection I need for the head tracker?

Thank you for your advice.:confused:
 
The most important thing is to make sure you connect the grounds of everything together. Yeah, I know that may be overly obvious, but it's a common mistake when dealing with hacking ready-made products.

Connecting to already-made products usually involves some guesswork. Products that run from a 6V or 7.4V battery probably don't actually use 6V or 7.4V logic signals. The might run heavy loads like motors directly from the battery, but logic circuits almost certainly run from an internal regulator that reduces the battery to 3.3V or 5V. Even Teensy 3.2 is like this... VIN & VUSB are 5V, but the regulator reduces to 3.3V, so all the logic signals are actually 3.3V.
 
Paul:
Thank you for your advice. Overly obvious is valuable to me. I will keep you posted on my progress.
David
 
Status
Not open for further replies.
Back
Top