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
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.
ReplyDeleteI'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.
ReplyDeleteHi
ReplyDeleteThanks 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
Hi
ReplyDeleteThanks 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
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.
Deletehttps://github.com/cleanflight/cleanflight/tree/master/docs/development
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.
DeleteJust need to get telemetry working!
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.
DeleteHey Paul
DeleteHere 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!
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.
DeleteI used ztx553 and ztx450 transistors, because I had them kicking about, and the resistors were 10k 1/8w,
Hmm..could the U1TX and U1RX not be shared with s.port? Or they need to be separate?
DeleteAs I would prefer to keep the OSD. Do you have pics of your cabling connector?
Appreciate your help so far!
No, you can't share a serial port.
DeleteOSD may work on softserial at a slower rate.
I'll put a pic in the post
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!
DeleteYeah, 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 :-)
DeleteWhat use does the OSD have for the TX/RX Pins connector to the FC?
DeleteYou 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.
Hi Paul,
ReplyDeletenice Job.
is it possible that you upload a ready build Firmware for the Naze 32 full rev5?
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:
Deletehttps://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.
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.
DeleteOf the loop time is still OK then, result.
Didn't think to look at looptime changes, I'll have to check.
DeleteLoop time looks fine, but I'm using a conservative 3500ยต.
DeleteThanks Kyis for the build i will use it for testing.
ReplyDeleteYou 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
This comment has been removed by the author.
ReplyDeletePaul you say you connect to Port 3 and 4. But i use Port 4 for sbus Connection of my Frsky x4rsb
ReplyDeleteSo how to connect the Smart port?
Is it possible to connect an osd,Gps, smartport and Sbus with this Code ?
I used ccpm, so didn't have that problem.
DeleteYou 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.
Can i usw Pin 7and 8 for softserial?
Deletewill it work with the Build few posts above
I used pin 5 and 6 but 7 and 8 should work just the same.
DeleteUART1 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...)