How does Kicad chose the net name out of two different sheet pins?

In my root sheet I have pins of different sheets connected together. I would like those nets to be called BCK_EN and BATT1 but they inherit the other sheets name:

Also, left sheet is number 2, right one is number 9, does it matter?
I have seen this question asked a few times, someone recommended assigning names manually but I’d rather not, someone else said that the net should be taken in alphabetical order, but it doesn’t happen, and I was not able to find a definitive answer.
How do I “lower priority” of a sheet in the net name assignment?

I do not know the answer to that question, but you should know that you can assign net names manually.

image

The various types of named ‘drivers’ of a net all have an internal ‘weight’, and if there isn’t an explicit net name assigned (which is actually just another type of net driver but with a large weight), then the heuristic chooses based on which of the available drivers of a net has the highest weight. The weights are (lower in the list is a higher weight):

Symbol pin
Sheet pin
Hierarchical label
Local label
Power pin
Global label

If two drivers have the same weight (like may be happening in your instance, but we’d need to see inside the hierarchical sheets to be sure) it falls back to a heuristic which ends up, after various other things are tested, with an alphabetical ordering.

As suggested above, the way to force a name is to add a net name (this is a ‘local label’ in the terminology above). As you can see from the list above, it’s a higher priority so will grab the ownership of the net.

One thing I’ll add is that the full net name of a non-global net always includes the sheet path, even though this is hidden in some places (such as on the net labels shown on tracks and pads in the PCB editor) to save space. The full name matters in situations like the example in this thread, because the name of the aubsheets counts as part of the net names when it comes to sorting them alphabetically.

The other thing you can do in this specific situation apart from adding a label on the higher level sheet is to mark one of the sheet pins as an output. If I remember correctly, I set it up so that output pins would win over input pins if they are the only options to drive a net name.

Is there a good reason to not have consistent net names? Someone coming along in the future and trying to figure out your schematic will struggle.

Please correct me if I am wrong:

I have noticed what seems like an improvement relating to this. Perhaps it is a parsing of “symbol pin”, (as in which symbol is given priority?):

Let’s say that you have R17 pin 2 connected to U3 pin “Audio_Out”. It seems to me that older versions of KiCad were likely to assign the net “R17 pin 2”. Maybe that (mostly meaningless to me net name assignment) would have happened based on a “flip of the coin” or alphabetical order? But version 8.XX now seems to assign it “U3_Audio_Out”. Much better in my opinion. Am I correct?

Thank you all for the precious input. I must say that I was an idiot - to have a clearer image to post, I renamed the sheet before taking the screenshot. If I reattached the nets with the screenshotted name, it would have worked as “Power” > “STM”. What made it click was craftyjon comment:

So my solution is to rename the “lower priority” sheet like this:
image
I deleted and reconnected the nets, and it works!!
Thank you so much!

I made a sheet just for the MCU stuff, and I wanted the MCU pin assignment to be done clearly in the root sheet. This way I have one less jump to do to see what is connected to a certain pin. All other sheets contain the signal conditioning necessary to go directly to the MCU pin, so the MCU sheet is clean with only programming connectors and strictly MCU stuff (caps, crystal, etc).
Also, this is easier as I’m routing tracks before connecting pins, to see what pin is closer to the signal.
Is there a better/more standard way to do this?