rename.py

some days ago my brother asked me if i can help him batch rename about 200 pdf files..
the needed name for the file was the heading found on the first page…

so i did a quick and hacky script and experiment with PdfReader library –
it worked really nicely and was only about 2h in learning and getting it to work as it should 😉

#!/usr/bin/env python3

import os
import re

from pathlib import Path

from pypdf import PdfReader

from operator import itemgetter, attrgetter

print(42 * "*")
print("running script rename.py")
print(42 * "*")
print()



# extract ids and title
regex_title = re.compile(
    r"Some Fixed Pre Text \(LM\),\s*(?P<id1>\d+-\d+)\s*(?P<title>.*?)\s*\((?P<id2>\s*G(\d+\s*)+)\)",
    re.IGNORECASE,
)


def parse_file(filename):
    print(42 * "-")
    print(f"reading file '{filename}'")
    reader = PdfReader(filename)
    page = reader.pages[0]

    # print(42*'-')
    # print(f"extracting text from page 0:")
    # print(page.extract_text(extraction_mode="layout"))
    # print(42*'-')

    parts = []

    def visitor_body(text, cm, tm, font_dict, font_size):
        # get top part
        y = cm[5]
        if 600 < y < 1020:
            parts.append(text)

    page.extract_text(visitor_text=visitor_body)
    text_body = "".join(parts)
    # text_body = text_body.replace('\n', ' ').replace('\r', ''
    text_body = " ".join(text_body.splitlines())
    # print(f"extracting text from page 0 with filter:")
    # print(42*'-')
    # print(text_body)
    # print(42*'-')
    # now we have on continus line.
    # let us get all the parts we need with some regex magic:
    regex_result = regex_title.search(text_body)
    # print(42 * "-")
    if regex_result:
        # print(regex_result.groupdict())
        result = regex_result.groupdict()
        result["title"] = result["title"].replace('/', '-')
        result["id2"] = result["id2"].replace(' ', '')
    else:
        result = {"text_body":text_body}
        
    # print(42 * "-")
    return result


def get_filelist():
    p = Path('.')
    filelist = list(p.glob('**/*.pdf'))
    return filelist

def main():
    files = get_filelist()

    results = []

    for file in files:
        result_dict = parse_file(file)
        result_dict["filename"] = file
        # result_dict["birth"] = file.stat().st_birthtime_ns
        result_dict["birth"] = file.stat().st_mtime
        results.append(result_dict)

    # we now have a list of dicts for each file with the extracted title and ids
    # we first sort it.
    # results.sort(key=itemgetter('id1', 'title', 'id2', 'birth'))
    results.sort(key=itemgetter('id1', 'title', 'id2'))

    for result in results:
        # print(result)
        title = result["title"]
        id1 = result["id1"]
        id2 = result["id2"]
        birth = result["birth"]
        filename_old = result["filename"].resolve()
        # create new base filename_new
        stem_new = f"{id1} - {title} - {id2}"
        # print(f"stem_new: '{stem_new}'")
        # modifie the stem part
        filename_new = filename_old.with_stem(stem_new)
        print(filename_new)
        # extend if this one already exists...
        while filename_new.exists():
            filename_new = filename_new.with_stem(filename_new.stem + " - 1")
        filename_old.rename(filename_new)

main()

maybe its of help for others…

maybe just as personal memo.

actual soldering :-)

this morning i did a last test-run with the tweaked Felder ISO-Cream profile:

yeah… at the top i thought it is in the cooling step already and opened the window – with ~3°C cold air from outside it dropped fast..
then i found it is in the middle of the reflow – sorry… and closed the window again – until it really switched to cooling..

the old left-over pcb i use for these is done now.. i comes from my LEDBoard_4x4_16bit project – and if i remember correctly i backed it with the assembled board in the oven multiple times back then..
now grilled it again ~4-7 times. it smells very bad – is super dark discolored.. i think that is ok with about ~12 times solder cycles..

and then started to assemble a simple board to really test the profile 🙂

placed

then reflowed:

i added a paper-lid to have stable air inside..

reflow was successful 🙂
my profile is just a little bit to long for my right angle touch switches:

they melted away 🙁 – lesson learned – have a look in the datasheet and you know that they are very heat sensitive!

in general i have the feeling that my heating elements get a little bit to hot – the pcb also slightly discolored at on place…
so will keep an eye on this and improve it..

Open Points

  • add housing
    • i would like to have class at the top for a good view what is happening inside..
  • metal frame for heating-elements
  • quite 5V fan with PWM control for cooling
  • add second temperature sensor
  • spring thing to hold board down
  • way to fix sensor position on board
  • more heating elements for bigger working area
    • switchable configuration for long or more square pcbs?!
  • bigger / second power supply ?! (~750W)

Testing & Tuning the PID

for tuning i followed more or less the tutorial PID Without a PhD
from Tim Wescott

and the tutorial and video from PID Explained Team.

first i just checked with low temperatures of 20..40°C
as i went on and tested up to 260°C i noticed that the current did decrease. and the temperature did not increase any more.
i could see this in my graph as the heating got slower and slower with the rising temperature… (also the pid already saturated at the output..)

so i measured the resistance during the cool down of the heating elements to get some insights:
(4x in series → 48V/4=~12V/Module)

Temperature (°C)Resistance (Ohm)Current (A)Power @48V (W)
255401,1957
250391,2158
240381,2359
230361,2660,5
220381,2660,3
200341,3564,8
100261,888,6
8024296
60222,18104
4020,92,3110
2519,52,46118
Temperature / Resistance – 4 Modules in Series – 12V/Module

result: the ~57W is not enough to get to more than 255°C…

i rearranged the Modules into 3-in-series connection.
this means ~16V/Module – and tested again:

Temperature (°C)Resistance (Ohm)Current (A)Power @48V (W)
25527,51,4570
25027,01,572
24026,61,677
23025,61,6780
22025,31,782
20024,11,886
10018,82,1100
8017,52,7130
6016,7
4015,6
2514,3
Temperature / Resistance 3 Modules in Series – 16V/Module

with this i found that i can go above 255°C.

i then tested the profile for the Felder ISO-Cream “Clear” and found that in the reflow stage the heat-up is a little to slow:

config:3S profile:Felder ISO-Cream “Clear”
my setup

in the *my setup* picture is a temporary cardboard thing with a 80mm 12V fan (connected to 5V) to cool down faster between tests.
for the final setup i think i will buy 1 or two 5V and PWM capable fans….
and also exchange the *chamotte* ston with some metal frame.
this way i also can cool the bottom side..


so i again switch the configuration –
now i have a 2-in-series config: 24V/Module
CURRENTLY THIS TABLE IS ONLY CALCULATED VALUES!!

Temperature (°C)Resistance (Ohm)Current (A)Power @48V (W)
255202,4115
25019,52,46118
240192,52121
230182,67128
22017,52,74132
200172,82135
100133,69177
80124192
60114,36209
4010,454,59220
259,754,92236
CURRENTLY ONLY CALCULATED VALUES!!!!
Temperature / Resistance – 2 Modules in Series – 24V/Module

i also tested this with the Felder profile:

this time the heat-up is fast enough! 🙂
the nice and working pid tuning i had for the 4-in-series arrangement is now out of tune…
so i will have to re-tune it to get less overshoot / swing.

while having a break i thought about the maximal power in this configuration –
and found that this way i only be able to power 2×2 modules with my 250W power supply.
for now i leave it this way. in the long run i hope with the other frame concept i get more heat to the pcb and less into the stone and this way be able to use the 3S config.

Tuning

after a day of mostly waiting til the system cooled down again
– one test cycle <=60°C needs 400s → 6:40min –
i just rebuild my hw mounting setup.

this way i can warm up quicker and cool down much quicker as i do not store heat in the stone. – at least that is what i hope..

plot old setup
plot with old setup
plot new setup
plot with new setup

hmmm – does not seem to change much..

i then tested the actual Felder Profile:

Felder ISO-Cream ‘Clear’ – Sn96,5Ag3,0Cu0,5 – 2S1P – P 04.50 I 00.00 D 00.00

seems i have a working profile.
i will add a little more time for the prepare phase. so the pcb is really fully at the 50°C. at the top i have a little bit of a mis-match –
i saw on my temp sensor directly connected to the heating elements at the top ~265°C – so that is hot…
the pcb seems to increase its temperature resistance at higher temperatures… at the peak i have 230°C to 245°C error. and to the heating this results in ~35°C difference…

i will report when i solder the first real board. 😉

the idea & planing

the idea came from this Applied Science Video:
Electroluminescent paint and multi-channel control circuit
21 Nov 2018
starting at 11:25

there is a link to amazon for a element – and it is not available to delivery to germany 🙁
so i went on with some help of friends and found

dimensionsvoltagepowercurrentresistance
(guess)
power@
6V
power@ 9Vpower@ 12Vpower@
24V
link
70mm x 15mm12V70W5,8A2,06R17W39W70W280WHALJIA 12V 70W Wired MCH Metal Ceramic Heating Plate Heating Element 70mm x 15mm
70mm x 15mm24V110W4,6A5,2R7W15,6W27W110WHaljia 24V 110W Wired MCH Metal Ceramic Heating Plate Heating Element 70mm x 15mm
40mm x 40mm12V48W4A3R12W27W24W192WHaljia 12 V48 W Wire MCH Metal Ceramic Heating Plate Heating Element 40 mm x 40 mm
40mm x 40mm24V96W46R24W13,5W48W96WHaljia 24 V96 W WIRED MCH Metal Ceramic Heating Plate Heating Element 40 mm x 40 mm

to get an idea of how much power i actually need i had a look at the small commercial IR-Heaters and Hot-Plates –
they all have about 800W:

180mm * 235mm = 42300 mm² = 423 cm²
a = 60mm * 60mm = 3600 mm² = 48 cm (1x4)
b = 60mm * 80mm = 4800 mm² = 48 cm (2x2)
c = 60mm * 90mm = 5400 mm² = 54 cm² (1x6)
d = 60mm * 120mm = 7200 mm² = 72 cm² (1x8)
e = 120mm * 60mm = 7200 mm² = 72 cm² (2x4)
f = 120mm * 90mm = 10800 mm² = 108 cm² (2x6)
g = 120mm * 120mm = 14400 mm² = 144 cm² (2x8)

423 cm² == 800W
1 cm² == x

x = 800W *   1cm² / 423cm² = 1,89W
a = 800W *  36cm² / 423cm² = ~68W (1x4) 
b = 800W *  48cm² / 423cm² = ~91W (2x2) 
c = 800W *  54cm² / 423cm² = ~102W (1x6)
d = 800W *  72cm² / 423cm² = ~136W (1x8)
e = 800W *  72cm² / 423cm² = ~136W (2x4)
f = 800W * 108cm² / 423cm² = ~204W (2x6)
g = 800W * 144cm² / 423cm² = ~272W (2x8)

30x40mm: ~23W/module
60x15mm: ~17W/module

then i calculated the resistance of the found element to check on what wattage i can do at what voltages:

U = R*I
P = U*I
→ P = U*(U/R)

(i added these *guesses* in the table above)

So I decided to go with the 70x15mm 24V model.
and will update here if i found how this works out..

and for the first test setup i will go with the concept
12V→ 27W / module
so definitive more then enough..

as power supply i will use a MeanWell GST280A48-C6P
(reichelt) with an fitting connector (reichelt)
to get a 5V for the controller i will go with a recom R-78HB50-05 (VIN: 9-72V)
and for switching the power to the heating elements i will use IRLB4030PBF – MOSFET N-LogL 100V 180A 370W 0,0043R TO220AB
and to drive this a BC 550C as mentioned in this nice article:
Schalten und Steuern mit Transistoren III – Mit MOSFETs höhere Ströme schalten
for temperature measurement i use a Adafruit Universal Thermocouple Amplifier MAX31856 Breakout with an Thermocouple Type-K Glass Braid Insulated – K
and have the plan to use a Melexis IR thermometer
i have ordered a MLX90614ESF-BAA-000-TU
i hope that with this i can precisely track the surface temperature..

so when all the parts arrive i can go on.. with building.

for the Controller i plan to write it in CircuitPython and run it on an adafruit (maybe ItsyBitsyM4) PyBadge
for now i just want to use the arduino serial plotter or similar with an second CDC-device enabled to log the progress and the flash-drive function of CircuitPython for a text-file with the temperature-profile.
i have written a request in the adafruit CircuitPython forum if there are any PID controller things out there…

HotPlate SMD soldering

Build a Hot-Plate / Heating-Element based reflow tool for SMD PCB soldering.

all the details are in the Project Logs:
show all posts for this project

Hardware

ToDo: description of used Hardware and why i choose what…

Software

Tools

Installation

  • update CircuitPython to at least v7.0.0
  • ​copy all the needed files to your CircuitPython drive.
  • create profile that fits your needs and copy to drive.

Usage

  • power up controller
  • power up psu for heating
  • connect serial terminal (GTKTerm)
  • connect and setup plotting tool (SerialPlot)
  • in the serial terminal you have a basic menu with some options..
  • tune your PID for your setup
  • select profile to use with *pn* or the hardware *Select* button
  • click on the hw *start* button
  • in the serial terminal the profile configuration is shown
  • start reflow cycle with a click on hw *start* button
  • wait…
  • if finished the plot should stop automatically (no data is send)
  • save plot
  • click on *start* to confirm and get back to standby state

Details

ToDo: describe how the software works

enable second CDC-device

Open Points

  • add housing
    • i would like to have class at the top for a good view what is happening inside..
  • metal frame for heating-elements
  • quite 5V fan with PWM control for cooling
  • add second temperature sensor
  • spring thing to hold board down
  • way to fix sensor position on board
  • more heating elements for bigger working area
    • switchable configuration for long or more square pcbs?!
  • bigger power supply ?! (~750W)
  • fix short heating powerup on microcontroller reset