[BUG] QR Code Wizard

My scripting console shows Python 2.7.18 (default, Apr 20 2020, 16:57:11)

I also have QGIS 3.14 on my PCs which is Python 3

Mine is 2.7.16
image

@kid Could you post an screenshot of your Window’s box python console ?

Hi

After my previous message, I had to uninstall the testing version as I fail in a finished design. With the stable version solved, I was already afraid of the worst.

By the way remove from the operating system all the versions of python that I had installed and performed a clean installation of Kicad, but with the stable version does not exit the error, it happens as before, it freezes the program until it closes.

Attached the requested capture.

I’ve tried to generate a QR and convert it with the bitmap tool, but I can’t get it detected by a QR reader.

I’ll keep investigating.

Thank you.

Well, a bit of falling into the rabit hole, I was wondering what was the problem with your imported QR code, so I made a test footprint with the text “test1” and try to generate a QR code online with the same text.

The first thing I noticed was the the KiCAD generated QR code had much more information (redundancy or something else) that the online generators

For the simple text “test1” you see that the KiCAD QR code is much more complex than the ones generated online.

The QR Code looks to me on the 3D Viewer, but if is scannable or not, could not tell

EDIT: @kid I followed you recommendation and used my phone to scan the codes directly from the computer screen, it worked well.

Hi

I’ve tried those steps just like others in a forum, but I can’t get the QR reader to identify it, in the bitmap converter if it works (tested with an android APP), but adding the footprint doesn’t look the same as the original.

I installed Python version 2.7.18 (https://www.python.org/downloads/release/python-2718/), but I get the same result, it freezes the application until it closes.

I’m going to try another computer that was pending reinstalling Windows 10 and try installing Kicad.

If it doesn’t work for me, I guess I’ll use Eagle again, which has never given me these problems. Start using kicad thanks to a friend who works with kicad in your company.

I later return feedback on the installation result on the other computer. Thanks!

The KiCad version is not more complex, it just has more pixels. :slight_smile:

QR codes come in around 7 different sizes, from 21x21 pixels to 177x177 pixels.

Could you share how does the QR code looks after you imported it into kicad? I am asking because of this

@paulvdh i reckoned it had to be something like that, thanks for the clarification, howeve it appears that the type is fixed on the script.

FYI the feature size seems to be hardcoded to 0.5mm but I can confirm that a a 0.3mm feature size prints on silkscreen well and scans fine on boards produced by one of the cheap Chinese fabs.

The python plugin structure is fairly amenable to a bit of lightweight hacking. This thread is worth a read

I also grafted on a DataMatrix version which makes much smaller codes - 6mm x 6mm are easily possible but the text length is more limited - fine for a serial number of version control ref though.

1 Like

When you go to small sizes of BAR codes, then the size should be matched to the raster of the printer. A QR code that has pixels of 2x2 on the printer can be much more readable then a QR code which maps to 2.723X2.723 pixels on the raster of the printer.

1 Like

Hi

I’ve tried reinstalling a Windows 10 computer and getting the same result. Tell my friend, he is the one who recommends KiCad, since he soon has to make a large series of PCBs with QR codes (my design is a small series), he has tested it on his computer and gets the same bug. He has also performed a clean installation on another computer, with Windows 10 Pro from a device created with Media Tool (updated today), KiCad downloaded from the official website and latest version, without installing Python or other software and gets the same result, the program freezes for several minutes until it closes.

I don’t know what else to try to see if we can find the error.

Thanks !

I think I’m very close.
I had a look at the source code at:
/usr/share/kicad/scripting/plugins/qrcode_footprint_wizard.py

And though my Python knowledge is minimal, the script is only 179 lines and Python is relatively readable. First I found, line 107 weird, where it did the “border” routine even if the border was 0, but that turned out to be a dud. Weird thing was that I did manage to get it to generate a new QR code, which motivated me to do more experimentation.

After further experimentation, it turns out that if you set “Qr Pixel Width” to “1”, or another integer (= whole number), then generation of QR code works on my machine. If I set it to a non-integer, then the Footprint Wizard crashes.

You can apparently resize an existing QR code, but during generation of a new QR code, the script fails if the size is a floating point number.
So if you want a QR code with pixel size of 0.5mm then:

  1. Set: “Qr Pixel Width” to 1mm.
  2. Change “Contents” string.
  3. Set: “Qr Pixel Width” to 0.5mm.

Can someone please confirm?
(Or even better: fix this in those 179 lines of Python. I get a bit lost there).

1 Like

Nice work @paulvdh ! my scriptt has this date included on line 16

C:\Program Files\KiCad_v5_1_6\share\kicad\scripting\plugins\qrcode_footprint_wizard.py

last change: 2017, Jan 4.

is it the same for yours ?

EDIT: That is also the latest version in Gitlab
https://gitlab.com/kicad/code/kicad-footprint-wizards/-/blob/master/qrcode_footprint_wizard.py

EDIT: @kid @paulvdh does your UI shows ‘,’ as decimal separator or ‘.’ ? Can it be problems with the locale?

EDIT: YES! I changed the kicad language to German an then the “Qr Pixel Width” is shown as ‘0,5’, now I can reproduce the error!

Yep, same date.
So it just crashes on dot versus comma in a text string. Gosh. Smells like a lack of exception handling…
I hate meddling with locale stuff, so I mostly ignore it. I usually set my PC to US-English, which should use dots, but KiCad won’t let me enter dots.

Then I set KiCad to “Dutch” via:
KiCad / Preferences / Set Language / Dutch which does use commas, and it still only lets me enter commas and crashes.
KiCad’s policy is to allow either dots or comma’s as decimal separator.
I have not checked if this is alread being handled in the big V6 update.

Then I tried some other of the Footprint wizards and 3 of them thow an exception at the moment: S-DIP, SOIC and BGA.

Just this week I switched to (yet) another PC, that may have something to do with it.

Tried them all:
S-DIP:
image

SOIC: Same: "TypeError: super(type, obj): obj must be an instance or subtype of type.
QFP: No error.
BGA: Same: "TypeError: super(type, obj): obj must be an instance or subtype of type.
QFN: No error.
QR: No error on first run, but …
Touch Slider: No error.
Circular Pad Array: No error.
Micromatch SMD: No error.
Barcode US-39: No error.
FPC(SMT connector): No error.
ZIP: No error.
ZOIC: No error.

@John_Pateman Yes, try those steps before I discovered that KiCad had a QR generation plugin, because the footprint it generated was not recognized by a QR reader, I tried several parameters.

@paulvdh Yeah ! Making those changes works correctly. Great, you’re a hacker!

Including this ( .replace(',', '.') ) somewhere in the plugin?

Thanks !

The problem is tha if your PC locale is English but you set kicad in another language where the decimal separator is a comma, then kicad takes care that you can only use commas. I set kicad’s language to English for this reason and because I’ve encountered this bug before…

1 Like
commit f7b30bf39721467bb787101e31a11103933d67ff (HEAD -> master, origin/master, origin/HEAD)
Author: jean-pierre charras <jp.charras@wanadoo.fr>
Date:   Tue Sep 8 18:19:28 2020 +0200

    FOOTPRINT_WIZARD_FRAME::ParametersUpdated(): fix a reentering issue
    On wxWidgets 3.0.5, in some cases calling ReCreateParameterList() generates
    a EVT_GRID_CMD_CELL_CHANGED that call ParametersUpdated() and creating
    an infinite loop
    Note also it happens **only for languages using a comma** instead of a point
    for floating point separator
    It does not happen on wxWidgets 3.1.4

EDIT: “master” means the fix is for 5.99. We’ll see if this will included for 5.1.

2 Likes

Amazed by the quick fix.
Until this trickles through, us lowly users can not do much more then change the default on line 32 in the QR code script to a whole number:

This would 2 small things:

  1. It works with “default” settings.
  2. If a user changes the width, and then it crashes, the user may get a clue that it has something to do with that parameter.

It was taken into 5.1 branch, too.

1 Like

My phone reads KiCad QR codes.
Getting the screen colours right to be read is the challenge

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.