LibrePilot Forum

Users => Applications - FPV => Topic started by: jdl on November 21, 2020, 01:22:54 pm

Title: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: jdl on November 21, 2020, 01:22:54 pm
It’s based on the original LP MinOPOSD code. I’ve been playing with it and adding or changing features for some time... The goal is to have in the OSD some vital kinds of information that would help me fly safer in FPV without distracting me during flight.
I believe the result had become useful enough to worth be shared. And I sincerely hope it to be of benefit to the LibrePilot project and community.


Because of program space limitations, I had to sacrifice some features in the original firmware that I’ve found not very useful to me in order to free code space and program new ones that I felt to be more beneficial. Like original MinOPOSD, the code can be compiled (compiler conditional defines) for different targets (CC3D or Revo, Multirotor or Plane) and features included or not.

New stuff:


Video mode might be set to PAL or NTSC like with original MinOPOSD. This is configurable in OSD_JDL_Config tool. I’ve not tested NTSC (I use PAL cams only) but it should work.

GPS coordinates (LAT, LON values) are displayed in xx.xxxxx  format, no letters. This is enough for an approx.  a meter accuracy and saves space on the screen. Negative numbers for coordinates and these with three digits before decimal point are also displayed (can expand to the right).

Current and voltage sensors can be either connected to Revo FC (preferred!) or directly to MinimOSD board. Different precompiled OSD firmwares. If using voltage sensor only, connected to MinimOSD board, and NO current sensor, disable it by setting “Current Sensor Amps Per Volt” and “Current Sensor Amps Offset” to zero (in OSD_JDL_Config tool or in the OSD Setup menu).

To disable LINK QUALITY / RSSI LOW alarms when using OSD without RSSI, just uncheck the "RSSI & LinkQuality" fields on both Panel1 & Panel2 in OSD_JDL_Config tool!

There are some settings that are configurable in the original LP MinOPOSD but are hardcoded in this MinOPOSD JDL version, sorry for that...
I run all my UAVs on LP “next” r735 based firmwares and the MinOPOSD JDL code has UAVObject IDs for r735 but I recall there are no changes in r782 that will affect it and it should match with r782 fine, too.
I’ve also included an option (compiler conditional define) to build the MinOPOSD JDL firmwares for LP 16.09, respective UAVO IDs are there. However, I’ve not tested it recently. It should work, though...


MinOPOSD JDL requires a dedicated matching charset version that comes with OSD_JDL_Config, it should be uploaded to the MinimOSD the same way as with original LP MinOPOSD (through the OSD_JDL_Config tool).

Different precompiled firmware HEX files for different FC targets (Revo or CC3D), UAV types (multirotors or planes) and / or features supported can be also uploaded to the MinimOSD board the same way as with original LP MinOPOSD (through the OSD_JDL_Config tool).

Because of space limitations, some firmwares are compiled WITHOUT the ability to update charset! In such a case, if charset update is necessary:
OSD can support up to three external LM335z temperature sensors (for ESC, Motor and Ambient air temperature monitoring), when battery voltage and current sensors are connected to Revo FC. Detailed how-to instructions shall be added later if there is interest.
Without extretnal LM335z sensors, the OSD displays baro sensor temperature.


All precompiled firmware HEX files, config tool and charset are available on github.
Some combinations were never tested in real as I don’t have such setups (like Multirotor + CC3D + Battery_on_OSD + Safety Radius&Eff), if you find any issues, let me know!

If anyone has interest in compiling the firmware himself, sources (OSD and Config tool) are there, too. OSD requires Arduino 1.0.5-r2; the Config tool – Microsoft Visual Studio 2010.

I’d like to emphasize that I had not made any efforts to make the changes to the source codes prettier, well commented and easier to read. It would be nice, but...  :D


Precomplied firmware (LP 16.09 & LP “next” r.735+) HEX files features matrix

FW#Multi rotorAir planeCC3D   Revo      Battery on OSDBattery on RevoOplink Radio ControlRSSI on Ch10Charset UploaderSafety Radius & EfficiencyGlide Est.WP InfoBatt Type SelectLiHV detectStall Alarm
01X-X-X--X-X---X-
02X-X-X--XX----X-
03-XX-X--XXX--X (noBattCrv)--
04X--XX--XX----X-
05X--XX--X-X (noEff)---X-
06X--XX-X--X---X-
07X--X-X-XXX---X-
08X--X-X-XXX-X-X-
09X--X-XX-XX-X-X-
10X--X-XX--X-X-X-
11-X-X-X-X-XXXX-X
12-X-X-XX-XXXX--X
13-X-X-XX--XXXXXX



Charset .mcm file is located in "/ConfigTool_minOPOSD JDL/OSD Charset/" folder.

HEX files are located in "/ConfigTool_minOPOSD JDL/OSD Firmwares/" folder: https://github.com/jdlilov/MinOPOSD-JDL/tree/main/ConfigTool_minOPOSD%20JDL/OSD%20Firmwares (https://github.com/jdlilov/MinOPOSD-JDL/tree/main/ConfigTool_minOPOSD%20JDL/OSD%20Firmwares)



Config Tool Panels:

(https://github.com/jdlilov/MinOPOSD-JDL/blob/main/PNGs/OSD_Config_Config.png?raw=true)

(https://github.com/jdlilov/MinOPOSD-JDL/blob/main/PNGs/OSD_Config_Panel1.png?raw=true)

(https://github.com/jdlilov/MinOPOSD-JDL/blob/main/PNGs/OSD_Config_Panel2.png?raw=true)



OSD DVR Samples:

https://www.youtube.com/watch?v=vFGtU4ONJ5A (https://www.youtube.com/watch?v=vFGtU4ONJ5A)

https://www.youtube.com/watch?v=wZIDkGz4020 (https://www.youtube.com/watch?v=wZIDkGz4020)

https://www.youtube.com/watch?v=VvMxWt1gUB8 (https://www.youtube.com/watch?v=VvMxWt1gUB8)



GitHub Link: https://github.com/jdlilov/MinOPOSD-JDL (https://github.com/jdlilov/MinOPOSD-JDL)

Download ZIP: https://github.com/jdlilov/MinOPOSD-JDL/archive/main.zip (https://github.com/jdlilov/MinOPOSD-JDL/archive/main.zip)



P.S. (02 Dec 2020) Updated sources and precompiled firmwares (incl. LP 16.09 compatible) to version 2.53.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: TheOtherCliff on November 22, 2020, 05:45:46 am
Wow!  Such a nice gift to the LP community!  Thanks!
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: jdl on November 22, 2020, 07:41:18 pm
Thanks, Cliff!

Its quite insignificant if compared to what the community had given to me! :)
I'd really hope this can contribute to the LP project!
But I'd consider work done if and when I see reports of this OSD version being successfully used in others' builds.


Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: karla on November 23, 2020, 03:32:04 am
Nice!

Quote
   
  • Stall speed warning and alarm for planes. Stall speed threshold can be set in the OSD_JDL_Config tool.
I think this was hardcoded in the version you posted before, much appretiated :)
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: jdl on November 23, 2020, 07:25:01 am
Nice!

Quote
   Stall speed warning and alarm for planes. Stall speed threshold can be set in the OSD_JDL_Config tool.

I think this was hardcoded in the version you posted before, much appretiated :)

I've managed to squeeze few more bytes and make the stall speed warning threshold configurable. :)
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: TheOtherCliff on November 23, 2020, 08:26:13 am
I watched the videos and when I saw time/distance to waypoint I had a big smile on my face.  :)  After that I read all the features carefully!!!

Does the config tool run under Linux/Wine?  Wish list: Config tool source on a cross platform framework so it can be built under Windows, Linux, or MacOS.  Sorry.  Had to say it.  ;)
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: jdl on November 23, 2020, 12:15:50 pm
I watched the videos and when I saw time/distance to waypoint I had a big smile on my face.  :)  After that I read all the features carefully!!!

Added this recently. WP info is calculated the same way as in the PFD (GCS).

Does the config tool run under Linux/Wine?  Wish list: Config tool source on a cross platform framework so it can be built under Windows, Linux, or MacOS.  Sorry.  Had to say it.  ;)

Config tool: Windows only, .NET 3.5

I'd like to but have no experience there... :(
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on November 23, 2020, 10:31:32 pm
Cool! So I tried this on the minOPOSD cards I just got. It seems to work with 16.09 as far as I've tested. I tried the 04 ucode version.
A few questions:
I'm setting for a multirotor and want to monitor battery voltage for a 4s battery. I have it currently plugged into the BAT1 pin, but I'm not seeing any voltage change.
I don't need to switch panes or manually initialize - I do that all through this setup. I don't have Ch7 in use for anything, so it seems to be giving me a telcom error message. Any way to turn this off?
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on November 24, 2020, 05:29:33 am
I did some more testing on the MinOPOSD board with the new code. Turns out with code 04 it now pulls the battery input from what was the current monitor pin on the PCB. It also does not seem to have a voltage divider - 0V reads 2.1V with the default settings and 1.1V is the max and reads as 16.6V - 1.1 V is the reference V on the A/D and max input V to the A/D. I'll try sticking a 14.7K resistor on it for my 4s batteries. Input to gnd measures 812ohm so may need to tweek the calibrate R divider values. Seems like there is an offset value that can be entered also in the setup - current offset?
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: jdl on November 24, 2020, 10:02:45 am
This (04) OSD firmware will not properly work with LP16.09, it has UAV Objects definitions matching current "next". This is most probably the reason you are getting "NO TEL COM" warnings!

Here I've compiled and attached the HEX file for firmware 04 that should work with LP16.09, please try it.

As for battery voltage, there is something strange, I've looked at the code and saw that it reads Atmega 328p analog pin 6 ?! The same is in the original LP MinOPOSD source, I've changed nothing here...

OSD_Config.h
Code: [Select]
// JRChange: Flight Batt on MinimOSD:
// #define FLIGHT_BATT_ON_MINIMOSD

// Add MicroOSD KV team mod
// #define MICRO_OSD_KVTEAM

// JRChange: Flight Batt on Revo:
//#define FLIGHT_BATT_ON_REVO

FlightBatt.h
Code: [Select]
#if defined MICRO_OSD_KVTEAM

#define VOLTAGE_PIN       0                       // Micro OSD KV team : Bat1
//#define VOLTAGE_PIN       2                       // Micro OSD KV team : Bat2
#define CURRENT_PIN       1

#else

#define VOLTAGE_PIN       6
#define CURRENT_PIN       7

#endif


I've only one UAV build that uses battery monitoring on OSD and it still works fine with my firmware (on pin 6). However, the MicroMinimOSD module on it is at least 5 years old. Cannot tell if it looks the same as nowadays ones as it is wrapped in thermofit but I suspect it differs...

I've traced the connections on a recently bought MicroMinimOSD and here is how the PCB pads and Atmega 328p analog inputs are matched on it:

CURR - A1
RSSI  - A3
Batt2  - A0
Batt1  - A2

Funny that Batt1 and Batt2 seem to are swapped on this particular board, compared to definitions in FlightBatt.h for MICRO_OSD_KVTEAM :)

CURR pad is not suitable for monitoring voltage, unless you make the voltage divider yourself (one 1k resistor from the CURR pad to the GND and one 15k resistor from the CURR pad to the battery terminal.

Anyway, please try the firmware I've attached here with battery connected to Batt1 (right-most pad). If still not getting plausible voltage readings, try connectiong the battery to Batt2 pad (the one to the left).
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on November 24, 2020, 11:08:09 pm
Ok! Tested this and checked the batt1 input pin R to gnd (15.5k, so it does have the divider). I had to change the divider ratio to 18.9 to get it to match the battery voltage (divided by 4). But it now reads an average cell voltage.
Everything else I checked seems to work fine now! GPS is showing num of satellites, mag is showing direction properly (my previous versions didn't work at all on this).
All good! Thanks!
Attached is image of unit as I have it wired.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: jdl on November 24, 2020, 11:32:49 pm
Glad to hear it works for you :), I've never tested this exact configuration (Revo FC + Batt on OSD).

But I'm little puzzled about what you said about "reading an average cell voltage"!? OSD should display number of cells detected and total battery voltage, not the averaged voltage per single cell. If a single cell voltage is displayed, this is not right and I'll fix it!

Here is a screenshot of what is expected to get in OSD about battery voltage when using Batt-On-OSD firmware. Do you see it this way in your OSD?

I'd appreciate if you can share a screenshot showing how is the battery voltage displayed.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on November 25, 2020, 12:35:19 am
Weird. Here's a pix - I have a different layout, but the V going to the input IS 4S, but I'm only seeing one cell appearing. So I get a Battery Low alarm, plus I still get a link alarm.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: jdl on November 25, 2020, 09:28:34 am
Weird. Here's a pix - I have a different layout, but the V going to the input IS 4S, but I'm only seeing one cell appearing. So I get a Battery Low alarm, plus I still get a link alarm.

Weird indeed! The OSD reads Batt1 voltage below 5V and detects it as s single cell battery. I've briefly checked the code and could not find issue there... Analog reference is being correctly set to INTERNAL (1.1V), I had a doubt about that but it seems right.

About LINK QUALITY alarm - this was expected as OSD is compiled with RSSI monitoring on Ch10. I've added an extra check to NOT display RSSI warnings at all when there is not RSSI field set on either of OSD panels.

Here is a fresh HEX file that should not monitor RSSI on Ch10 and not issue LINK QUALITY warnings at all. Again, you must check in Config tool that RSSI & Link Quality field is disabled / not checked in both Panel1 & Panel2.

When I get back home, I'll flash the same HEX on my CC3D quad (battery voltage is also read in OSD there) to see if it displays correctly the battery cells count and total voltage.

Can you do one more check: please, measure again (with multimeter) the 4S voltage coming to OSD board, with probes touching directly the Batt1 and GND pads on MicroMinimOSD board.

What is the value set in Config tool for Battery (Single Cell) Warning Level (V) ?
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on November 25, 2020, 07:40:23 pm
That fixed the Link error.
I think I've got a lead for you on the battery problem. On my system, I have separated the power going to the FC,OPOSD,escs,rcvr,OPLINK and the camera,vidxmtr - which includes the 4s power lead that goes to the OSD to measure battery voltage. Sometimes I don't want to bother with all the video stuff and just fly the plane.
I normally plug the FC combo in first, then the cam/xmtr.
If I reverse the order and plug in the cam/xmtr FIRST then the number of cells come up correctly, and the V starts OUT at the right value, then decreases steadily until it gets to a one cell value. The cell count stays correct at 4s. The battery percent keeps decreasing after the bat V stabilizes.
I checked the voltage and it is definitely 15+ volts. Cell warning is set at 3.0V

I looked at your code - seems ok. I gather batt_type is force set to 1 or lipo. I get the sampling filter(s) and the num_cell calculator. Does num_cell get locked in somehow?
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: jdl on November 25, 2020, 08:19:14 pm
I've just flashed this same HEX on my CC3D quad. Of couse, NO TEL COM error as it runs firmware LP next 735 and the OSD firmware is for older 16.09, this was expected.

But battery voltage monitoring stuff works flawlessly!  I've tested it with 4s and with 2s batteries and I confirm the code is ok, cells count is detected correctly and battery voltage too, i.e. 15.33V on the 4S battery. The voltage reading is steady. Battery percentage is steady, too.

My best guess is an electrical issue in your setup like a floating / loose ground or some kind of ground loop. But I would not bet on either of these particular suggestions :(
Its resembles like there is a large capacitor between the voltage divider and the Atmega adc pin?!

Cell warning threshold of 3.0V is suitable for Liion, for Lipo this is disastrously low!

Correct, batt_type is force set to 1 (lipo) in this particular firmware as BatteryType Selection code is not included / disabled in it.

num_cells starts with value "1" on OSD boot. Later, it can go only up if higher voltage is detected, but never goes down. This meanes the cells count depends on the highest voltage seen from OSD firmware since boot up.

Code: [Select]
          if (voltage > 21.8)                            // min 3.63V for 6-cell (21.0-25.2)    (21.0-26.1)
            num_cells=6;
          else 
            if ((voltage > 17.45) && (num_cells < 5))    // min 3.49V for 5-cell (17.5-21.0)    (17.5-21.75)
              num_cells=5;
            else 
              if ((voltage > 13.2) && (num_cells < 4))   // min 3.30V for 4-cell (14.0-16.8)    (14.0-17.4)
                num_cells=4;
              else
                if ((voltage > 8.8) && (num_cells < 3))  // min 2.93V for 3-cell (10.5-12.6)    (10.5-13.05)
                  num_cells=3;
                else 
                  if ((voltage > 5.0) && (num_cells < 2))// min 2.50V for 2-cell (7.0-8.4)      (7.0-8.7)
                    num_cells=2;                             

This explains your observation that cells count stays at 4s while voltage drops down.

What value is displayed for battery percent when voltage drops below 4V while cells count remains 4s?
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on November 25, 2020, 08:51:19 pm
In the scenario where I plug the V into the OSD first, and get 4 cells, the V displayed settles on 3.94V, but capacity keeps getting smaller and smaller and eventually goes down to like 2%.
I tried another test. I have the V into the OSD batt1 pin on separate plug. I plugged in everything except the batt1 pin. The OSD displays 0V and 1 cell - oddly capacity shows at 55%. Then I plug in the batt1 pin. Battery voltage V climbs to 3.94V (the correct V of a 4s divided by 4) - but num_cell stays at 1. Capacity climbs to 82% and holds.
I wasn't too concerned about the battery low warning - I usually just look at the voltage to determine the cutoff point, but I'll change that in the setup to a more reasonable value like 3.5V
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: jdl on November 25, 2020, 10:11:19 pm
Thanks for tests!
I've got something :) ! If per-cell voltage is far below what I've considered a completely depleted cell (under load) - appox. 3.4635V (or even "0" in extreme case) the percent calculated is negative. When Voltage-to-Remaining Capacity correction curves are used, this could cause Out-Of-Range (index > 99) error situation when performing table read (0..99) with this negative value converted to unsigned int.

I've made some code changes. This is the fixed HEX file. It should fix the abnormal voltage percent display in your second test when voltage is read "0V" and one cell detected.

Do not know, however, if it'll help with the problem with voltage reading creeping from approx 16V to 3.94V...
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on November 25, 2020, 11:21:13 pm
Ok. Tested. Yes, it fixed the bat capacity issue. Now if I plug in everything except the batt1, it reads 1 cell and 0V. Plug in batt1 and it rises up to 3.94V, and the capacity goes up to 81%. Good!
But it still only reads 1 cell.
Reversing the order, plugging in batt1, then the cam/xmtr, then the fc+OPOSD+, it starts at 4cells and 15+V, then ramps down to 3.94V, plus capacity goes to about 2%, but num_cells stays 4.

I did have another weird issue. I had changed the voltage divider value, the bat capacity value to 2200 and the warning level to 3.0 in previous versions. I did a read OSD of the device, then tried changing the batt warning value in the config tool. I enter 3.5, hit enter, and the config tool crashes and goes away. I note also there were some odd values on the current items in the GUI.
I restarted the config tool, then manually reentered all the values BEFORE doing anything to the device, then hit write. Then everything was ok, and now the battery low warning is gone.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: jdl on November 25, 2020, 11:57:17 pm
Ok. Tested. Yes, it fixed the bat capacity issue. Now if I plug in everything except the batt1, it reads 1 cell and 0V. Plug in batt1 and it rises up to 3.94V, and the capacity goes up to 81%. Good!
But it still only reads 1 cell.
Reversing the order, plugging in batt1, then the cam/xmtr, then the fc+OPOSD+, it starts at 4cells and 15+V, then ramps down to 3.94V, plus capacity goes to about 2%, but num_cells stays 4.

Expected this. Glad to know that battery percent is now correct even in extreme cases.

But why OSD reads 3.94V remains a mystery... It might even be a deffective atmega chip or bad solder joint on OSD PCB. Still cannot replicate the situation, and never had similar...

Have you tried with another battery or the same one, but charged to a different level, e.g approx. 16.8V (4.2V per cell). Does OSD displays agaiv 3.94V or smth. like 4.18V?


I did have another weird issue. I had changed the voltage divider value, the bat capacity value to 2200 and the warning level to 3.0 in previous versions. I did a read OSD of the device, then tried changing the batt warning value in the config tool. I enter 3.5, hit enter, and the config tool crashes and goes away. I note also there were some odd values on the current items in the GUI.

Batt capacity has no use in this firmware (04). It it saved to EEPROM but not even read by this OSD firmware (N#04).
If you had odd values on current items, I can suggest either previous write to EEPROM (from Config tool) had failed or you hadn't set them to "0" when initially setting up OSD.
If you don't have current sensor connected, these values must be set to "0".


I restarted the config tool, then manually reentered all the values BEFORE doing anything to the device, then hit write. Then everything was ok, and now the battery low warning is gone.

This is the best practice in this situation. OSD firmware does not reset EEPROM to defaults upon initial install (discarded the corresponding code to save space), user has to do this manually with Config tool (as you did)!
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on November 26, 2020, 12:34:36 am
Another data point.
I recoded another OSD device on a quad I have using this latest firmware and charset, using the config from the other boards. It is not identical PCB, but pretty close.
I ended up resetting the divide ratio to the default.
On this system, I have to plug in the cam/xmtr first, or for some reason the OSD will not run - I get nothing on the display.
But when I do, it DOES display properly, and gets the correct cells and battery voltage! Yah! Pix enclosed.
One oddity - the battery voltage and capacity are fluctuating a lot.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on November 26, 2020, 12:47:09 am
Here's a suggestion you might try:
Disconnect your battery input to the OSD or put a switch inline.
Plug everything else in.
Then switch in the batt1 connection - see if it gets to the correct cells and voltage.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: TheOtherCliff on November 26, 2020, 01:04:03 am
Unrelated to your discussion with @trust

num_cells starts with value "1" on OSD boot. Later, it can go only up if higher voltage is detected, but never goes down. This meanes the cells count depends on the highest voltage seen from OSD firmware since boot up.

I wonder if some setups could see more cells than they have, like from LC resonance with long wires and not enough C.  I worry too much.  They should just smooth the voltage reading with an RC network; add C in the voltage divider.

(Interesting story:  One cheap model I bought that came with motor in a pod and ESC had long ESC wires.  You could hear a high whine that changed a lot during load changes in a loop; smoothly increased whine frequency (sounded about ~1kHz) under high load, opposite of what you would expect from prop.  I actually suspect this was from the ESC output wires but smoothly changing frequency doesn't fit my expectation of fixed frequency 8kHz 16kHz PWM?)

Forgive me.  I must be bored.  :)

Code: [Select]
          if (voltage > 21.8)                            // min 3.63V for 6-cell (21.0-25.2)    (21.0-26.1)
            num_cells=6;
          else 
            if ((voltage > 17.45) && (num_cells < 5))    // min 3.49V for 5-cell (17.5-21.0)    (17.5-21.75)
              num_cells=5;
            else 
              if ((voltage > 13.2) && (num_cells < 4))   // min 3.30V for 4-cell (14.0-16.8)    (14.0-17.4)
                num_cells=4;
              else
                if ((voltage > 8.8) && (num_cells < 3))  // min 2.93V for 3-cell (10.5-12.6)    (10.5-13.05)
                  num_cells=3;
                else 
                  if ((voltage > 5.0) && (num_cells < 2))// min 2.50V for 2-cell (7.0-8.4)      (7.0-8.7)
                    num_cells=2;                             

:) Sample code could be replaced with a loop to save some space (and even increase max cell count) if you are code space critical.  :)
Code: [Select]
  #define MAX_CELLS     8
  #define MAX_CELL_V    4.40 /* high voltage lipo is 4.35 */
  #define TOTAL_V_FUDGE 0.20 /* help for inaccurate v dividers */

  // even calcs correct cell count for zero / near-zero / negative volts
  for (int cell_count=MAX_CELLS; cell_count>=0; --cell_count) {
    // if voltage is higher than the next smallest cell count max v
    if (voltage > (cell_count-1)*MAX_CELL_V + TOTAL_V_FUDGE) {
      num_cells = cell_count;
      break;
    }
  }

Test program output and program
Code: [Select]
cliff@i925 ~/Desktop $ ./celltest
voltage +0.10
cell count 8   requires more than 31.00V   requires more than  3.88V/cell.
cell count 7   requires more than 26.60V   requires more than  3.80V/cell.
cell count 6   requires more than 22.20V   requires more than  3.70V/cell.
cell count 5   requires more than 17.80V   requires more than  3.56V/cell.
cell count 4   requires more than 13.40V   requires more than  3.35V/cell.
cell count 3   requires more than  9.00V   requires more than  3.00V/cell.
cell count 2   requires more than  4.60V   requires more than  2.30V/cell.
cell count 1   requires more than  0.20V   requires more than  0.20V/cell.
num_cells 0

cliff@i925 ~/Desktop $ cat celltest.c
#include <stdio.h>
#include <stdlib.h>

#define MAX_CELLS     8
#define MAX_CELL_V    4.40 /* high voltage lipo is 4.35 */
#define TOTAL_V_FUDGE 0.20 /* help for inaccurate v dividers */

void main() {
  float voltage;
  int num_cells;

  voltage = 0.1f;
  printf("voltage %+5.2f\n", voltage);

  // even calcs correct cell count for zero / near-zero / negative volts
  for (int cell_count=MAX_CELLS; cell_count>=0; --cell_count) {
    if (cell_count) printf("cell count %d   requires more than %5.2fV   requires more than %5.2fV/cell.\n", cell_count, (cell_count-1)*MAX_CELL_V + TOTAL_V_FUDGE, ((cell_count-1)*MAX_CELL_V + TOTAL_V_FUDGE) / cell_count);
    // if voltage is higher than the next smallest cell count max v
    if (voltage > (cell_count-1)*MAX_CELL_V + TOTAL_V_FUDGE) {
      num_cells = cell_count;
      break;
    }
  }

  printf("num_cells %d\n", num_cells);
}
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on November 26, 2020, 01:05:51 am
It occurred to me I could try this myself on the older OSD. I did. After power up V was 0.
Plugged in batt1. It quickly ramped to 4 cells and 15.X volts. So it does work there too.
There must be something weird in the new versions of the newer boards I have, or some strange grounding issue on my mini Hellaplane (the eVTOL planes we're building).
I am having some trouble with the video. Everything is fine until I ramp up the power - then the OSD data flickers.
If I turn off the video input, the OSD data is fine by itself with the power ramped up.
I do have grounds out to the camera and video xmtr coming from the gnds next to the in/ou pins.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: TheOtherCliff on November 26, 2020, 01:13:46 am
I had an OSD flicker problem that turned out to be voltage.  It only happened with fresh battery at high motor load, or more often at the end of the flight.

Using 3S for the OSD 12V requirement didn't work well for me.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on November 26, 2020, 01:35:04 am
Cliff did you get the new versions of the OSD you ordered yet? Another data point will be helpful.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: jdl on November 26, 2020, 11:13:35 am
(Interesting story:  One cheap model I bought that came with motor in a pod and ESC had long ESC wires.  You could hear a high whine that changed a lot during load changes in a loop; smoothly increased whine frequency (sounded about ~1kHz) under high load, opposite of what you would expect from prop.  I actually suspect this was from the ESC output wires but smoothly changing frequency doesn't fit my expectation of fixed frequency 8kHz 16kHz PWM?)
Could that be the switching 5V voltage regulator inside the ESC? It varies its frequency depening on the load and input voltage. But it must be  much higher than 1kHz... The whine could be emitted from the (low quality?) inductor? Just guessing...


:) Sample code could be replaced with a loop to save some space (and even increase max cell count) if you are code space critical.  :)

Code: [Select]
  #define MAX_CELLS     8
  #define MAX_CELL_V    4.40 /* high voltage lipo is 4.35 */
  #define TOTAL_V_FUDGE 0.20 /* help for inaccurate v dividers */

  // even calcs correct cell count for zero / near-zero / negative volts
  for (int cell_count=MAX_CELLS; cell_count>=0; --cell_count) {
    // if voltage is higher than the next smallest cell count max v
    if (voltage > (cell_count-1)*MAX_CELL_V + TOTAL_V_FUDGE) {
      num_cells = cell_count;
      break;
    }
  }


Very helpful comment, thanks!! 
Initially this code was intended to just distinguish 3S from 4S LiPo batteries...

I admit nested "if"s are ugly solution. Lot of code space is wasted. Your suggestion saves 90 bytes ;)

However I see some drawbacks. Equally spaced thresholds do not always properly work for cells count detection for 4S and above. For example a voltage 17.4V can be either fully charged 4S LiHV battery or a relatively discharged 5S LiPo (or LiHV) battery under heavy load.

These are the thresholds and the respective ranges I consider more suitable:
Cells     Total V Threshold     Min V per cell     LiPo range    LiHV Range
621.80V3.63V21.0 - 25.221.0 - 26.1
517.45V3.49V17.5 - 21.017.5 - 21.75
413.20V3.30V14.0 - 16.814.0 - 17.4
38.80V2.93V10.5 - 12.610.5 - 13.05
25.00V2.50V7.0 - 8.47.0 - 8.7


The cells count calculator code continuously monitors the sampled (and filtered) battery voltage. Once detected, num_cells should not be allowed to go down during flight. If allowed to be decreased, at some moment under heavy load and near depleted battery, the voltage will drop well below the threshold and once the cells count goes down, the estimated per_cell voltage will become erroneously high and this will disable "LOW BATT" alarm (which is per_cell threshold dependant) when it is most necessary.

I've slightly evolved your suggested code (now it suits for 1S-6S batteries) to use predefined thresholds and prevent num_cells from being decreased.

Code: [Select]
          // OSD_Vars.h
          static int num_cells = 1;
          ......

          // FlightBatt.ino
          static const float batt_levels[5] = {5.0f, 8.8f, 13.2f, 17.45f, 21.8f};

          for (int cell_count=6; cell_count>1; --cell_count) {
              if ((voltage > batt_levels[cell_count-2]) && (num_cells <= cell_count)) {
                  num_cells = cell_count;
                  break;
              }
          }

This saved two more bytes.
Again, thanks for pointing me that!! :)
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: jdl on November 26, 2020, 11:22:09 am
Another data point.
I recoded another OSD device on a quad I have using this latest firmware and charset, using the config from the other boards. It is not identical PCB, but pretty close.
I ended up resetting the divide ratio to the default.
On this system, I have to plug in the cam/xmtr first, or for some reason the OSD will not run - I get nothing on the display.
But when I do, it DOES display properly, and gets the correct cells and battery voltage! Yah! Pix enclosed.
One oddity - the battery voltage and capacity are fluctuating a lot.

It looks like the charset is not uploaded sucessfully?!

Neither voltage, not capacity should fluctuate... Looks like you have a lot of noise in the power system, this may be caused by noisy switching voltage regulator, it can emit noise not only on its output, but can inject it in its input line, too! A simple LC filtering circuit between battery and the OSD Batt1 pad may help.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: TheOtherCliff on November 26, 2020, 11:33:32 am
Cliff did you get the new versions of the OSD you ordered yet? Another data point will be helpful.

Sorry.  I haven't ordered any OSDs in a couple years.  I might have referred to new OSDs as being my Micro MinimOSD with the KV team mod?
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: jdl on November 26, 2020, 11:34:18 am
I am having some trouble with the video. Everything is fine until I ramp up the power - then the OSD data flickers.
If I turn off the video input, the OSD data is fine by itself with the power ramped up.
I do have grounds out to the camera and video xmtr coming from the gnds next to the in/ou pins.

I suppose the flickering you describe is caused by ground loop!

On the other hand, MicroMinimOSD is quite demanding for its +5V power supply. To avoid blackouts/flickering  during throttle bursts and/or interference from ESCs, I do always power MicroMinimOSD from a reliable +5V supply through an aditional LC filter (100 to 330uH inductor / 1000uF(6.3V) capactior), the capacitor being soldered directly to MicroMinimOSD power pads. And ONLY ONE ground wire goes to OSD board!
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on November 26, 2020, 07:08:55 pm
I'm using bare ESCs - no battery eliminator. I generate my 5V from a LM1085 3A regulator with a fairly big heat sink and 10uf caps on in/out.
1000uf cap LC filter! Wow. OK! I may try that or at least a big cap.
I did add a 10uf cap on the GPS/mag 5V cable - it seemed to help with the GPS/mag issues.
My 5V power goes to the rcvr, then the throttle 3 pin cable supplies power to (almost) everything else - GPS/mag, OPLINK, and OPOSD through their respective cables from the FC. I get ground for the servos from the receiver, as the FC doesn't provide a decent high current ground.
The Runcam (an older 2K) gets power from a separate cable that is driven from the 5 pin charging plug of the battery. I tap the 2s point for power - otherwise the xmtrs get way too hot on 4s, even though they're supposed to work. I have an extra heat sink on it.
I tried several DC-DC switching converters to power the cam/xmtr combo, but they tended to blow up or the xmtr would not work. I had one that worked for a while, until I noticed the rating was only good to 15V in - so I pulled it and went back to the tap approach. Yes, I balance my packs religiously.
 So ground for the cam/OPOSD/xmtr comes from the battery charging cable. The runcam has a two wire plug with ground that I plug into the video input, same 2 wire with video output. Batteries share the black ground, so that is the ccomon ground point. But unfortunately that can cause ground loops to the OPOSD through the video ground cables. If I don't ground the video cables, I get WAY higher noise on the video output.
Not the best approach,

Cliff, yes I was referring to your KV mod OPOSDs.
I just want to find a source for one of these small square units that works reliably with this new code! The ones I have I guess are usable even if they don't quite work properly with the battery monitor code. As long as I can get values I can check for battery level that track the actual battery capacity (don't need high accuracy) I'm happy. I have a rcvr/DVR I set to record the flights so I can look at the data that's lightweight and convenient.
Does anyone know current sources for these OSD boards?
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on November 26, 2020, 07:31:37 pm
A HUGE Thanks to you two and the Librepilot community for all the help you've supplied. We would never have been able to accomplish what we have - and had fun doing it! - without your help. Hopefully we can also help with testing and feedback - let us know if there are things you want us to try.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on November 27, 2020, 08:21:56 pm
FYI - I added a 10uf cap right on the PCB power in leads - it definitely helped the flickering issue - now it still flickers a little, but not too bad. So I've ordered some 100uf 10V caps - will try those when they arrive. Biggest ones radial dipped I can find - the 1000uf are much pricier and axial leads. Judging by the improvement with 10uf the 100uf may be good enough, or adding the inductor to make a low-pass filter.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: jdl on December 02, 2020, 04:50:46 pm
Updated sources (discussed fixes included) and precompiled firmwares (v2.53).

LP16.09 compatible precompiled firmwares are also available for download.


FYI - I added a 10uf cap right on the PCB power in leads - it definitely helped the flickering issue - now it still flickers a little, but not too bad. So I've ordered some 100uf 10V caps - will try those when they arrive. Biggest ones radial dipped I can find - the 1000uf are much pricier and axial leads. Judging by the improvement with 10uf the 100uf may be good enough, or adding the inductor to make a low-pass filter.

100uF is better but may still not be enough.

https://www.aliexpress.com/item/32334407922.html (https://www.aliexpress.com/item/32334407922.html) - Just for reference, you definitely don't need 100pcs.

Miniature electrolytic caps (470uF or 1000uF/6.3V) can be scavenged from old PC motherboards ;)

Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: TheOtherCliff on December 03, 2020, 10:18:10 am
One of my favorite electronics salvage pieces is a dead PC power supply.  The living ones from dead PC's get repurposed into 12V power supplies for charging lipos and bench lipo replacement power and 5V for bench power.

But eBay has all kinds of assortments.  I bought myself some resistor and capacitor assortments for Christmas a few years ago.

120 electrolytics 0.22uf to 470uf for about $3 shipped.
https://www.ebay.com/itm/Portable-120PCS-Set-12-Values-0-22UF-470UF-Electrolytic-Capacitor-Assortment-Kit/114531752679

a search for capacitor assortment (sort it by price)
https://www.ebay.com/sch/i.html?_nkw=capacitor+assortment


And everybody needs one of these, an inductance, capacitance, resistance (LCR) meter.  To tell you if your capacitors are good or dried out.  Troubleshoot AC start capacitors!  It also tells you what your mystery 3 pin devices are, transistor, triac, etc, etc.  It's just magic.  :)  I think this one is assembled and not a kit.  For searches, make sure you are buying a meter, not just the case.  Make sure you file a "not received" if it doesn't arrive on time.
https://www.ebay.com/itm/LCR-T4-ESR-Meter-Transistor-Tester-Diode-Triode-Capacitance-Inductance-SCR-U9H6/303643622349
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: jdl on December 03, 2020, 10:53:53 am
Another data point.
I recoded another OSD device on a quad I have using this latest firmware and charset, using the config from the other boards. It is not identical PCB, but pretty close.
I ended up resetting the divide ratio to the default.
On this system, I have to plug in the cam/xmtr first, or for some reason the OSD will not run - I get nothing on the display.
But when I do, it DOES display properly, and gets the correct cells and battery voltage! Yah! Pix enclosed.
One oddity - the battery voltage and capacity are fluctuating a lot.

I'm currently experimenting with a potential stability improvement that should help with this situation (OSD not initializing when started without video-in signal).

The MAX7456 chips used in these cheap MicroMinimOSD boards seem to be of a variable quality, some of them do reset/lock up (during flight) when ambient temperature drops below approx. 8-10degC, some of them would not start at all when colder, some do not properly start every time if no video input signal is present...

I've recently had few embarassing moments with my GepRC quad (first time used in colder weather). During flight I've got unexpected blackouts (0.1 .. 1seconds) then video back but without any OSD data. I've traced the issue to MAX7456 chip in the OSD that resets/stalls when getting colder. Searching the net revealed this issue is not not uncommon...

No doubt, I'm going to replace the problematic MicroMinimOSD module on this quad with another, stable one.

I've got some inspirations looking at ShikOfTheRa/scarab-osd MWOSD repository. Hardware reset of MAX7456 (while OSD is running) is not possible with MicroMinimOSD boards, as its reset pin is directly connected to the reset pin of ATMEGA328p and cannot be controlled from the code. However, software reset option seems to perform very well, at least for (freezingly) cold starts and starts without video-in signal.

With v2.53 firmware the replacement OSD module (still not mounted on the quad) sometimes have issues to properly initialize when started on USB power and without video-in signal present (room temperature). It cannot start at all when kept in freezer at -22degC :) However, once started while being warm and then put in the freezer, it runs without resets/locks for hours so I presume it's a good chip!

With the test firmware, the very same OSD module starts reliably EVERY time (without video-in from camera, at room temperature) and, which is more important - starts reliably EVERY time in the freezer (no video-in, again).

I hope it could also restart the MAX7456 if it locks in flight but that has to be tested on my bad OSD module once dismounted from the quad, as I cannot simulate the situation with the new (presumably good) OSD module.


@trust: It'd be interesting to know if this experimental firmware (HEX file attached) will work for you on the UAV you've mentioned. With it, the OSD should start fine even without cam/vtx plugged in, at least I hope so :)

Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on December 07, 2020, 09:46:37 pm
Have not tried this code yet. I seem to have wrecked one of the two (sort of) working OPOSD boards I have - not sure exactly what happened - it also took out my GPS/mag. But everything else seems fine. It blinks so the cpu must be working but the overlay does not appear anymore. I swapped in the other one and another GPS/mag and they seem to work fine.
  Have you found another reliable source for these boards? I want to get a bunch more.
BTW - plz message me when you want to get a quicker response. I don't check all the threads Im in all the time, but messages I check. Thanks
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: TheOtherCliff on December 08, 2020, 01:08:43 am
There is currently only a small amount of traffic on the forum.  The easiest way to stay up-to-date is to look at the list of recent posts at the bottom of the main forum page:
https://forum.librepilot.org/index.php

... and simply refreshing that page will pop up a an alert if you have any personal messages.  :)
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: jdl on December 08, 2020, 10:42:18 am
Have not tried this code yet. I seem to have wrecked one of the two (sort of) working OPOSD boards I have - not sure exactly what happened - it also took out my GPS/mag. But everything else seems fine. It blinks so the cpu must be working but the overlay does not appear anymore. I swapped in the other one and another GPS/mag and they seem to work fine.
  Have you found another reliable source for these boards? I want to get a bunch more.
BTW - plz message me when you want to get a quicker response. I don't check all the threads Im in all the time, but messages I check. Thanks

I recall I'd burned a MicroMinimOSD unit once ago when I'd disconnected (by accident) its ground wire while being powered and video-in and out connected. That particular setup had separate ground wires going to camera, osd and vtx (not a good practice!).

Still waiting for my ordered MicroMinimOSD boards... Will test and report if good once they arrive.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: jdl on December 21, 2020, 10:34:41 am
Updated OSD source on github to version 2.56.

New features:

1. Doubled SPI rate.
2. MAX7456 stalled state detection and soft reset attempt.
3. Fix an issue with black levels autodetect when video-in comes from Runcam2-4K HD Cam feed.



I've encountered a problem with Runcam2-4k HD camera FPV feed. It is common for MicroMinimOSD modules having MAX 7456 or AT7456E chips.

https://www.youtube.com/watch?v=7XF20lnMex0 (https://www.youtube.com/watch?v=7XF20lnMex0)

I've checked the Runcam2-4k video output signal, its level (Vp-p) is OK. The problem probably comes from camera internal processing, image brightness seems boosted a lot, incl. shadows. MAX7456 obviously struggles to properly autodetect black levels.

The fix is to switch off black levels autodetection in MAX7456. I've set the OSD white level to 100% and black level to 10%. The result satisfies me, works fine for Runcam2-4k HD Cam and for dedicated FPV cams (e.g. Runcam Eagle2), too.

Here is demo clip WITHOUT fix applied:

https://www.youtube.com/watch?v=9FyfKJU_eLM (https://www.youtube.com/watch?v=9FyfKJU_eLM)


And now with #define RUNCAM2_4K_FIX

https://www.youtube.com/watch?v=0qT_ak9L1zw (https://www.youtube.com/watch?v=0qT_ak9L1zw)



Anyone can compile the OSD 2.56 firmware from source with desired features included.

Or just post a request here, I'll compile it for you.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on December 21, 2020, 07:55:21 pm
Interesting. Yes, please provide a hex file here. I use a lot of the Runcam 4K cameras. i recently added one to an older OSD board with your latest code - it seemed fine but then I haven't tested it in low light, only outdoors. I use the batt1 input for battery voltage detection. For some reason on this older system, the indicated voltage moves around a LOT - I can't get a clear indication of what the true battery voltage is. Here's the downlink video:
https://youtu.be/sLIyNnV0GyM
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: TheOtherCliff on December 22, 2020, 04:56:53 am
Considering that the voltage reading jumps around even when disarmed...

First guess is electrical noise and first guess for that is the FPV transmitter.  For most certainty I would run a bench test with the RF turned off (send video signal straight to a recorder).  Or (less certain) turned way down to lowest setting if it is adjustable.

I notice that quad wobbles around somewhat when descending.  Higher PIDs might help that.  Save your settings so you can get back to them and try AutoTune.  That usually helps straighten out descent wobbles.  :)
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: jdl on December 22, 2020, 11:36:43 am
Interesting. Yes, please provide a hex file here. I use a lot of the Runcam 4K cameras. i recently added one to an older OSD board with your latest code - it seemed fine but then I haven't tested it in low light, only outdoors. I use the batt1 input for battery voltage detection. For some reason on this older system, the indicated voltage moves around a LOT - I can't get a clear indication of what the true battery voltage is. Here's the downlink video:

Here is the HEX file (v2.56) attached. I assume you need the same FW variant (No.4).

Selected features:
- LP16.09 compatible
- Multirotor
- Battery voltage monitoring on Batt1 pad
- NO RSSI monitoring
- Charset Uploader
- PathPlan Waypoints Info (also active in RTB mode)
- MAX7456 stalled state monitoring and reset (experimental)
- Runcam2 4k HD camera compatibility Fix (Black Level Autodetect OFF, White 100%, Black 10%)


Ambient lighting (outdoors or indoors, sunny or cloudy) doesn't matter in my case.

Oddly, your setup does not really need this fix applied! Either we are talking about different Runcam models, or it's only mine with a non-standard SD FPV video output...

I have the issue with black levels for RunCam2 4K Edition:
https://shop.runcam.com/runcam2-4k-edition/ (https://shop.runcam.com/runcam2-4k-edition/)

(https://cdn10.bigcommerce.com/s-m8o52p/products/328/images/1595/RUNCAM2-4K__11037.1606702581.1280.1280.jpg?c=2)


Ordered it from Banggood at the end of August 2020. It maybe came from early batches...



I support TheOtherCliff's assumption about the electrical noise. Excessive noise on power lines might also be a reason for failures to program the charset in the OSD.

Linear voltage regulators can also generate oscillations and noise in certain circumstances. They often require capacitors with ESR within specified (by manufacturer) range.

It would be best to check what happens at the power lines of your UAV with an oscilloscope. Even cheapest models are good for such diagnostic. I can recommend this model (JYETech DSO-150), it's cheap and reliable and does a good job to test the voltage ripples, like ones coming from switching regulators. You can also use it to adjust video signal peak levels, if necessary.

https://www.banggood.com/Original-JYETech-Assembled-DSO-SHELL-DSO150-Digital-Oscilloscope-Module-9V-p-1211151.html?cur_warehouse=CN&rmmds=search (https://www.banggood.com/Original-JYETech-Assembled-DSO-SHELL-DSO150-Digital-Oscilloscope-Module-9V-p-1211151.html?cur_warehouse=CN&rmmds=search)

(https://imgaz.staticbg.com/images/oaupload/banggood/images/69/39/9f6bc43a-4152-4ebf-bdc3-568231e69ff4.jpg.webp)


This link is for reference only, I bet it can be found cheaper. I've got mine for $11 some years ago, unassembled. But there are options to buy it already assembled and tested.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on December 22, 2020, 10:29:05 pm
Thanks. I bought a quite nice Hantek 2D72 hand scope with signal generator a few months ago - I used it as the voltage source for testing the OPOSD battery inputs. Ordered a bunch of grabber leads to make it easier to hook up and see what's going on - they only arrived recently.

It's the same Runcam 4k model. I got several of the first models just after they announced them earlier this year and have another on the way with a spare battery. Impressive detail.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: TheOtherCliff on December 22, 2020, 10:47:20 pm
@jdl, for $23 shipped from in-country, I had to buy myself one for field use.  :)  I used oscilloscopes a lot in college, but I have never bought one.
https://www.ebay.com/itm/Original-JYETech-DSO-SHELL-DSO150-15001K-DIY-Digital-Oscilloscope-Unassembled/193458231082
It's a kit, but IC's come pre-soldered.

That Hantek 2D72 looks really nice.  I may have to get one for the bench.   ::)
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on December 23, 2020, 01:06:36 am
Ok. Measured the voltage coming into the batt1 pin on the scope. less than 100mv of noise, all high frequency (10Mhz or so). I conveniently broke off the pad going to the pin, so traced back the pin to the 16k resistor it lead to (oddly, it measures 8k on my DMM - a Fluke). Painfully resoldered a tiny wire to it and hooked all back up - operationally seems to be the same. Still fluctuates a lot. Its possible it's the RF xmtr. The Hawkeye Little Pilot monitor/rcvr I have has a video in - but I can't seem to get it to switch to the AV in! Arg. I tried the auto search - it just scans all the RF channels - never sees the AV in even when I have it connected with no RF on.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: TheOtherCliff on December 23, 2020, 11:47:29 am
That scope isn't going to show 5.8GHz noise...  :)

Did you try with FPV Tx powered off?

Could also be switching voltage regulator putting noise there.  Those can be from kHz to MHz.  Besides stand alones, they can be built into things like cameras.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on December 23, 2020, 07:10:20 pm
That's what I was trying to do with the LCDs AV input. I tried two other displays - at least one of them shows the camera input but neither will show the output of the OSD. The only thing that works is the video xmtr. And obviously then it is on. I checked the signal with my scope - it looks fine.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on December 23, 2020, 08:06:41 pm
I also tried adding a 10uf tantalum cap to the power supply leads to the xmtr. No difference in the battery voltages jumping around. It also is not powering up properly, it won't always sync after powering up, and the camera input now doesn't work. I've gone from two working OPOSDs to none.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: TheOtherCliff on December 23, 2020, 10:44:25 pm
Sorry to hear that.  :(

:)  If the wild voltage happens with more than one OSD, I would get the video displaying without the FPV transmitter.  It doesn't have to be pretty.  :)  If there was still a problem with OSD voltage I would remove things that have switching power supplies, one at a time, even if that means temporarily changing my switching main power converter to a linear one or 4.8V battery for a test.  Even if that means using a different brand of camera (or other video signal source) for a test.

A thought about going through several OSDs...  I know one thing I have to tell myself is to avoid plugging / unplugging most any connector when there is power on.  That goes mainly for any connector that has 3 or more wires.  The problem is that sometimes the ground is the last to make connection by a small fraction of a second.  Plugging in a 3 wire camera (Sig, +5, Gnd) connection to a powered OSD, you have +5 and signal connected, but no ground.  With R and C between the two (in the camera), that can be as bad as connecting +5 straight to the OSD video in from the OSD's viewpoint.  I helped a guy reconfigure his quad because one of his six 3-pin-servo FC connectors stopped working for probably this reason.

Edit: The other thing that comes to mind about several OSDs becoming non-functional is that enough electrical noise on the power lines could make your voltage regulator output the wrong voltage or even make an OSD act like it is the wrong voltage.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: jdl on December 24, 2020, 07:53:07 pm
...so traced back the pin to the 16k resistor it lead to (oddly, it measures 8k on my DMM - a Fluke).

This, in fact, is a 15k resistor, probably marked 18C (EIA-96 code). You had probably (unintentionally) touched with one of the probes both this and its neighbour (that goes to batt2) resistor's pads, then the DMM really reads approx. 8k resistance. If you carefully touch with probes just the pads of this 15k resistor, DMM displays 15kohm, as expected - I've tested that right now.

Hantek 2D72 looks nice, I'm tempted to buy myself one, too! :)

Sorry about the toasted OSD module, its MAX7456 is probably dead...

TheOtherCliff pointed the probable cause. I've also burned one MicroMinimOSD some time ago, doing the same. And two MobiusMini cameras too, but that's a different story... :D

Merry Christmas to all!   :)
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on December 30, 2020, 08:00:49 am
Well, I got 3 more PCBs today that look identical to the last batch - with the same little QC label on one side. Wired up, tested in the quad. Acts like the other ones - except battery voltage reads 3.05V and only 1 cell on a fully charge, 4.17V battery. The divisor ratio and the current sense value are the defaults.
I used the latest .hex with the softreset.
I changed the divisor to 21 and now it reads 4.18V. Close enough.
I have more from a different (the source you recommended) on the way. Should be here soon.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: jdl on December 30, 2020, 10:59:24 am
@trust, I guess I've found what causes your issue! Or, at least, I've found a flaw in the code...   :-[

If OSD is configured to monitor Voltage AND CURRENT, both sensors connected to MinimOSD board directly,  the readings would be probably unstable.

This is caused by an "improvement" (attempted to widen the acceptable voltage range coming from current sensors) I had made when I first started to tackle with MinOPOSD code (and Arduino at all - year 2016 :) ). Actually, I've never used current sensor connected to OSD, so I've never realized there is a problem there...

In short, the suggestion is that the issue lays in switching analogReference from INTERNAL (1.1V) to DEFAULT (5V)  and vice-versa between immediate consecutive analogRead (for voltage and current). This is possible, but few extra dummy ADC reads after each analogReference change are required.
https://www.arduino.cc/reference/en/language/functions/analog-io/analogreference/ (https://www.arduino.cc/reference/en/language/functions/analog-io/analogreference/)

Quote
Notes and Warnings
After changing the analog reference, the first few readings from analogRead() may not be accurate.



I'm going to correct this and update the sources on github.

Meanwhile, setting (in MinOPOSD JDL Config tool) the Current Sensor Amps Per Volt to 0.00 should fix the issue for you.

In any case, when no current sensor is connected to OSD, it is advisable to set the Current Sensor Amps Per Volt to 0.00.



Btw, did the charset upload succeed with these MicroMinimOSD boards?
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on December 30, 2020, 07:49:08 pm
Interesting!
I just did a flight test on the quad in somewhat windy conditions - not the best but wanted to see if the voltage tracked properly under loads.
It seems like it did reasonably well - after landing and checking battery voltage vs display, only off by a few hundredths of volts.
Overlay looked good - I don't have power going to the Runcam 4K - I'm using it's internal battery power to see if I can eliminate a noise source. And it looked much better than before. Pretty clear even on the recorded OSD data on the ground.
Of note was the sag in the 4000mah 4s battery under load - reading 20% lower at 50% throttle than after landing.
I'll try setting the current sense parm to 0 - I'm not using a current sensor.
And yes, the charset uploaded fine - although I don't know whether there was one there first as I didn't check.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on December 30, 2020, 08:10:01 pm
I changed the current sense parm to 0 - then the voltage reading was 5 cells and 20.xx volts!
So I changed the voltage multiplier back to the default - it was off by 1.8% so I set it to 15.67 and now its within a hundredth of a volt.
Now it reads 4 cells and 15.63 volts - which is correct.
Glad you found this - devils in the details!
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on December 30, 2020, 08:53:11 pm
I also did a flight test with these changes. The sag issue disappeared. Now voltage and capacity drops slowly and evenly as I would have expected.
Excellent!
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: jdl on December 30, 2020, 10:04:52 pm
Great! Happy it finally works for you and thanks for your cooperation in resolving this mystery!

Really, sometimes one has to step back and look from a different angle :)  No matter how thoroughly I was going through the code, I just kept skipping the section for current reading as I've assumed it is not used. I've also assumed it is effectively disabled by setting the Current Sensor Amps Per Volt to 0.00, just because it was the logical setup when not using current sensor at all. Reading your comment about setting current sense value to defaults led me to the insight :)

I'm going to restore the analogReference for current reading to 1.1V as it was in the original MinOPOSD code, in case anyone might wish to use a current sensor connected to OSD.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on January 07, 2021, 01:17:07 am
Update on noise issues. I migrated the GPS+OPOSD to the Atom FC Micro Hellaplane V2  today and tested.
Video all looks great until motors run - then the overlay blinks on and off with the motor power.
I disconnected the 7V power from the battery powering the camera and tested again. It has a battery so runs fine without external power.
Then the overlay looked pretty much fine even with the motors running, although the camera image had some banding from motor noise. Usable although not great.
Added a 100uf tantalum cap across the power leads of the OSD. No appreciable difference.
Note the camera/xmtr combo works fine with no noise when no OSD in place - just direct connect from camera to xmtr. There is still a common ground, and up to today camera was powered also by same supply as xmtr.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on January 28, 2021, 10:31:11 pm
I got some 330uH inductors and 1000uf electrolytic caps & added these to all 3 OPOSD systems I have. Cap directly across the OPOSD power leads, inductor in line with 5V supply. Should be a pretty effective low pass filter. 220Hz Fc
  On the sk450 quad, it was a significant improvement - not perfect, but most motor noise considerably reduced - maybe by a factor of 3 (visually on screen).
  On both of the Hellaplanes, which have motors running at higher speeds (and less bypass on the power leads at the esc's), it cut the noise by maybe half. The OSD display is pretty solid - just the video input has some banding with the motor noise.
  I now use the battery power on the Runcams to supply them with power for the video feed, so it shouldn't be getting power supply noise. That made a big difference previously.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on March 04, 2021, 02:44:35 am
I upgraded Hell8ious - the 8 motor, large Hellaplane (85 lbs thrust) to the bimode electronics, with OPOSD. I added the 1000uf cap and inductor on the OSD. Interestingly - there was virtually no noise on the video link at all even with motors running in hover mode.
  I note on the YEP ESCs running 6S, they have two 470uf caps on the power input lines on EACH esc.
On the small planes, there are NO extra caps on the ESCs - only what the little 20A bare PCBs have on board (can't tell what they are, all surface mount).
  I imagine if I added caps on each of the 20A ESC boards themselves, it would greatly reduce the video noise.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: jdl on March 04, 2021, 08:13:22 am
...  I imagine if I added caps on each of the 20A ESC boards themselves, it would greatly reduce the video noise.

Great, the noisy video is very annoying and severely degrades the FPV experience!

Sure, one or two large low-ESR capacitor on the PDB or smaller low-ESR caps on each ESC's power lines (this is better) are mandatory for cleaner video. They also protect the other electronic units onboard from potentially destructive voltage spikes when ESCs are braking. They also protect ESCs themselves in case of long power lines (between battery and ESC) - not uncommon situation with larger planes.

Useful articles:

https://oscarliang.com/capacitors-mini-quad/ (https://oscarliang.com/capacitors-mini-quad/)

https://www.rcgroups.com/forums/showthread.php?3240349-Adding-Capacitors-to-ESC-for-Longer-Wire-Length (https://www.rcgroups.com/forums/showthread.php?3240349-Adding-Capacitors-to-ESC-for-Longer-Wire-Length)
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: TheOtherCliff on March 04, 2021, 10:10:33 am
I note on the YEP ESCs running 6S, they have two 470uf caps on the power input lines on EACH esc.
On the small planes, there are NO extra caps on the ESCs - only what the little 20A bare PCBs have on board (can't tell what they are, all surface mount).

I'm a little surprised.  The 5 or 6 brands of cheap 20-30 amp ESCs I have all have input caps off board between the power wires.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on March 04, 2021, 06:19:49 pm
These are the ones we use on the small planes:
https://www.ebay.com/itm/RC-Turnigy-MultiStar-32bit-20A-Race-Spec-ESC-2-4S-NAKED-OPTO/252530725482?hash=item3acc01126a:g:HBoAAOSwSuNaVywP
  I usually buy a batch of at least 4 at a time.
The on-board caps seem to be fine for functionality, but reducing the power line noise feeding to the video likely needs bigger low ESR caps.
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on March 11, 2021, 10:54:21 pm
Added 1000uf 25V low ESRcaps to each ESC - greatly reduced the video noise on OPOSD - almost completely gone now.
https://www.digikey.com/en/products/detail/kemet/EST108M025AL3EA/3082791
$0.75 each for 10+
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: TheOtherCliff on March 12, 2021, 08:56:42 am
Was the shipping significant?  :)
Title: Re: Alternative LibrePilot MinOPOSD with a matching Config tool and Charset
Post by: trust on March 12, 2021, 05:33:01 pm
$4.99 for First Class. Took a couple days to get here in N. California. Order placed 3/5 - 5 days.
I used to get some items in 1-2 days - not anymore. Still not bad.
My last local shop that carried electronics closed shop end of last year. Sad day. Al Lashers was an icon of the bay area.
Not so much a casualty of the pandemic, but city requirements to upgrade to code.