Feed on
Posts
Comments

I’ve mentioned before that I’ve been looking into quadcopters and built my ZMR250 quadcopter a few months ago which is working well, a few modifications have been made here and there; and some are still to come.

IMG_1186_1 IMG_1504_1

One problem with the transmitter is that there isn’t a way that I’ve found to make it beep or light up if you exceed a certain communication error rate, the further you go or the more objects in your line of sight, the higher the error rate becomes. You can glance down at the remote and check it there but when you are focused on your FPV monitor you can easily forgot so I would like a better way. There may be a way to do it in software but I decided to try the hardware route.

IMG_1461

To start, I thought I’d go digging around the transmitter to see if I could find an RSSI pin by measuring voltages when I had the receiver on the quadcopter in an open space and then compare to in a microwave (as it blocks most of the 2.4GHz radio). I couldn’t find an RSSI pin so it was time to break out the logic analyser and capture data from the radio module, there had to be some communication between the MCU and radio module in order for it to display on the LCD.

tgy-i6-1tgy-i6-2

Once thing that was very noticeable was the GOIO pin would pulse low for about 1.2ms every 57ms when it was in range. When the error rate got higher, it would drop to 150ms and sometimes 300ms but after more testing it seemed unreliable.

tgy-i6-4

When the transmitter and receiver are paired we see the initial TX and then the RX packet, I decoded it using SPI, there was a clock of ~6MHz and 1 data line GOIO. Inspecting both packets gave some similarities but nothing that stood out. After a few more attempts of trying to figure it out I jumped over to the scope, something that I should have done sooner.

tgy-i6-5tgy-i6-6

I applied one close by RX packet as a reference (white) and then captured an RX packet when in the microwave (yellow) to compare the two, after a bit of analysis I found one byte that changed depending on the error rate, as you can see in close proximity there is basically no error. The RSSI byte is found in the RX packet occurring after the FE and 00 bytes.

Now we can move to the code side, I was thinking about using an external shift register to read the serial data but after testing different methods and wanting to keep things simple I settled with using an ATtiny25/45/85’s Universal Serial Interface (USI) to read the incoming data. At a 6MHz serial clock we’ll have to use an AVR clock double that frequency so I went with 16MHz with the PLL like I’ve done before.

// Initialise USI properly, wait for GOIO pin high for a while
uint8_t counter = 0;
while (1) {
	if (PINB & (1<<goioIn)) {
		counter++;
		if (counter >= 30) {
			USICR = (1<<USIWM0) | (1<<USICS1); // Enable USI
			break;
		}
	}
	else {
		counter = 0;
	}
}

With the 6MHz serial clock we don’t have that much time to spare and after testing a few methods, the most reliable method was to initialise the USI after the data pin was high for some time. USI is enabled with external clock input and two wire mode.

while (!(USISR & (1<<USIOIF))); // Wait until new serial data received
USISR |= (1<<USIOIF); // Clear received flag
if (USIBR == 0xFE) { // FE byte
    while (!(USISR & (1<<USIOIF)));
    USISR |= (1<<USIOIF);
    if (USIBR == 0x00) { // 00 byte
        while (!(USISR & (1<<USIOIF)));
        USISR |= (1<<USIOIF);
        
        // RSSI byte
        if (USIBR >= RSSI_COMPARE_TO) { // Change to suit your error rate needs
            OCR0A = USIBR;
            led_on = 1;
        }
        else {
            OCR0A = 0;
            led_on = 0;
        }
    }
}

// Timer overflow
ISR(TIM0_OVF_vect) {
    if (led_on == 1) {
        PORTB |= (1<<led);
    }
}

// Timer OCR0A compare match
ISR(TIMER0_COMPA_vect) {
    PORTB &= ~(1<<led);
}

We monitor the USI and wait until a byte is received, then quickly clear the received flag so we can accept another byte and look for the FE and 00 bytes before reading the RSSI byte. Testing is required on the RSSI_COMPARE_TO until the LED turns on at the error rate that we need, for me I wanted it to turn on around 50-70% or so.  Download TGY-i6_RSSI_LED_Indicator_v1.0

IMG_1470_1 IMG_1474

I put the ATtiny in an IC socket, glued the wires in place and blu-tacked it down, then put the LED above the monitor in the monitor cover.

https://www.youtube.com/watch?v=qMDcZc0PiiA

And here’s a video to show it in action.

20 Responses to “Adding Signal Strength (RSSI) LED to the Turnigy TGY-i6 Transmitter”

  1. Wolfgang says:

    Hallo Alex
    Sorry for my bad english. I have learn english a little bit 50 Years ago.I have buy a Turnigy-i6
    Now i found two Firmenware on the Hobbyking Side.Can you tell me what Version of this two Firmeware i need ? I have the Receiver 6B with Telemetrie Option.
    Question two : When i have two Quads i must bind two Receiver . What i have to do ?
    Thanks for Help and Respect for what you now about electronics.

    • Alex says:

      Hi Wolfgang,

      My TGY-i6 is running v1.1 – 15 Oct 2014 from when I bought it and it works fine. You shouldn’t need to update the firmware unless there is some feature or fix they come out with that you would like. I have heard of users flashing their firmware with the FlySky i6.

      With 2 quads, you just need to change the model memory – Hold Ok, press ok, Model select, change to Model 2, hold cancel for the beep, then press cancel a few more times. It will show the model as “TGY 02”, then power off. Put the receiver in bind mode, hold down the “Bind Range Test” button and power up. Remove the bind connector from the receiver and power off the TGY-i6 TX. Power it back up and confirm it binded ok. Now you can do the same for the other models, just change to Model 3 and re-bind another receiver, etc.

  2. Paul Hilgeman says:

    So since we know it is sending the RSSI info back to the transmitter, how can we get this useful information over to our Flight Controller or OSD board for display on our video overlay?

    Any idea where to pull this info from the IA6 or IA6B receivers?

    Thansk!

    • Alex says:

      That sounds like a good idea, I’ll have open one up and check it out.

      • Alex says:

        I’ve been able to find the pin on the MCU which is giving out the same byte stream as the transmitter with the RSSI byte being in the same location, CLK and DATA pins shown in the picture. The clock speed is 1MHz but there is 4 clock pulse here and there instead of always been 8 all the time so I’ll need to rework the code a bit because it doesn’t work at the moment and then add PWM output to work with MW OSD.

        iA6-Rx2 iA6-Rx

        Edit: The 4 clocks even out and I ended up having to use negative clock edge (spent a while to figure that out). 50Hz PWM generation is done, now I just need to combine it all together and test.

  3. Sebastian says:

    Why are you not using the buzzer for the RSSI-alarm? This would be useful when flying FPV without OSD. It could work the same as the battery alarm.

    • Alex says:

      Hi Sebastian,

      Initially I did think of doing that but I didn’t really want something beeping at me (because sometimes it jumps to a high error rate for just a split second), so I went with the LED option. But it wouldn’t be too hard to add the buzzer option at all, you can grab the output and use a transistor or mosfet to switch 5V to the buzzer.

  4. Roberto says:

    Very nice page!!!
    This code works in arduino nano too?
    Can you help me with this?
    Tks

  5. Ryan says:

    Excuse my ignorance, I don’t know what to do with the code…. 🙁
    I’ll keep investigating. I assume it needs compiling. Someone here mentioned it works with a Nano. I have programmed an Arduino as an ISP so I just need to figure out how to load this onto an ATTiny44.
    Any help will be appreciated.

  6. Ryan says:

    Ok. I think I’m just gonna buy a taranis.

    I love arduino and gadgets but this is more than expected. I actually need to be able to diagnose this. So another arduino receiving info from this one. I have a diy oscilloscope from banggood but I don’t know how to use it well enough.

  7. Tupi says:

    I use telemetry, would it be possible to extract in TX the data received from telemetry? Vbt, Alt, Dist among others? Thanks

Leave a Reply