Tuesday 1 September 2015

NAZE32, X4R, Cleanflight, smart.port and Taranis telemetry.

Having read the great write-up by Frank on how he got a X4R talking smart port to a NAZE32, I assumed I'd be up and running in no time. There were a couple of snags though.

I didn't want to take a soldering iron to my X4R and I wanted to not reverse the polarity, with a hack, because it would be good to hook up other smart port devices, like the battery voltage monitor, among others

So I built a bi directional inverter with a couple of transistors and 4 resistors.




After getting the serial com polarity fixed, there was another issue with the NAZE running Cleanflight.

The current build expects you to have either hacked the X4R or that you have an F3 board where you can reverse the polarity of the uart via the CLI.
I had neither so I did a build with a non bi-directional serial port.

In the configureSmartPortTelemetryPort function in smartport.c, the port is hard coded as SERIAL_BIDIR. The current code expects that the serial connection is sent over a single wire, but I couldn't figure out the circuit to do that. The NAZE doesn't have serial polarity inversion so, I simply changed the line to SERIAL_UNIDIR, and connected Tx and Rx wires to pins 3 and 4 on the NAZE, respectively.


 void configureSmartPortTelemetryPort(void)  
 {  
   portOptions_t portOptions;  
   if (!portConfig) {  
     return;  
   } 
   portOptions = SERIAL_UNIDIR; 
   if (telemetryConfig->telemetry_inversion) {  
     portOptions |= SERIAL_INVERTED;  
   }  
   smartPortSerialPort = openSerialPort(portConfig->identifier, FUNCTION_TELEMETRY_SMARTPORT, NULL, SMARTPORT_BAUD, SMARTPORT_UART_MODE, portOptions);  
   if (!smartPortSerialPort) {  
     return;  
   }  
   smartPortState = SPSTATE_INITIALIZED;  
   smartPortTelemetryEnabled = true;  
   smartPortLastRequestTime = millis();  
 }  

Et voila, Cleanflight telemetry on my Taranis.


Edit: Pic of connections

25 comments:

  1. Great work! Thanks for taking the time to post this. Do you know if this would work with a naze32 rev6? I know I wouldn't need to invert the sbus since rev6 has a built in inverter. I would just like to get the smart port telemetry working. Also, where would one apply this code? I apologize for the numerous questions I'm a bit of a noob when it comes to cleanflight code.

    ReplyDelete
  2. I'm not sure about the V6, I read that the v6 doesn't accept cleanflight just now, but don't quote me on that. The code goes in smartport.c and only the one line highlighted in green needs changing.

    ReplyDelete
  3. Hi

    Thanks for this. Clean flight is working on rev6. And it supports sbus as it has inbuilt inverter.

    Would be good to hear from you steps to just get smart port telemetry working! Where is the smartport.c for located?

    Thanks

    ReplyDelete
  4. Hi

    Thanks for this. Clean flight is working on rev6. And it supports sbus as it has inbuilt inverter.

    Would be good to hear from you steps to just get smart port telemetry working! Where is the smartport.c for located?

    Thanks

    ReplyDelete
    Replies
    1. You'll need to build the firmware from the source after you alter smartport.c. The help file tells you how yo do that here.
      https://github.com/cleanflight/cleanflight/tree/master/docs/development

      Delete
    2. Thanks for this. Would the hardware mod still be needed with Rev6? I currently have SBUS working in Rev6 by connecting +,- and signal to 1, 2 and 4 pins on the Naze32 Rev6.

      Just need to get telemetry working!

      Delete
    3. I can't seem to find any schematics on-line to know if the rev6 is different, but if you still have access to the second serial port then that's all that's required, along with the hardware and software mod above.

      Delete
    4. Hey Paul

      Here you go: http://desdeelairerc.es/1375-thickbox_default/acronaze-32-rev6-new-version.jpg

      I am currently using Pins Gnd, 5V, U2RX/4
      I have OSDoge connected to U1TX & U1RX

      Do you have photos of your mod? And parts list? The only electrical knowledge I have is soldering things etc. If you can help would be great!

      Delete
    5. Nice one. Pins 3 and 4 would do the job, but you are already using them. Smart port needs hardware serial because of the baud rate, so you could move the OSD to softserial and put s-port on u1tx and u1rx.
      I used ztx553 and ztx450 transistors, because I had them kicking about, and the resistors were 10k 1/8w,

      Delete
    6. Hmm..could the U1TX and U1RX not be shared with s.port? Or they need to be separate?

      As I would prefer to keep the OSD. Do you have pics of your cabling connector?

      Appreciate your help so far!

      Delete
    7. No, you can't share a serial port.
      OSD may work on softserial at a slower rate.
      I'll put a pic in the post

      Delete
    8. Damn! OK! Thanks again. I will use the D4R-II with the Naze32 and use the X4R-SB with a different board which has more UART ports and supports S.Port telemetry - like Seriously Dodo!

      Delete
    9. Yeah, ultimate solution is a flight controller with serial inverters on the processor. And plenty of hardware uarts. I guess we just do it on the naze cos we can :-)

      Delete
    10. What use does the OSD have for the TX/RX Pins connector to the FC?

      You look at something like this: http://www.rcgroups.com/forums/showthread.php?t=2527613 and it has no connection of TX/RX to the FC.

      Delete
  5. Hi Paul,
    nice Job.
    is it possible that you upload a ready build Firmware for the Naze 32 full rev5?

    ReplyDelete
    Replies
    1. It's really easy to build, simply follow the building guides in the CF development documentation, you'll always have the latest version, or the one you choose. Here is 1.10.0 with the modification:
      https://goo.gl/9M3izY

      As a side note I got mine to work on soft serial, should I expect glitches and timing errosr? I haven't plugged in the logic analyser but on a scope at least it looks like every request gets a response.

      Delete
    2. That's good, that it runs on soft serial. The only reason I didn't think it would was because the specs say SS can't run at the 57k baud. But if it does... Neat.
      Of the loop time is still OK then, result.

      Delete
    3. Didn't think to look at looptime changes, I'll have to check.

      Delete
    4. Loop time looks fine, but I'm using a conservative 3500ยต.

      Delete
  6. Thanks Kyis for the build i will use it for testing.
    You say that you use softserial port which Pins are hardcoded now?
    Can you make a photo of your Naze32?
    sorry but im new on this

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. Paul you say you connect to Port 3 and 4. But i use Port 4 for sbus Connection of my Frsky x4rsb
    So how to connect the Smart port?
    Is it possible to connect an osd,Gps, smartport and Sbus with this Code ?

    ReplyDelete
    Replies
    1. I used ccpm, so didn't have that problem.
      You could either use softserial as KYiS has done or use the serial port usually connected to the PC. It looks for a telem connection for a few seconds after boot, when not connected to a PC. I should add I've not tried that though, so might not work.

      Delete
    2. Can i usw Pin 7and 8 for softserial?
      will it work with the Build few posts above

      Delete
    3. I used pin 5 and 6 but 7 and 8 should work just the same.
      UART1 doesn't work unfortunately with or without usb connected, not sure why.
      One thing to note, you don't need any inverter or firmware mod with software serial, just connect both tx and rx to the sport, setup smartport on those pins and enable telemetry_inversion on CLI.
      All values look fine but I'm getting weird values in altitude with softserial, there might be just enough timing jitter that the rest of the data is received fine but altitude gets garbled (even thou the protocol is supposed to check sums and it looks reasonably timed with proper value on a logic analyzer...)

      Delete