Properly usage of Solid State Drive on Linux

Solid State Drive (SSD) is superior to even the fastest 7200rpm Hard Disk Drive (HDD), both in performance, power saving and temperature control.

I recently bought a used Thinkpad T430 with a 500GB @7200rpm HDD. Performance is not bad at all with 8GB RAM. But the palm rest on the left side of the touch pad become hot until the point I couldn’t take it anymore (not really really hot though, just around 40 degree C but still uncomfortable). I decided to upgrade it to a 128GB SSD of Kingston and was amazed by its performance: file copied instantly, OS boot just like come back from sleep, temperature was at a comfortable degree that I could work on this laptop for hours. Amazing! Yes it’s expensive, for only 128GB I have to put 20$ more into my HDD to finish the deal. But it’s totally worth every cents.

But the SSD is different to a normal HDD in writing and reading, in deleting file. The minimum unit when writing is a 4KB page. But the minimum unit when deleting is a block of 256KB. See the problem yet?


To write to a page is easy and always ready as long as there is an empty page. But if the SSD want to delete a page, it has to copy all written pages in the same block –> erase the whole block, then copy those pages except for the page it need to delete. The process become heavily slow overtime. The more data is written to an SSD, the slower it get.

So to fix this problem, the OS must tell the SSD which block is empty in the file system. And this is where the TRIM command come to the rescue. TRIM command or alternative is available on Windows 7, 8, 10 (where windows 9 is at huh Bill Gates?) and latest Linux OS.

My system run Linux Mint 17 and it’s already have the script enable to weekly TRIM the SSD. But it only apply for Intel and Samsung drive. I have to add –no-model-check to bypass this model checking and all is well.

This is the content of my currently weekly cron script:

# call fstrim-all to trim all mounted file systems which support it
set -e
# This only runs on Intel and Samsung SSDs by default, as some SSDs with faulty
# firmware may encounter data loss problems when running fstrim under high I/O
# load (e. g. You can append the
# --no-model-check option here to disable the vendor check and run fstrim on
# all SSD drives.
exec fstrim-all --no-model-check

DIY Soldering Station [part 5]

My soldering station is working nicely now for a while.
Below is my demo video of it. Not all functions demonstrated in this video though.

As always, all codes, schematics and PCBs is updated on my GitHub project page:
1. Heating control
In this version of code, heat is controlled using only Proportional controller (although the full PID controller is coded, but Integral and Derivative terms are commented out)
The reason for this is after tuning PID for a few set of values, I noticed Integral or Derivative only worsens system’s response, as you will see on some of the graphs below (All data and graphs is in /Data folder)

2. Calibrating heat sensor
You can calibrate this iron, using the two buttons SW2 and SW3. I don’t have a good and trusted thermometer around. So I only depend on the melting ice temp and hot boiling water to calibrate this.
First, press either Sw2 or SW3 while turning this station on. The LEDs will display “- – – -“, indicates calibrating mode.
Next put iron tip on melting ice for a few minutes, then press SW2. The LEDs will display “000°” for 0.5s and then display ADC value that it reads on the sensor for you to notice. It then saves this value to ROM.
Then you put iron tip on boiling water for a few minutes, then press SW3. The LEDs will display “100°” for 0.5s and then display ADC value that it reas on the sensor. It also saves this value to ROM.

You will have to reset the station after calibrating.

3. Auto-standby and auto-cool off
The station can detect whether the iron is resting on its holder or not. But you need to connect a wire from the holder (should be metal) to GND so the holder effectively becomes GND.
When you put the iron on this holder, the LEDs will display a RTclock and a timer will start. This RTclock can be adjusted using SW2 and SW3 if necessary. Although I have to admit this will be reset back to 00:00 when you turn the station off since it doesn’t have a back up battery.
After 20 minutes resting on its holder, the target temperature will be set to no more than 200 degC, depends on your temp setting at the moment.
After 30 minutes resting on its holder, the station will turn off heating, let the iron to cool down on itself. This is important and safe for me because I a forgetful person who usually forget to unplug soldering iron after work.
During and after this time, if iron get off its holder, the target temperature will be back to normal, which is whatever value that is set using the pot knob.

That’s all for this project. I could think of a few more functions to implement and the PIC still have some program memory space left (which is ~35% left on PIC16F873A and ~70% left on PIC16F876A). But for a smart soldering station, I think this version is good enough.
Please feedback if you think I miss something or you want to add something more.

[STM32] Set up tools and library

Previous post I told you how I chose to learn STM32 next. This post will be about how to set up tools like C Compiler and library, ST-LINK software.

1. GCC for ARM

Download this free C compiler for ARM here GCC-arm-embedded
Currently the latest version is 5-2016-q1-update. Choose a packet that compatible with your system, either Windows or Linux.
Extract it to a folder. In my case, it is in ~/STM32/gcc-arm-none-eabi-5_3-2016q1/bin
Next step is add GCC binary folder into your PATH environment. I’m using Linux Mint.

$ export PATH=$PATH:~/STM32/gcc-arm-none-eabi-5_3-2016q1/bin

Next install automake for the MAKE files to work

Continue reading “[STM32] Set up tools and library”

DIY Soldering Station [part 4]

Hi everyone, anyone, who is still reading this 😦

Check out my latest version of the SSS (Smart Soldering Station – Yes, it sounds cool, doesn’t it?) on  GitHub.

1.Power supply:

In V1, I used a buck regulator to step down from 19V, and powered the logic parts. But it was so hard to filter noise out of the analog signal. Because the PIC used +5V as a REF+ and +5V in this case was not exactly 5V but has ripple all over it. That affected the final digital result.

In V2, I used the jelly bean LDO LM7812 and LM7805 to “step down”. What I worried before was the heat dissipating from them. But after testing for a long time, the 78XXs don’t even need any heatsinks because the load on them is low. The result is good, stable ADC readings.

2.Amplification: Continue reading “DIY Soldering Station [part 4]”

  1. Power supply:

This soldering station need to be efficient. I will choose switch mode power supply. The circuit will have 2 power inputs: from 24V AC though a rectifier or 19.5VDC from a spare laptop power supply. I prefer the laptop power supply since it will be safer to use and output voltage will be cleaner than I could make it myself.

The Hakko 907 is rated 50W 24V. I measure the resistant of the heater R_{heat} is around 3-4 Ω when cool and 10 Ω when hottest. WhenR_{heat} =3\Omega, assume maximum power is the rated power 50W then we have current I_{heat} = \sqrt{50/3}=4(A), Voltage supply need to be R_{heat}*I_{heat}=12(V). When R_{heat}=10\Omega, we have I_{heat}=\sqrt{50/10}=2.2(A) and voltage supply need to be 2.2*10=22(V). So we need a voltage of power supply 24VDC.

Continue reading “DIY Soldering station [Part 3]”