Page 1 of 3

Analog input for X8R

Posted: Sun Oct 13, 2013 11:08 am
by MikeB
Reason for project.
FrSky have chosen not to put any analog input ports on the X8R receiver. Many users would find one such input very useful.

Implementation:
Use a small Arduino to read an analog signal and send this to the X8R using the SPort protocol.
I used a Mini Lite, but the Pro Mini is the basically the same device.

Connections:
SPort +V ---> Arduino +9V
SPort -V ---> Arduino 0V
SPort signal <--- Arduino I/O 4

Arduino 0V <--- Analog ground
Arduino A3 <--- Analog input 0-3.3V (tolerates 4.5V)

Here is my first code effort.
SPortAnalog.zip
13 Oct 2013 12:10
(7.69 KiB) Downloaded 775 times
Unzip the files as an Arduino sketch and download to the Arduino Mini.

Mike.

Re: Analog input for X8R

Posted: Sun Oct 13, 2013 4:21 pm
by Rob Thomson
Great. Very useful addition.

Sent from my GT-I9300 using Tapatalk now Free

Re: Analog input for X8R

Posted: Sun Oct 13, 2013 4:26 pm
by ShowMaster
Pro mini's on order now.

Re: Analog input for X8R

Posted: Sun Oct 13, 2013 5:17 pm
by Kilrah
Cool :)

Just one thing, why create an independent codebase instead of simply integrating it in the openxsensor? Then there's only one page, codebase, set of instructions etc to maintain for one thing that does it all...

Especially as the hardware is the same, and that it's only a couple of lines to add to measure an additional analog input and put the value out :)

Re: Analog input for X8R

Posted: Sun Oct 13, 2013 5:18 pm
by Rob Thomson
Now that's a good idea!

Sent from my GT-I9300 using Tapatalk now Free

Re: Analog input for X8R

Posted: Sun Oct 13, 2013 5:26 pm
by jhsa
the oXs already measures voltage.. My question is, will we have a define for choosing what system the sensor will be running with? "D" or "X" series? Better a difine to choose between the two or the complete thing will be a mess ;)
Or maybe making 2 codes.. D series and X series. then we just flash the one we are using.. less confusion and more space in the arduino.
Just my two bottles of whiskey.. :mrgreen:

João

Re: Analog input for X8R

Posted: Sun Oct 13, 2013 5:53 pm
by ReSt
jhsa wrote:My question is, will we have a define for choosing what system the sensor will be running with? "D" or "X" series?
or none at all :D
as I use it without frsky receivers

Reinhard

Re: Analog input for X8R

Posted: Sun Oct 13, 2013 7:34 pm
by MikeB
Kilrah wrote:Just one thing, why create an independent codebase instead of simply integrating it in the openxsensor? Then there's only one page, codebase, set of instructions etc to maintain for one thing that does it all...
I thought I'd keep things simple for those that just want the analog input. They don't need the pressure sensor and this, I think, makes it easy to just have the analog input.

I was also thinking it might be useable on a smaller processor, although with the low cost of some Arduino mini clones it probably isn't worth the effort.

Mike.

Re: Analog input for X8R

Posted: Sun Oct 13, 2013 7:41 pm
by jhsa
you mean an attiny?? If possible it would make it smaller in my opinion..

João

Re: Analog input for X8R

Posted: Sun Oct 13, 2013 7:51 pm
by MikeB
Yes. With the code as it is, you would need an external crystal (or resonator). I could look into using the internal oscillator, but I would then need to measure the incoming baud rate to get the outgoing baudrate correct. If I got that working then the whole thing might just need to be the processor, no external compomemts at all.

Mike.

Re: Analog input for X8R

Posted: Sun Oct 13, 2013 8:28 pm
by jhsa
Exactly.. A bit of strip board with the same size as the attiny to avoid shorts and give some solder points. a bit of shrink tube and done. very small A1/2 ports for the X8R ;) :)

João

Re: Analog input for X8R

Posted: Sun Oct 13, 2013 8:48 pm
by MikeB
As a result of some other testing of the SPort in general, I will need to be changing the SPort driver code.

Mike.

Re: Analog input for X8R

Posted: Sun Oct 13, 2013 10:49 pm
by ShowMaster
FTDI cable?
I'm ordering many of the Arduino components mentioned as well as the sensor for the OpenXsensor. I thought I'd do my best to learn about all this. So do I own anything Frsky that's FTDI cable? A search says USB to rs232 but some mention to TTL maybe?
I have USB to castle creation programing adapter cables. Also the Frsky USB to rs232 cable. I also have a Arduino UNO. Also USBasp

Will any of these work? If not I need a link to one.
Thanks

Re: Analog input for X8R

Posted: Wed Oct 16, 2013 8:45 pm
by ttabbal
I'd love to make some of these with a bare ATtiny or a little stripboard. Using an external resonator will work for me. Will the code work at 16Mhz? I was thinking I might order up some chips and resonators to try out.

I was going to try this exact thing myself, but FrSky hasn't gotten back to me for a while about specs/NDA.

Re: Analog input for X8R

Posted: Wed Oct 16, 2013 9:20 pm
by MikeB
The code is for 16MHz. I think you will need a minimum of 4K flash to fit the code in.
It should work on an ATtiny, you only need one analog input and one digital I/O.

Mike.

Re: Analog input for X8R

Posted: Wed Oct 16, 2013 10:24 pm
by Clivew
Is it really impossible to re-route the existing analogue port or just hellish difficult??
This does seem to be a sledgehammer to crack a nut :P

Re: Analog input for X8R

Posted: Wed Oct 16, 2013 10:53 pm
by ttabbal
Clivew wrote:Is it really impossible to re-route the existing analogue port or just hellish difficult??
This does seem to be a sledgehammer to crack a nut :P
From what I have read, to get to the existing A1, you have to separate 2 boards inside the receiver box as the only place you could get to it is between them. And then it's probably some fine pitch solder work, which I can handle, but it's a lot easier to just solder a chip, resonator and 4 wires up. Oh, and 2 resistors.

Re: Analog input for X8R

Posted: Wed Oct 16, 2013 11:21 pm
by Clivew
It just seems overly complicated to me, adding yet another module and connectors.
I would love to see some closeup photos of the board(s).
I was always told "simplificate, and add more lightness" :roll:

Re: Analog input for X8R

Posted: Wed Oct 16, 2013 11:40 pm
by jhsa
I think, in this case, the easiest way is really to use the attiny :D :p

Re: Analog input for X8R

Posted: Wed Oct 16, 2013 11:49 pm
by MikeB
Preserves your Rx warranty, keeps the existing internal analog data and gives me a chance to program the SPort driver!

Also, we can probably include some other inputs of some sort if not using the openXsensor.

Mike.

Re: Analog input for X8R

Posted: Wed Oct 16, 2013 11:53 pm
by Clivew
I want to do it the hard way (after someone else did it of course!) ;)

Re: Analog input for X8R

Posted: Thu Oct 17, 2013 12:01 am
by Clivew
MikeB wrote:Preserves your Rx warranty, keeps the existing internal analog data and gives me a chance to program the SPort driver!

Also, we can probably include some other inputs of some sort if not using the openXsensor.

Mike.
Aha, in that case I'm with you all the way :P

(I would still be interested to see what is involved for a simple model solution without extra
modules/cables though!)

Clive

Re: Analog input for X8R

Posted: Thu Oct 17, 2013 12:03 am
by jhsa
Dismantling a receiver completely? ;) no, not me :mrgreen: mrgreen:

João

Re: Analog input for X8R

Posted: Thu Oct 17, 2013 7:47 am
by MikeB
Clivew: Have you read this thread from here?
http://openrcforums.com/forum/viewtopic ... X8R#p59640

Mike.

Re: Analog input for X8R

Posted: Thu Oct 17, 2013 10:45 am
by Clivew
Thanks Mike, missed that one completely!

Re: Analog input for X8R

Posted: Fri Oct 18, 2013 9:57 am
by MikeB
I'm looking into implementing this on an attiny13 (8-pin device). I've converted the code to a 'proper' makefile project. Arduino adds too much coe not required, and the attiny13 only has 1K of flash. It also doesn't have a bootloader.
The program is currently around 520 bytes, so I have some spare flash. I've still to actually test it!
You have to use the internal oscillator, but I intend to add code to detect the actual bit rate from the SPort receive data and adjust the timing to match.
My intention is to use a 3.3V regulator to power the attiny, and this will also therefore act as the reference voltage for the A2D.
So I'm looking at, a 3.3V regulator, 2 small caps and the attiny13.

Mike.

Re: Analog input for X8R

Posted: Fri Oct 18, 2013 10:11 am
by jhsa
5V would give you better resolution? Or you are using 3.3V to keep things compatible with the frsky sensors?

I use the 5V on the openXsensor. the sensor just takes 2 resistors.. I can see an advantage on the 3.3V though. You just get power from the 5V BEC and it will be regulated to 3.3V while at 5 you would have to power it from batt voltage, as the voltage from the receiver/BEC might fluctuate a bit with the load from the servos.. Or is my thinking wrong?

João

Re: Analog input for X8R

Posted: Fri Oct 18, 2013 4:28 pm
by ShowMaster
FYI
X8R photo
The top board covers the A1 resistor area and probably needs to be removed.
As for rec warranty,
I'm not sure the $ to replace the rec if I need the feature is worth worrying about. No reason to think the rec will fail under the warranty time.
If only Frsky would not be so secret about their plans and release dates now that they have a following. If HK gets their new 9XR to market this year at an attractive price and can fold it may shift the $. As good as the Taranis is, it's main selling feature is what it does for the price. Lower the price with the same features and suddenly the sales shift to that product. Many just want a programmable/flashable tx that talks and displays telemetry at the lowest price. That could be the new 9XR.
Let's go Frsky, get your release dates in print.
In the meantime Mike, keep the good ideas gong. We all want to use our x8r with the same features the D rec have. It is so easy to use the A1 and A2 ports in the D receiver.
ImageUploadedByTapatalk1382112544.523736.jpg
ImageUploadedByTapatalk1382112580.072686.jpg

Re: Analog input for X8R

Posted: Fri Oct 18, 2013 4:38 pm
by MikeB
We are replaceing an A2D that provides 8 bit resolution at 3.3V reference, so this is providing the same. Also, unlike the mega328 on the openX sensor, the attiny13 does not have the 1.1V bandgap reference to correct for changes in supply voltage.
A 3.3V regulator also handles powering from a 4/5 cell NiMh receiver battery.

Mike.

Re: Analog input for X8R

Posted: Fri Oct 18, 2013 4:54 pm
by ShowMaster
I'm in!