PROJECT: Half-Life 2 AR2, Update #2 - Barrel Assembly


Quick update coming at ya, I have just made the 2nd prototype for the AR2 barrel assembly:

Current variant seems to be working quite well, while still having enough room for electronics. Now I just need to fix a few minor errors and move onto the next moving assembly, the firing pin

UPDATE: Various 3D Printed Projects

Here is another quick update, this time covering some 3D printed projects I recently completed:
  1. My wife’s laptop seems to overheat when encoding videos or playing GPU heavy games. So I made a stand to give the laptop intakes/vents more air and move the screen to a more comfortable height. If you want to make one yourself, you can find the model here
  2. Another one for my wife who mainly works from a laptop connected to an external monitor. Recently work threw out a fairly decent PC (i7-3770k CPU, 32GB RAM, GTX 760 GPU), so we decided to refurbish it has her main computer. The problem she soon encountered was that it was a pain having to unplug the monitor/keyboard/mouse from her laptop and plug them into the desktop, so I designed a wee box to house USB & HDMI extension cables. Come to think of it we should have just got a KVM switch…
  3. Lastly, I made some 3D printed frames for the postcards & instax/Polaroid pictures we got along our 4 month overseas trip. You can grab the model here


PROJECT: Half-Life 2 AR2, Update #1 - Info & Model

Here is a passion project I have been slowly working on since 2012, and only recently has it started to take actual shape. The project is a rifle from my long time favourite video game Half-Life 2 called the Overwatch Standard Issue Pulse Rifle (OSIPR), however in the community it is more commonly referred to as the Pulse Rifle or the AR2
Overwatch Standard Issue Pulse Rifle (OSIPR) aka Pulse Rifle aka AR2

The plan is to make it as functional as possible (sound, lights, and movement wise) with the help of SolidWorks, Altium, and 3D printing. I then want to make a cosplay using the AR2, first as the Resistance/Rebels and finally as the Combine:
Resistance/Rebels from Half-Life 2

Combine from Half-Life 2

Looking back, one of the major reasons this project has only recently started to gain momentum is due to the gradual improvement of my own skillset
For example, when I first started in 2012 I planned to make the rifle completely out of wood and mimic the firing pin movement with a motor, this proved to be quite difficult so I shelved the project. The second attempt (2015) involved me exporting the 3D model from the game files and importing it into SketchUp, I soon found that the model had too many errors to work with plus doing such a complex assembly in SketchUp was never a good idea, so the project was shelved again

With my current attempt I have designed the 3D model completely from scratch in SolidWorks (see pictures below). Next I plan to:
  1. Figure out mechanical movement of barrel, reload mechanism, and firing pin
  2. Design the circuit (sound, lights, and movement) in Altium
  3. Adjust 3D model internals and solve how it all fits together in SolidWorks
  4. 3D print rifle on my trusty Prusa i3 MK3S
AR2 game model (exported from w_irifle)

Overlaid AR2 game & SolidWorks models

AR2 SolidWorks model

Simulated AR2 barrel mechanism (gear & rack exported from Gear Template Generator)


PROJECT: Solar Weather Station, Update #4 - RTC & FRAM


Turns out you can't just turn on the SGP30 (air quality sensor), wait a few seconds for it to warm up, and then take a reading. Instead you must burn-in the sensor for 12hrs after which you can obtain a baseline value. From this point on you need to:
  1. Fire up the sensor every hour or so and store the current baseline (as well as actually read the current air quality)
  2. Check that the stored baseline is not older than 1week, if it is then you must do the 12hour burn-in stage again
A scenario where #2 could happen is when the sunshine has not been so great and so the weather station has been without power for more than 1week. 

What all this means is that I need to check how much time has passes since a baseline has been measured/stored. To achieve this the easiest way would be to use an RTC (PCF2129) to log the time and FRAM (FM24CL64B-G) to record any values I need to store (like old baseline value and the time it was recorded).

RTC (PCF2129 vs DS3231)

After doing a bit of digging it turned out that most people tend to use the DS3231 a tried and true RTC whose behaviour is well understood in all sorts of implementations. Then you also have the PCF2129 which is a newer RTC that offers lower power consumption and is surprisingly cheaper (2.38AUD/1000pcs for PCF2129 vs 6.33AUD/1000pcs for DS3231).
NOTE 1: Dan has a good blog post comparing the two in terms of accuracy. The DS3231 is the winner here as is you can expect it to be fast by ~1sec/year, whereas the PCF2129 is expected to be slow by ~1sec/month. This was not a worry for me as I was expecting to sync up the RTC every once in a while.

On paper (or datasheet) it looked like the PCF2129 is a clear winner for me as it's typical 3.3V draw is 2.5uA (from both Vcc & Vbat), whereas DS3231 is a whopping 70uA from Vcc and 3.0uA from Vbat. But I wanted to see just how true this is so I tested both of them with my trusty 121GW:

What I found really put things in perspective. Here is the power consumption plot where both y-axis are to same scale:
And here is one where y-axis are properly scaled:
As you can see you can expect a power saving of x40 when using the PCF2129 (vs DS3231).
NOTE 2: Here is the Arduino driver I used for the RTC's, and here are the steps I used to test the power consumption (I was logging in ~0.2ms intervals, 121GW limit):
  • 0sec:     Log start (all OFF)
  • 20sec:   Vbat ON
  • 60sec:   Vcc ON
  • 260sec: Vcc OFF
  • 300sec: Vcc ON
  • 340sec: Vcc OFF
  • 380sec: Vbat OFF
  • 400sec: Log end (all OFF)


The next problem was where to store the baseline & timestamp value. I could have easily written the values in the non-volatile memory of nRF52 but this is limited to 10000 write/erase cycles (or 1.8x10⁹ with wear levelling). Whereas if I use FRAM then I can expect a write/erase cycle count of 1x10¹⁴. 
NOTE 3: This is not accounting for memory retention which is 10years for nRF52 (at 40°C) and 151years for FRAM (at 65°C for FM24CL64B-G).

To put things into perspective if I was to write values 8760times/year (once every hour) then each memory would last:
  • nRF52 (no wear levelling):    ~1year
  • nRF52 (with wear levelling): ~200000years
  • FRAM (FM24CL64B-G):          ~10000000000years

Interestingly enough when I was picking out the FRAM I finally managed to get a counterfeit module. Initailly I ordered the Fujitsu MB85RC64TA & Cypress FM24CL64B-G as both were identical in memory structure (8bits wide & 65311 addresses) and had pretty much the same I²C command format. 

What I quickly found out was that with the MB85RC64TA I could not successfully write/read values even though I was sending the correct address/data structure and received the expected acknowledge bit. I tried the same script with the FM24CL64B-G and it worked without any issues.
NOTE 4: The MB85RC64TA has a high speed mode (3.4MHz) which can mess things up if the master does not support it, but all my tests used the standard 100kHz speed. 

Getting out the logic analyser proved what I was seeing:
Finally having a closer look at the suspected counterfeit IC (MB85RC64TA) did raise a few questions:
  1. Why was the top & bottom surface (of same package) different?
  2. Why was the pin1 indent looking so shallow?
  3. Why does it look like the top surface has been polished and engraved with a laser?
NOTE 5: CTISMT have a couple of really good presentations on how to spot counterfeit components. 


PROJECT: Solar Weather Station, Update #3 - nRF52 Progress & SES Config

nRF52 Programming Progress

After getting some good advice from members of EEVblog/Nordic/reddit and burning a bit of time with my crude nRF52 dev kit I have managed to make some good progress in terms of programming the nRF52832. So here is what I have completed thus far and what I still have left to do:

Task Complete? Notes
LED Blinky Yes Pin config is quite simple
LED PWM Yes Pin config is a bit more complex here
UART Comms Yes As always make sure your logic voltage levels are compatible
ADC Read no Will be used to monitor voltage of supercapacitor
BME280 Comms Yes I2C/TWI up and running :D
SGP30 Comms ~ Basic function working, need to add humidity compensaiton
BLE Comms ~ Have done some basic tests with making a BLE peripheral

Reading data from BME280 (Temperature, Pressure, & Humidity)

Reading data from SGP30 (tVOC & eqC02)

SGP30 testing in Hong Kong

Segger Embedded Studio (SES) Configuration

Also I have found out that setting up a completely new nRF52 projects in SES is not so simple, your best bet is to copy and modify an example project that resembles what you want to achieve. Here & here are a couple of suggestions on how to create a new nRF52 project in SES, also below is my summary that has worked well so far:
  1. Download the nRF52 SDK and place it not so deep in the main drive: 
    • C:\NORDIC\nRF5_SDK_15.2.0
  2. Make up a working directory near same folder, again this can't be too deep into your main drive: 
    • C:\NORDIC\_WorkDir
  3. In the working directory create a project folder, for example when I was testing the PWM function I worked out of:
    • C:\NORDIC\_WorkDir\11_2019May21_PWM-test_v12a
  4. In the examples folder of the SDK find a project that closely resembles what you want to achieve, then copy the following files into your project folder:
    • C:\NORDIC\nRF5_SDK_15.2.0\examples\peripheral\pwm_driver\pca10040\blank\ses\pwm_driver_pca10040.emProject
    • C:\NORDIC\nRF5_SDK_15.2.0\examples\peripheral\pwm_driver\pca10040\blank\ses\flash_placement.xml
    • C:\NORDIC\nRF5_SDK_15.2.0\examples\peripheral\pwm_driver\main.c
    • C:\NORDIC\nRF5_SDK_15.2.0\examples\peripheral\pwm_driver\pca10040\blank\config\sdk_config.h
  5. Now your project folder should look something like:
    • C:\NORDIC\_WorkDir\11_2019May21_PWM-test_v12a\pwm_driver_pca10040.emProject
    • C:\NORDIC\_WorkDir\11_2019May21_PWM-test_v12a\flash_placement.xml
    • C:\NORDIC\_WorkDir\11_2019May21_PWM-test_v12a\main.c
    • C:\NORDIC\_WorkDir\11_2019May21_PWM-test_v12a\sdk_config.h
  6. Rename the SES project in explorer: "pwm_driver_pca10040.emProject" to "PWM-test.emProject"
  7. Open up the renamed SES project in a txt editor and change the following:
    • "<solution Name="pwm_driver_pca10040" target="8" version="2">" to "<solution Name="PWM-test" target="8" version="2">"
    • "<project Name="pwm_driver_pca10040">" to "<project Name="PWM-test">"
    • If using a custom board make sure to state this in "c_preprocessor_definitions": "c_preprocessor_definitions="BOARD_PCA10040;" to "c_preprocessor_definitions="BOARD_CUSTOM;"
    • Using the find & replace function of your txt editor change the path depth of all mentioned files/libraries/directories so that they agree with your nRF52 SDK directory: "../../../../../../" to "../../nRF5_SDK_15.2.0/"
    • Update the directory of "main.c": "<file file_name="../../../main.c" />" to "<file file_name="main.c" />"
    • Update the directory of "sdk_config.h": "<file file_name="../config/sdk_config.h" />" to "<file file_name="sdk_config.h" />"
    • Lastly update "c_user_include_directories" so that it looks at the correct directory for "sdk_config.h": "c_user_include_directories="../../../config;" to "c_user_include_directories=".;"
  8. Try opening up the updated project in SES and hitting the compile button (F7), given that everything has been done correctly the project should compile without any issues


TRAVEL: Solar Around The World

Here I show some cool solar related stuff that we found on our travels


Tokyo - Solar powered road sign

Tokyo - Solar powered road cone

Tokyo - Solar powered traffic light

Tokyo - Solar powered street light

Tokyo - Solar powered info station

Tokyo - Solar powered trinket (kinda moves like a fish)

Nikko - Solar powered road light

Kyoto - Solar powered info station

Kyoto - Solar powered path lamp

Kyoto - Solar powered toilet something

Kyoto - Solar powered taxi station light

Kyoto - Solar powered path light

Mount Koya - Solar powered thermometer

Outside Mount Koya - Solar panels on a hill

Outside Mount Koya - Solar panels on a field

Onomichi - Solar powered road light (seen better days)

Onomichi - Solar powered bike path light

Onomichi - Solar panels on a field

Onomichi - Solar panels on roofs

Onomichi - Solar panels held with scaffolding

Onomichi - Solar powered road light

Onomichi - Solar powered traffic light

Hiroshima - Solar powered street lamp

Hong Kong

Hong Kong - Solar powered mosquito zapper

Hong Kong - Solar powered mosquito zapper

Hong Kong - Solar panel on Ngong Ping 360 cable car (see top)

Hong Kong - Solar powered road light


 Central - Solar panels on roofs

Arad - Solar powered bus stop display

Arad - Solar panels on roof

Be'er Sheva - Solar powered bus stop display (and a bunch of ants digging up dirt...)

Be'er Sheva - Solar powered utility box

Jerusalem - Solar powered radio speaker

Tel Aviv - Solar powered something on a lifeguard building

 Tel Aviv - Solar powered bike light

Tel Aviv - Solar powered wireless phone charger


Kiev - Solar powered bench ;^)

Kiev - Solar powered rubbish bin

Kharkiv - Solar powered bike hire stand


Krakow - Solar powered hire bike

Krakow - Solar powered car park ticket machine


Venezia - Solar powered data gathering?

Venezia - Solar panel on a boat

Venezia - Solar powered art piece (lighting)

Florence - Solar powered road light

Florence - Solar powered hire bike (see basket)

Florence - Solar powered car park ticket machine

Rome - Solar powered pedestrian crossing lights (near Vatican City)

Rome - Solar powered car park ticket machine

Rome - Solar powered traffic lights


Saint Petersburg - Solar powered radio bus

Saint Petersburg - Solar powered bike hire stand

Altai - Solar powered camping hut (no power or cellphone reception in region)

Altai - Solar powered street lamps

Altai - Solar powered street lamps, now with wind power :D

Tomsk - Solar panel beside window (large window, 2nd from bottom)