Thingy 91 Tutorial Startup Guide

When I was first handled with the task of building a Bluetooth and NB-IoT gateway, I was a bit overwhelmed by the messy and complex documentation on the manufacturer’s website. So I decide to do a write guide to start off a hello world example as I learn discover that Thingy 91 module is all about.

Start up hardware

Thingy 91 (from Nordic)

Thingy 91 is a prototyping kit which consist of the IC chip nRF9160 (for NB-IoT communication), and nRF52840 (Bluetooth Low Energy BLE 4.0, 5.0 communication). Simple battery powered electronic hardware to get engineer start up with working on nRF9160.

nRF9160-DK (from Nordic)

nRF9160-DK is similar to Thingy91, an development kit for learning nRF9160 IC chip. That why the it is named “-DK”. It consist of the same IC chip nRF9160 and nRF52840.

Check out this video introduction of nRF9160-DK development kit board.
and a quick introduction to nRF Connect SDK.

An additional big chip is found on this kit. This chip is there for the programming of the IC nRF9160 or nRF52840. A switch SW5 near this big chip is used for selecting the chip that you want to program. You can select nRF52 (for nRF52840 chip) or nRF91 (for nRF9160 chip).

IDC Cable 10p
(1.27mm pitch)

Beside able to program the IC chip on its own board, this development kit can also act as a programmer to program nRF52xxx or nRF91xxx chips on other boards. You can use nRF9160 as a programmer device to program the chips (nRF52840 or nRF9160) on the Thingy91 board via the JTAG cable (10pins ribbon cable).

How to get started?

This was one big question on my head. I done many installations until I also don’t know what I was doing. Here I want to start off by learning how to program a “Hello World” firmware into nRF52840 chip first.

I decided not to rush into things and do things step by step from the basis fundamental first.

What do you need?

  • Development Kit nRF9160-DK
  • USB micro cable
  • A computer with a Windows Operating System

Ways to program Nordic nRF52840 chip

There are a number of ways to program the Nordic chip nRF52840.

  • Debug header
  • USB Bootloader (Wired)
  • USB Mass Storage
  • Bluetooth Firmware Loader (Wireless)

Click here for further details of programming Nordic chips.

Getting start with nRF9160-DK

You can refer to the reference from this webpage.
https://devzone.nordicsemi.com/nordic/cellular-iot-guides/b/getting-started-cellular/posts/getting-started-with-nrf9160-dk

Summary

  1. Install the software nRF Connect on your desktop computer.
  2. Open up this software nRF Connect.
  3. Go to Getting Started Assistant, click <Install>
  4. Open and execute the program Getting Started Assistant to guide you with the steps to take.

Summary from Getting Started Assistant

  1. Install the toolchain
  2. Clone the nRF Connect SDK
  3. Download SEGGER Embedded Studio
  4. Set up a project in SEGGER Embedded Studio

Install the toolchain

The whole installation experience is a pain. Please ensure there is no space in the name of your folders. It will not be recognized by the software tools.

  1. Install toolchain Chocolatey. Chocolatey tool makes software installation on WinOS looks easy. It will be like typically how we do software installation on Linux OS system. Helps you to automate and create software deployment package for Windows. Learn about Chocolatey here.
    The subsequent steps, we will be doing installation and configuring of Chocolatey from WinOS command prompt.
  2. Open a command prompt as an Administrator on your WinOS computer. Press on your keyboard Windows+X. Click on the pop-up menu “Command Prompt (Admin)” or “Windows PowerShell (Admin)”. A command prompt should pops up.
  3. Paste the following command text into the PowerShell,
    > Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString(‘https://chocolatey.org/install.ps1’))
    This will download and install Chocalatey onto your computer system.
  4. Enter the following command text into the PowerShell to check if Chocolatey is installed.
    > choco
    You should receive the following message when Chocolatey is properly installed.
    Chocolatey v0.10.15
    Please run ‘choco -?’ or ‘choco -?’ for help menu.
  5. Enter the following command texts, and click verify button on Getting Started Assistant. The Assistant should highlight green which indicates that the task is done properly. Do the same for the subsequent command.
    > choco feature enable -n allowGlobalConfirmation
  6. Enter the following command texts, and click on verify button.
    > choco install -y cmake –installargs ‘ADD_CMAKE_TO_PATH=System’
  7. > choco install git
  8. > choco install python
  9. > choco install ninja
  10. > choco install dtc-msys2
  11. > choco install gperf
  12. Download and install ONLY the recommended version of GNU ARM Embedded toolchain so that able to cross-compile for ARM microcontroller chips. Follow what nRF Connect assistant tells you to download.
    https://developer.arm.com/-/media/Files/downloads/gnu-rm/8-2019q3/RC1.1/gcc-arm-none-eabi-8-2019-q3-update-win32-sha2.exe
    which is version 8-2019-q3-update of the GNU ARM Embedded toolchain.
    Install the software to the root directory c:
    The installed folder is probably c:\8 2019-q9-update
    Change the folder name to c:\gnuarmemb

    Ensure that there is a bin folder under c:\gnuarmemb\bin.
    Use the Verify button to confirmed that you have done it correctly.

    Please ignore the following test…..
    Open up “Command Prompt” and key in the following command to check if GNU toolchain is installed.
    > arm-none-eabi-gcc –version

    Please ignore the following test…..
    Install onto “C:\gnuarmemb” directory. (recommended by nRF Connect)
    example: “C:\gnuarmemb\GNU Tools Arm Embedded\9 2019-q4-major

    Click verify on your Assistant when this is done.

Clone the nRF Connect SDK from Nordic Repository.

Nordic has developed SDK specially for their nRF chip products (only for nRF9160 or nRF5340). These source code are in Nordic repository. The following commands are to copy/update that source code onto our own local computer system.

Enter the following command texts in Windows PowerShell, and click on Verify button.

  1. Install West (Zephyr’s meta-tool), a swiss-army knife command-line tool .
    Use pip3 to install west.
    > pip3 install west
  2. Create your own directory to store nRF Connect SDK, and create a directory (no spaces in the directory name) ncs under it.
    example: e:\nRFConnectSDK\ncs\,
    > cd ‘e:\nRFConnectSDK’
    > mkdir ncs
    > cd ncs
  3. Initialise West meta-tool, and update it
    > west init -m https://github.com/NordicPlayground/fw-nrfconnect-nrf
    > west update
  4. Visit the webpage nRF Connect SDK Release Notes to look for the version that you want to clone onto your computer system. Look for the Release Tag to use. In this example, I am looking at “nRF Connect SDK v1.2.0 Release Notes”. The Release Tag that I see from this release is “v1.2.0“. Use this tag for git checkout as shown below. This will fetch the release version v1.2.0 from the repository.
    > cd ‘e:\nRF Connect SDK\ncs\nrf’
    > git checkout v1.2.0
    > west update

    If you want the latest version (may not be a stable version from Nordic), use the command “git fetch origin” instead of “git checkout v1.2.0”. The command “west update” simply update the files to that version.
  5. Install a list of required Python modules.
    > cd ‘f:\nRF Connect SDK\ncs’
    > pip3 install -r zephyr\scripts\requirements.txt
    > pip3 install -r nrf\scripts\requirements.txt
    > pip3 install -r bootloader\mcuboot\scripts\requirements.txt

Download SEGGER Embedded Studio

Download and install SEGGER Embedded Studio.

Set up a project in SEGGER Embedded Studio

Execute the SEGGER Embedded Studio software.

  1. Use command prompt to navigate to the folder where SEGGER Embedded Studio is located. In this example, it is located at “e:\nRF Connect SDK\arm_segger_embedded_studio_v442a_win_x64_nordic\bin\”
  2. Execute the file emStudio.exe to launch the software.
  3. A pop up screen may appeared indicating “No commercial-use license detected”. Activate your free license.

Setup the path of the Zephyr Base (the location of your cloned Zephyr repository, path ncs/zephyr), and the path where GNU ARM Embedded Toolchain is installed.

In the software go to Tools > Options, and select the nRF Connect tab.

In our example, the path for

  • Zephyr Base, “e:\nRFConnectSDK\ncs\zephyr
  • GNU ARM Embedded Toolchain, “c:\gnuarmemb

You can now start opening your nRF Connect project. Select File > Open nRF Connect SDK Project.

Follow the setting of the screenshot on the right.

For the board name, remember to select the name ending with xxxxxxns. Which means Non-Secure version.

  • CMakeLists.txt (location of the project makelist. Typically located at ../ncs/nrf/samples/nrf9160/lte_ble_gateway/CMakeLists.txt)
  • Board Directory (location of the board used for the project. Typically located at ../ncs/zephyr/boards/arm/nrf9160_pca10090 )
  • Board Name (names for the board will be automatically generated when the board directory is selected). Always choose the board name with xxxxns at the end of the name. ns means Non-Secure.
  • Build Directory (the folder of where the output build will be located, will be automatically generated when the CMakeLists.txt is selected. The build… will be generated in the same directory of the CMakeLists.txt)
  • Check the box “Clean Build Directory” so that the outdated build is not cache.

Success!!!

Successfully loaded

Problems encountered

  • Issue installing Chocolatey due to outdated software. TLS 1.2 at a minimum version.
    Error message “DownloadString” with “1” argument(s): “The request was aborted: Could not create SSL/TLS secure channel.”
    reference: https://chocolaty.org/docs/troubleshooting
  • When verifying “choco install -y cmake –installargs ‘ADD_CMAKE_TO_PATH=System'”, an error message occurred.
    Error message is ” ‘cmake’ is not recognized as an internal or external command, operable program or batch file.”
    Solution 1: is to download and install cmake software. https://cmake.org/install/
    It is found that cmake is already installed, just that it needs some repair only. You may need to install and uninstall.
    Remember also that you may need to go to Tools > Options > nRF Connect > Executables > CMake Executable, to set the location of the newly installed cmake program.
    Solution 2: set environment path in the command prompt.
    $env:path += “;C:\Program Files\cmake\bin”
    After this, key in cmake in the command prompt. It should work.
  • SEGGER software keep asking me to activate license.
    Solution: Close Segger Embedded Studio and open any SES project from Nordic SDK.
    https://devzone.nordicsemi.com/f/nordic-q-a/43274/my-segger-license-is-never-activated
    Example of such a SDK project file is “nRF5_SDK_15.2.0_9412b96”
    Open a *.emProject files using the SEGGER program.
    The file can be found under the folders “examples\peripheral\blinky\pca10056\blank\ses”
    There will no longer be a license problem the next time you open the SEGGER.
  • What I learned is Zephyr is a OS is based on a small-footprint kernel designed for use on resource-constrainted systems.
  • Don’t give name to a directory that have space inside.
  • Error message while opening a nRF Connect SDK project.
    “warning: BSD_LIBRARY (defined at…….. has direct dependencies TRUSTED_EXECUTION_NONSECURE with value n, but is currently being y-selected by the following symbols: -MODEM_INFO (defined at…….”
    Solution: When choosing the board name, choose one with name ending with xxxxxxns. Reason: bsdlib can only be used from a non-secure application and you need bsdlib to use the modem.
    Reference: https://devzone.nordicsemi.com/f/nordic-q-a/57722/cmake-error–open-nrf-connect-sdk-project

Other good tutorial resources

Updating the Modem firmware on nRF9160

Remember to put the switch to nRF9160 (instead of nRF52840) before the programming. You can switch and click on the “Read” button from the nRF Programmer software to check which chip the nRF9160-DK board is connected to.

The following tutorial is a good reference to show us how to update the modem firmware to the nRF9160 chip on the nRF9160-DK board.

Update Thingy91 with the latest firmware

You can download the latest “precompiled application and modem firmware” from this URL
https://www.nordicsemi.com/Software-and-tools/Prototyping-platforms/Nordic-Thingy-91/Download

Inside this package, you will see 4 folder,

  • images_dfu_bin (programming nRF52840 nRF9160 chip via bin format using ???)
  • images_dfu_hex (programming nRF52840 nRF9160 chip via hex format using bootloader method)
  • images_full (full firmware image, programming nRF52840 nRF9160 chip firmware via J-Link debug probe/development kit)
  • mfwnrf9160110.zip (modem firmware)

Let’s use the full firmware image method. Inside the folder images_full, you will see,

  • thingy91_at_client_2019-11-29_d3130d77.hex (flash nRF9160 with only AT Client application)
  • thingy91_ltem_2019-11-29_d3130d77.hex (flash nRF9160 with Asset Tracking Demo (connect to nRF Cloud Server for Demo purpose) using LTE-M network)
  • thingy91_nbiot_2019-11-29_d3130d77.hex (flash nRF9160 with Asset Tracking Demo (connect to nRF Cloud Server for Demo purpose) using NB-Iot network)
  • thingy91_nbiot_legacy_pco_2019-11-29_d3130d77.hex (???)
  • thingy91_nrf52_usb_uart_bridge_2019-11-29_d3130d77.hex (flash nRF52840 to act as a USB-UART converter chip)

There are 3 firmware that needs to be updated.

  • thingy91_at_client_2019-11-29_d3130d77.hex
  • thingy91_nrf52_usb_uart_bridge_2019-11-29_d3130d77.hex
  • mfwnrf9160110.zip (modem firmware)

They can be loaded via the nRF Cloud Programmer software.

For modem firmware, after going into the programmer software, go to the lower right side of the screen and load in the *.zip file (modem firmware). Remember to slide the switch on the Thingy91 to select for the nRF9160 chip.

For the thingy91_at_client firmware, in the programmer software load up the hex file. Then click “erase & write” to begin flashing. Remember to slide the switch on the Thingy91 to select for the nRF9160 chip.

For the thingy91_nrf52_usb_uart_bridge firmware, in the programmer software load up the hex file. Then click “erase & write” to begin flashing. Remember to slide the switch on the Thingy91 to select for the nRF52840 chip.

Playing with the nRF9160 modem

Everytime the board is plugged in, there will be 3 COM port that appears. 2x COM belongs to the nRF9160 chip, one maybe for the AT command, and the other maybe the logging messages from the modem module. 1x COM belongs to the nRF52840 chip.

Using the software LTE Link Monitor to initialise the modem and send AT command.

First connect the device, communication port by selecting the connected Thingy91 or nRF9160 device.

Some console text will starts to appear. If not, can also press the reset button on the hardware board. Key in the command “AT” to check if the board is responding to this AT command.

Key in “AT+CGMR” to check the modem firmware version.

Key on the modem command “AT+CGMR” to initalise and start the module. The indicator on the software Modem, UICC, LTE, PDN will all start to turn green.

Network will display, Singapore Telecom

For more information on AT commands for NB-IoT, refer to this page.

Flashing with AT firmware only

AT+CEREG=4
AT+CFUN=1 (connect to LTE network)

<- Back to Bluetooth Resources Page

Compare NB-IoT with LTE-M

reference from
https://www.i-scoop.eu/internet-of-things-guide/lpwan/nb-iot-narrowband-iot/

LPWAN

DescriptionNB-IoT
(Cat-NB1)
LTE-M
(eMTC, Cat-M1)
LoRa
LoRaWAN
Sigfox
GPRSLTE
QoS (Quality of Service)LowHigher
Cellular TechnologyYes (using existing cellular network)Yes (using existing cellular network)No
(non-cellular LPWAN)
For mobile applicationNo (for static only)Yes (cellular switching)No
Latency1.6 to 10 sec100 to 150ms
In-door applicationBetterGood
CommunicationHalf-duplex Half-duplex
Devices talk less oftenDevices talk less oftenDevices talk more often
Good if only a few devices is expected to be used in the remote area.same as NB-IoTGood if many devices are deployed in area the same area nearby.
CostVery Cheap
$1/month
CheapCheapExpensive
Brand New methodLight version of LTE.

Telecom Connectivity Offer

Some of the offer from Mobile Network Operators (MNOs).

International Sim Card for NB-IoT connectivity

Evidence suggesting that NB-IoT is a method of using existing Telecom cellular network for IoT devices

Company supplying NB-IoT module

Other lists of manufacturer brands for NB-IoT modules can be found here,
https://www.gsma.com/iot/mobile-iot-modules/

<- Back to Bluetooth Resources Page

Laundromat Payment System Installation Guide

Example of an Installed Payment System

This is an illustration of an installation done. There is no network point in this illustration as it is using a 3G modem for communication instead. The cables are pulled into the enclosure via the cable entry hole channel on the left side of the enclosure.

In a typical setup, the following 3 type of cables has to be laid.

  • Dual ganged power socket.
  • Network point socket.
  • Cables from machines to this payment terminal enclosure.

Enclosure Installation Height

The recommended installation height of the power/network socket point is about 1157mm. The enclosure will be installed after power/network sockets are installed. The enclosure will cover directly over the sockets and cable trunking.

The position of the sockets will be the center location of the enclosure. The installed position of the sockets will determine the position of of the payment terminal.

Install the sockets/enclosure at a comfortable and ergonomic high for your user.

The following information provides the internal layout of the casing.

Power Point & Network Point Installation

The payment system requires a minimum of 1x power point and 1x network point. A spare power point is recommended for future use.

Resources to Provision:

  • 2x Power Point
  • 1x Network Point

The following is the dimension of the enclosure covering the power point and network point. The opening from the enclosure is about 298 x 120mm. Space is tight. Please ensure that there is enough space for the enclosure to cover over the power/network points on the wall.

Internal layout dimension of the payment terminal enclosure.
Internal structure of the enclosure.
Left cable entry by the side of the enclosure.
Left and bottom entry for cable trunking.

Please note that there are 3 pre-designed hole channel for cable entry. Two are located by the sides and one at the bottom of the enclosure. The hole channels are aligned to the ceter of the enclosure. It is recommended not to have the cable entry coming from the top of the enclosure, nor the trucking be laid across the top of the enclosure. This is for aesthetically pleasing reason. It will look nicer to select the cable entry channel location to a position that is not too visible. The best entry location will be from the bottom of the enclosure.

The standard width of the hole channel (max) is indicated on the layout above. The holes are design base on the commonly available cable trunking found on the market. Suitable for small and big cable trunking.

There may be situation where the 3 standard hole channel on the casing may not be big enough for the trunking deployed. If the trunking size is bigger than the standard hole channel on the casing, the hole channel will have to be manually enlarge to cater for the massive chunk of wiring.

Cables from Washer/Dryer machines to Payment Terminal

Cables are required from the machines to the payment terminal location. This is to allow the payment system to trigger the machine after the user successfully made their payment.

Cable range AWG20-25 (multi-strand) is recommended. CAT5 cables is easily available and is also fine to use.

Estimate about 1 cable per Washer/Dryer stack. It is recommended to lay a spare cable for every 2 stacks of machine. There are a lot of vibration from the machine, and it is possible that wire may break after long use. This is especially for Cat5 cables as they are only of a single strand. Therefore spare cables is recommended.

These cables will be laid all the way into the enclosure together with the power/network socket. There is no need to terminal these cables. Just leave it dangling with an extra length of about 500mm will.

Network Port Settings

The payment terminal communicates over the internet for all payment transaction. When using local network point that is protected by the organisation firewall, some of the port number needs to be open so that communication needed by the transaction can proceed.

Please contact us for further details of the exact network port to open.

Use Ping.exe program to test data route to ensure that the port is open on the network point.

Common mistakes and problem faced

Here are some of the commonly mistakes and problem that makes the installation

  1. Power socket point and Network point has to be installed in the middle of the casing position. The back of the casing has a hole opened for power point and network point. Please position the power/network point socket in the middle where the casing has to be installed. Always install them to the middle of the casing enclosure.

Precaution for Recessed Installation (not surface mounting)

  1. Please ensure that there are no obstruction to the path of slotting the casing into the recessed hole. All wiring and termination has to be behind the wall, and in to middle of the recess hole position.
  2. Have a wooden frame made to size, for the casing to slot in. This frame provides a stronger support and makes it more precise for the casing to fit it. Casing can then be used to secure the casing firmly onto the frame. Gypsum plasterboard should not be used as a frame for the casing. The soft powdery structure is not suitable to hold the casing.

Wiring & Connection

Wiring and connection for speed queen washing/dryer machine.

Wiring color code

The following is the propose color code of the wiring assuming that a CAT5e network cable is used.

Pluggable Screw ConnectorCAT5e wire color codeVHR-7N Connector
Pin 1Orange/WhitePin 4
Pin 2 Orange Pin 5
Pin 3 Green/WhitePin 6
Pin 4GreenPin 7
Propose standardised color code for the wiring

Board Description (MDB Payment Interface Board)

MDB Payment System Interface Electronic Circuit Board

Testing with $0.01

Click here for payment system testing procedure with your credit card or cashless card.

Restarting the payment system.

There are two touch button assigned to the payment system to restart the system. It is usually the last button and the first button on the touch panel.

On a 8 machines payment board set, the default buttons are W4 (last button), and D1 (first button). Simply press and hold W4, followed by pressing and holding D1 button. Hold both button until you hear a short beep, followed by a long beep, then you can release your finger.

You should be able to see the system doing a full power off, and on restart process.

For IUC180 payment terminal, you will need to wait for about 10sec before terminal is ready for use.

For IM30 payment terminal, you will need to wait for about 2-3 minutes for the terminal to establish the internet connection before you can start using it.

Video demonstration of restarting the payment system.

Clearing Credits on the Washing Machine

This procedure is for fast forwarding or skipping the washing machine operating procedure. This is needed to help clear the credit triggered on the machine.

A quick paragraph to summaries the procedure. Simply ensure that the bypass switch is activated (disconnected or open circuit), press and hold button 1 & 2 to enter into the maintenance mode “rAPd”. Press “Start” button until the whole process ends.

The detailed procedures and explanation is as follows,

  1. When the machine is idling, the display panel shows “100” indicating the credit of $1.00 required to start the machine.
  2. After the payment, the machine will response with a beep with number changed to 30 (representing 30min of washing) This indicate that the machine has accepted the payment.
  3. Open the front panel with a physical key.
  4. Disconnect the bypass switch. This bypass switch allow us to go into the maintenance mode. With the machine bypass activated, it will also not record any transaction or operation to this machine. If you can see a sensor switch which detect the panel open, this is also known as the bypass switch. The washer (left side), dryer machine (right side), each has their own by pass switch.
  5. Press and hold button 1 & 2 (the left side buttons, top and button). It will go into maintenance mode with the panel displaying “rAPd“.
  6. The front loading door has to be close in order for the machine to cycle through the wash cycle.
  7. Press the green Start button to fast forward the whole washer process. This reduces the timing on the machine. You will see the number 30min reducing. Keep on pressing until the value becomes 1, then wait for a few second for the machine to react, and a final press will get the machine time to becomes 0.
  8. Open the door to complete the whole process. The washing machine will reset back to machine idling state. This panel will display “100” again, and the machine status will become available for the next transaction to take place.
  9. Do remember to restore back the bypass switch before leaving the place. Test to check that the machine cannot enter into the maintenance mode by press holding the button 1 & 2.

Price Settings on the Washing Machine

  1. Open the door for 2 sec and close it back to go into the configuration mode.
  2. Press and hold button 1 & 2.
  3. You will enter into “rAPd” menu. It is a bypass operation.
  4. Press button 3 & 4 (up/down button) to scroll through the menu.
  5. Scroll to the menu item Prog. Then press button 5 to enter.
  6. Scroll to the menu item AtS, then press enter.
  7. Scroll to the menu item 0, then press enter.
  8. Then the price setting will be displayed. Example for $1, it will be 0100.
  9. Press button 3 & 4 to change the price.
  10. Press enter to go to the next digit until the price is entered.
  11. Then press button 2 (back key) to escape all the way to the operation mode.

Troubleshooting Problems

Error messages on the payment terminal iUC180

  • REFUSED (XX) REMOVE CARD
    Network connection issue with the payment.
    Resolved by resetting the payment terminal, or do a manual settlement to see if the problem go away.
  • OCBC CABLE UNPLUGGED NETWORK ERROR
    Ethernet cable unplugged
  • OCBC NETWORK ERROR
    Local Area Network issues, LAN port not opened for the bank. Communication error.
    • Test using Telnet command via the Win10 Command Prompt
      • telnet 43.245.17.122 15443
      • telnet 43.245.16.210 15443
    • (both should show a blank screen meaning network connectivity is there)
  • DRMS NETWORK ERROR
    Network DHCP issue.
  • DRMS CONNECT ERR-1601
    socket creation error
  • OCBC CONNECT ERR-1602
  • COMMUNICATION ERROR
    should be board MDB communication error.

Some of the more common problems

  • Network point is down
  • Machine is not triggered
  • Machine is not available for selection
  • Cannot connect to payment gateway

Maintainance mode on payment terminal iUC180

QR Code

QR code can be found on the system which will lead you to this page. (future implementation)

 

 

How to load Arduino bootloader into ATMEL microcontroller ATMEGA328P

Install Mini-Core

Install Mini-Core following the instructions given on their githhub page:
https://github.com/MCUdude/MiniCore#how-to-install

This installation method requires Arduino IDE version 1.6.4 or greater.

  1. Open the Arduino IDE.
  2. Open the File > Preferences menu item.
    Arduino preference menu

  3. Enter the following URL in Additional Boards Manager URLs:
    https://mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.json
    Additional Boards Manager URLs

  4. Open the Tools > Board > Boards Manager… menu item.
    Arduino board selection

  5. Wait for the platform indexes to finish downloading.
    Scroll down until you see the MiniCore entry and click on it.
    Click Install.
    Boards Manager, MiniCore by MCUdude

  6. After installation is complete close the Boards Manager window.

Programmer preparation

Plug the USBasp device into your computer.

USBasp programmer


If you get an error stating the USBasp cannot be found,

use Zadig to download the device driver.

Go to : https://zadig.akeo.ie and download the software. Once downloaded

Launch the software and go to Options>List all devices

Zadig software for programmer driver

 

In the drop-down menu, select USBasp.
Then in the Driver selection click the small arrows until you find “libusbK (v3.0.7.0)”

Zadig driver selectioin

Then click “Replace Driver”

Burning the Bootloader onto the chip

Inside of Arduino IDE go into Tools>Programmer>USBasp

Arduino select programmer USBasp

Select the board ATmega328

Select board ATmega328

and select the variant 328/328A

Select IC chip variant

 

Connect the USBasp to the Arduino programming port (6 pins header)

Connecting programmer to Arduino ICSP programming header

Go to Tools>Burn Bootloader

Burn Arduino bootloader into ATMEL ATmega328 microcontroller

You should see this message in the console.

avrdude done. Thank you.

A quick way to check if the boot-loader was correctly burned is to try loading with an empty source code.

If the loading fails, try changing the port in Tools>Port. If the loading still not works, try redoing step 3. for the start.

 

Arduino programming via USB

 

You can program the board using a USB B mini, just like you would a normal Arduino Board.

For this you need to change the port if necessary: Tools>Port

Use the Check button to compile ans the arrow to load the code onto the board.

Select Arduino USB programming port.

Set up:

The pins of the USBasp must be connected to the corresponding of the Arduino ICSP connector.

Arduino programming header port

Basic circuit for Arduino and boot-loader programming.

 

 

 

Other references

Coin Notes Acceptor and Dispenser Machines Singapore

This page contain references to buying of a coin dispensing machine and notes-to-coin machine. Coins, Notes and token solution for your automated business payment collection.

Bills and Coins Machine Product Companies

Bills to Coins Changer

Notes to Coin changer machine

Bills Validater / Note Acceptor

Money Notes Acceptor device

Coin Accepter

Coin Acceptor device

Coin Dispenser (Hopper)

Coin Dispenser device

Custom Cash (notes & coin) system.

We can help you to design a system suitable for your application use.

For customised automatic cash (notes and coins) payment collection system, please contact our sale engineer with your project details for a quotation.

Cashless Payment Terminal

Microcontroller Firmware Programming Upload with MPLAB X IDE

Introduction

This section provides fresh user a step-by-step instruction to upload your updated firmware (a program or machine codes) onto your circuit board using a Microchip microcontroller.

Microchip logo

Things That You Need To Prepare

  1. Your Microchip microcontroller circuit board
  2. Programmer Tool (PICkit)
  3. MPLAB X IDE (Integrated Development Environment)
  4. Firmware (a hex code file *.hex or project files, containing the program of your controller)

Once you are prepared, you can proceed step-by-step to upload your firmware to your microcontroller.

Microchip Circuit Board

Most microchip circuit board design by PIC-CONTROL comes with a programming port which allows us to upload the program onto the microcontroller chip onboard.

There are standard microchip programming port also known as ICSP, which you can connect to with your programmer tool.

Programming Connector Port on your circuit board product

The programming port is usually located near the edge of your circuit board. It is a row of 6 holes grouped up with a rectangular box (2.54mm pitch header pins).

You must know how to identify the pin no.1 on this port. Pin number 1 of the footprint is indicated by a triangle arrow marking. You can also identify this pin 1 from the bevel corner on the rectangular box.

The following are some photos of how the ICSP programming port looks like on your circuit board.

ICSP programming port on PCB board     ICSP programming port on PCB board     ICSP programming port on PCB board

smd ICSP programming port on PCB board (without holes) ICSP (a special version without any holes)

You are suppose to connect the programmer tool to these ICSP port, with alignment to the pin 1.

Details of the procedure will be provided in the later section below.

Programmer Tool

You will need to get yourself a programmer tool. A programmer tools helps you to connect your computer to your microcontroller chip. It is used for uploading of the microcontroller firmware (controller program) onto the microcontroller on your circuit board.

There are a number of programmer tools which allows you to upload your firmware. In this example, we are using the official PICkit 3 or PICkit 4 programming tool from Microchip.

Other commonly known programming tools available are ICD4 (In-Circuit Debugger), ICD3, PM3 and REAL ICE.

Please take note of the pin no.1  on the programmer tool. You must identify this pin and align it to the pin 1 of the ICSP port on your circuit board.

PICkit 3 Programming Tool

PICkit 3 programmer tool

PICkit 3


PICkit 4 programmer tool

PICkit 4 (new version)

PICkit Programming Tool’s Pin-out

This is the PICkit programmer pin-out. This pin-out is also known as the ICSP programming port.

Please take note that the pin no.1 is identified by the triangular arrow head.

PICkit 3 programmer pin out

MPLAB X IDE (Integrated Development Environment for Microchip Microcontroller)

The last item that you need is the software which allows you to develop and upload your program to your microcontroller chip.

MPLAB X IDE is a free microchip microcontroller development software. It is a complete platform for your firmware coding development work.

What you should do now is to download the following,

  1. MPLAB X IDE software (Windows version).
  2. MPLAB XC Compiler.

Download & Install the MPLAB X IDE Software MPLAB X IDE

You can click on this shortcut link to download the latest MPLAB X IDE software (Windows version). If this links cannot work, please follow the steps here to download from the Microchip official website.
https://www.microchip.com/mplab/mplab-x-ide

  1. Click here to go to the Microchip website for MPLAB X IDE software.
  2. Scroll down to the bottom of the page and look for the “Downloads” tab to click on.
  3. Go to the respective version (Windows, Linux or Mac) and download the software.
  4. As of this point in time the software is of version “MPLAB® X IDE v5.05

Install this software to your computer.

Download & Install the MPLAB X Compiler MPLAB XC Compiler

The compiler converts the programming source code into a machine code before you can upload the program into a microcontroller chip. Different microcontroller would requires its respective compiler. It is recommended to install all the compiler as follows.
http://www.microchip.com/mplab/compilers

Install these MPLAB XC8 and MPLAB XC16 compilers to your computer.

Step-by-Step Procedure to Upload Firmware to Microcontroller Chip

Now that you have your

  • Circuit Board
  • Programmer Tool
  • MPLAB X

ready…

We can start to upload your project or *.hex file..

 

There are two modes of uploading firmware to the microcontroller.

  1. Method 1: Upload hex.* file (machine code) using MPLAB X IPE software.
  2. Method 2: Upload project (source code) using MPLAB X IDE software.

Method 1: Firmware upload using IPE Software

This method is usually used for the production. Programmer operators will be provided with a *.hex file for them to upload the firmware to the microcontroller chip.

The advantage of this method is that it is simple, and it do not expose your actual project source code.

 

Step 1: Launch the program MPLAB X IPE software.

IPE software launch up screen shot

Step 2: Under the section “Device:“, select the microcontroller part number that you want to load your firmware to. Refer to your schematic for the exact microcontroller part number.

Click on the button “Apply“.

IPE selecting microcontroller device

Step 3: Plug in your programmer tool to your computer.

You should notice that the software update the “Tool:” section once your tool is detected.

IPE programmer tool detected

Click on the button “Connect” to start connecting to your programmer.

You should see the following message printed out…

*****************************************************

Connecting to MPLAB PICkit 3…

Currently loaded firmware on PICkit 3
Firmware Suite Version…..01.51.08 *
Firmware type…………..Enhanced Midrange

IPE programmer tool successfully connected

Step 4: Under the section “Hex File:“, load your *.hex file for your production. This is the machine code file for your circuit board. This is the only file required for the production.

For a start, this file is located in your project folder. For example…
Your project directory -> “yourProject.X\dist\default\production\yourProject.X.production.hex

Step 5: Connect your programmer tool to the ICSP port on your circuit board. Make sure that the pin 1 on your connector is aligned correctly. Then power up your board.

Step 6: Click on the button “Program” to start the uploading of your firmware to the microcontroller chip on your circuit board.

IPE program button

Yes, you are done. Congratulation.
Your board is successfully loaded with the firmware.

Method 2: Project source code upload using IDE Software

This method is usually used during the development. Engineer can edit the source code and upload the firmware changes onto the microcontroller chip directly.

It is recommended to maintain your firmware version while you are doing editing and improvement work. Keeping the original functioning version is a must. You can always fall back on the original copy if you mess up the project source codes.

Step 1: Launch the program MPLAB X IDE software.

MPLAB X startup screen

Step 2: Open up your project files. Go to File > Open Project…

Select your project files. It is the project folder which ends with *.X. For example “yourProject.X”

MPLAB X select project file

The project will loads up.

MPLAB X upload firmware to microcontroller IC chip

Step 3: Plug in your programmer tool to your computer.

Step 4: Connect your programmer tool to the ICSP port on your circuit board.
Make sure that the pin 1 on your connector is aligned correctly. Then power up your board.

Step 5: Click on the arrow down icon below the menu bar.
Select “Make and Program Device” to start the uploading of your firmware to the microcontroller chip on your circuit board.

Yes, you are done. Congratulation.
Your board is successfully loaded with the firmware.

More…

For further details, you can check up the Microchip official website Microchip logo
or YouTube YouTube logofor a more detailed instructions.

How to crimp 1mm pitch connector (JST connector)

The principle of crimping a 2.54mm pitch female socket header and a 1mm pitch connector is fairly similar.

The difference is that a 1 mm pitch connector pin is much tedious to crimp because it is too small. For most people, a magnifying glass is required while doing the crimping.

JST 1mm pitch connector pin    1mm pitch pin for crimping onto wire

JST 1mm pitch connector receptacle housing receptacle socket for housing the pins

 

crimping tool for JST 1mm pitch connectorNot only it is small in size, the tool for crimping this 1mm pin is also difficult to find. This tool is rare, hence it is also very expensive. The crimping tool for a 1mm pitch pin (0.039″) can cost a couple of hundreds to a thousand of dollars. The tool name from JST (JAPAN SOLDERLESS TERMINALS) is called WC-SH2832 (Crimp Tool, Ratchet).

 

JST Connector pitch: 1mm

Connector pin width is less than 1mm

Wire Gauge Size is 32 to 28 AWG

 

Crimping 1mm pitch pin Step by Step

JST 1mm pitch connector pin
1- sleeve gripper for gripping the wire sleeve as a strain relieve,
2- wire strand gripper for the contact to the wire strand.

  1. Close up the sleeve gripper for the wire’s sleeve. This allows the pin to easily grip the wire when you position the wire for crimping.

    close up the wire sleeve gripper before inserting the wire

  2. Insert the wire into the pin. Position it nicely with the pin’s sleeve gripper end holding the wire sleeve. Ensure that the wire sleeve is over the sleeve gripper but before the wire strand gripper.
    1mm pitch JST connector pin (front side)     1mm pitch JST connector pin (side view)
  3. Crimp the sleeve gripper first. Then proceed to crimp the exposed wire with the wire strand gripper.
  4. After crimping, ensure that the width of the pin is less than 0.88mm. If the width is too big, it will not be able to fit into the connector housing. Use your crimper to lightly squeeze it narrower.
    ensure that the width of the 1mm pitch pin is less than 0.88mm
  5. After the wire is crimped to the pin, pull the wire to ensure that the crimp is tight. The crimp pin should not give way.
    Properly crimped 1mm pitch JST connector pin
  6. You should be able to easily slide the crimped wire into the connector housing without much force. If it is difficult to insert in, it is probably not done correctly. Redo again and do not force the pin into the receptacle housing.

Contact PIC-CONTROL for 1mm pitch wire assembly

For custom wire assembly of any 1mm pitch connector pin, please contact PIC-CONTROL.

 

 

Electronic Hardware Design Service

Electronic hardware design is a very specialised field. It may be tedious to get started at first because you need quite a number of basic tools for building electronic hardware. Anyone can easily pick up this engineer skills in these days, learning through the internet and using Arduino development kit. The difference between a good and poor hardware design is mainly the experience.

PIC-CONTROL specialises in electronic hardware design and is committed to delivering guaranteed working product to our client. The main hardware design involves the following know-how.

If you are looking for electronic design service, please click here to our engineering service pages.

or contact PIC-CONTROL here.

Power Supply Hardware Design

Power supply hardware is the most fundamental knowledge to have when designing electronic. All circuit requires this hardware design in order to function.

These are the 3 basic power supply hardware for electronics circuit that a designer will encounter on a daily basis.

  • Regulated DC Voltage (<24Vdc)
  • Unregulated Power Supply
  • 230Vac to Vdc design

Other Power Supply Type

  • 3 Phase AC Voltage
  • Regulated DC Current
  • Very high DC voltage regulation
  • Very high DC current regulation

Microcontroller and Digital Circuit Design

The microcontroller is the heart of most electronic design these days. A microcontroller is like a mini computer chip that is able to control logic using software codes.

Due to its flexibility, most modern electronic design uses a microcontroller. It is considered a general purpose IC chip that is necessary for modern hardware design.

Features:

  • Digital Logic control
  • Analog Voltage Sensing
  • Standard Data Communication (UART, SPI, I2C)
  • Timer Timing Control
  • Analog Voltage Out

FPGA controller (similar to the microcontroller) can do operations at a much higher speed. For an application that needs computation on the fly, FPGA is an alternative. It is slightly more expensive. Most project applications do not need these extreme features.

Data Communication Design

Depending on the industry that you are in, commonly used data communication are fairly different

  • USB for consumer electronics.
  • RS232, RS485 for industrial electronics.
  • Ethernet network communication for office and new industrial electronics.
  • Wireless. (not recommended for industrial designs)

Analog Electronic Design

Analog design is seldom used in the modern electronic design. Most analogue features are integrated into a specialised IC chip. The integration work becomes more digital. It is easier and more precise when compared to designing our own analogue circuit from scratch.

For basic analogue design, it is hard to avoid using the op-amp component. It is a basic component used in the analogue design. There are many different types of the op-amp to select from depending on the nature of your project.

Industrial Standard

Difference electronic hardware designer think differently. Their design evolves over the years in their own industry. Other designers also start to copy to keep their product compatible with their industry. Over time a pattern can be observed from the electronic hardware that is designed in a particular industrial.

The electronic hardware in an oil and gas industry is different from the automotive industry. Building offices and home consumer products have their own standard hardware design.

The following are some of the evolution points to take note of when evaluating hardware design across the various industries.

Electronic Hardware Design in Singapore

For electronic hardware design, you can contact PIC-CONTROL. Send us your electronic hardware requirements to us, and we will translate your idea into a working hardware design for you.

 

 

DIY Surface Mount Soldering and PCB Assembly

This page is to demonstrate how easy it is to solder very small electronic SMD (surface mount device) components on your PCB board. It is easier to work with compared to through-hole components. The component insertion time is shorter, and there are no component’s leads to cut away after the soldering. This save time and cost.

SMT (surface mount technology) methods of assembly PCB has significantly improve the production efficiency. Not only it reduces the board size and board cost, SMD components are usually costing lesser. The SMT design also make automation of PCB assembly much more efficient.

The re-work with SMT boards is also simpler. Using a hot air blower, it is very simple to de-solder and re-solder of a 44 to 100 pins IC chip.

There are many methods to working with SMT components. The following presents some of the cost effective methods suitable for low volume production.

Advantages of Working with SMT Board

  • Smaller
  • Faster
  • Cheaper
  • Lower probability of being obsolete

The board size can be smaller reducing your product size and weight. The use of lesser material can help minimise cost.

As more production is using SMT, the cost of the surface mount components will usually be cheaper than the through-hole version. The chances of the component’s package being forced end-of-life or obsolete is also lower compared to through-hole.

Due to the simple assembly of surface mount, it simplifies the assembly automation for mass production. This not only speed up the assembly process, ultimately the cost of assembly is going to be lower.

The small component and devices will also use up less space for your logistic storage. It takes less space to keep your component parts and your finished product. The reduce weight and size also helps to lower your shipment cost.

Disadvantage of Working with Small Components

  • Not suitable to deploy in a very dirty and dusty environment without an enclosure.
  • May be too small to work with for some technician.
  • Additional tools and equipment may be required

SMT is not suitable to deploy in a very dusty and dirty environment with proper enclosure protection. There is a conductivity in every material. A dust may fall in between the fine pitch of the IC chip and unintentionally causes a connection or short circuit. This may result in a faulty circuit operation. It is important to keep the circuit free from dust and dirt especially when the pitch distance between the pins are 1mm and smaller.

Some technical may find it harder to work with SMT components. A better eye sight compared to working with through-hole compoents. Their hand should not be shakey when placing very fine pitch components.

While SMT soldering can be done by an ordinary soldering iron, some tools are recommended to better help you work with SMT.

  • A pair of good staineless steel tweeter.
  • Flux to clean the contact surface.
  • Hot Air Rework Station for doing rework.
  • Reflow Oven for small volume mass production.

The following are some useful videos that was posted in You-Tube. Check them out to see for yourself how easy is it to work with SMT components and boards.

Manual Iron Soldering of a Passive Component

SMT components may be small but you can still solder with a soldering iron with ease. This is a video of how a SMD resistor (size 1206) is manual soldered using a solder iron. You can easy solder resistor, capacitor, inductor and diode using this method.

Smaller component size like 0805 is still relatively easy to work with using a simple tweeter and a iron. Size 0603 component can still be managable. Component size 0402 and below will be much tougher. It may be too small for your tweeter to hold. It is still possible but much challenging to work with.

The size which is comfortable for a technician to work with is subjective. As a general rule, the minimum size of 0805 should be easy enough to work with for most age group. For technical that is age 40 and above, they may find it challenging to work with component size 0603, 0402 and below.

Manual Iron Soldering of Fine Pitch IC Chip

This method of soldering small SMT IC chip is applicable to IC pin pitch as low as 0.6mm distance apart.

The key ingredient is the use of flux to keep the solder flowing like a liquid so that it will not bridge as a lump. Flux may not be neccessary for passion components or IC chip with pitches of 1.27mm and above. It is a must for SMT IC components with fine pitches.

A clean iron tip will improve the soldering experience. Always tin your soldering iron tip when it is not in use. Tinning acts as a layer to prevent the soldering tip from oxidising. An oxidised tip will act as an insulator prevent the heat from flowing to the component’s lead. Tin the tip when you are not using the iron for the next 5-10 minutes. Tinning is recommended if the iron heating is left idling for some time or before it is powered off.

De-soldering and Re-soldering of Fine Pitch IC Chip

SMT IC chips may seems small to work with. Actually the rework is much simpler when you have a Rework Station equipment. This equipment blows out hot air which will melt the solder on the board. This allows you to remove the SMT component easily with a tweeter. The same equipment can also help you to solder SMD component with ease.

Reflow Soldering Method for SMT PCB Assembly Production

Reflow method is a simple method which allows you to solder your boards at one go using a reflow oven. The following steps provides you an overview of the PCB assembly process.

  1. Apply soldering paste to the bare PCB board using a stencil.
  2. Place your SMT components on the PCB board that was applied with the paste.
  3. Place the assembled PCB board into the soldering oven for a couple of mintues.
  4. Yes. Your boards are now soldered. It is so simple.

The following a a short video which demonstrate to you how the process is like.

 

Self Alignment of SMT Components During Reflow Soldering

For those who had not experience in SMT soldering before, it can be intemiding. One common question is the concern of not placing the component perfectly on the board. While smaller component can be more changllenging to place, the good news is that you do not have to place the component with precision. As long as the component’s lead is touching the SMD pad on the PCB board, that would be good enough. The component will be pull to alighnment automatically during the reflow oven soldering process.

The following video demonstrate the self-alignment of the small SMD components during the reflow oven soldering process.

That’s All for SMT Soldering and Assembly

Simple isn’t it. Once you done it for a few times, I am sure you would not want to go back to through-hole components again.

This is not to say that through-hole components are no good. For connectors where there are a lot of physical handling with user plugging in and out, it is recommended to go for through-hole connector. The mounting will be stronger and is less likely to be damaged due to rough handling. Electrolytic capacitor is currently less expensive than the SMT version.

There are pros and cons working with SMT. I would say SMT has much more benefits compare to through-hole. It is definately a direction which you should move towards.

Proper dispose of battery & electronic waste in Singapore | Save Our Environment

*** <- Attention Please -> ***
This is a reference page for your information to know where to dispose off your toxic waste properly.
Please DO NOT contact PIC-CONTROL for waste disposal matter.
We do not provide waste disposal or consultation service.

The electronic product contains toxic which pollute our environment and can cause a health issue. It is important to dispose of the electronic waste properly to protect our environment in Singapore. Battery especially, contain leads content.

Unwanted electronic waste (e-waste) example,

Places in Singapore which you can dispose of your electronic waste.

There are many recycle bins (e-waste disposal bins) scatter all across the island of Singapore.

Check out this map for the location to recycle your E-waste nearest to your location.

Typical places where you may find the bins,

Map from Starhub for recycling of electronic waste.



Disposal bin for electronic waste


More Recycle SingTel, SingPost E-Waste Programme. Bins can be found at the various location across Singapore island,

  • Singpore Post Office Branches
  • SingTel Shop
  • SingTel Exclusive Retailer



Electronic Recycle Bin at Singapore Post Office and at SingTel

Click here to find out the nearest recycle bin available near your specific location.

Free Mailing of your Electronic Waste

You can also collect free envelopes from SingPost and Singtel to mail your electronic waste for free. Everyone doing their part to protect our environment.

envelopes for disposing electronic waste for recycling

Professional Service for Toxic Waste Disposal

For bulk disposal of toxic waste, you can engage local professional companies to help you with the disposal.

Check out this list of authorised industrial toxic waste collectors in Singapore (This list is provided by NEA).

Example of Toxic Waste Items

  • SLA Batteries (Sealed Lead Acid Batteries)
  • Chemical Waste (Solvent)
  • PVC materials

Be sure to dispose of the toxic waste with care. Protect our environment, protect our home.

Please DO NOT contact PIC-CONTROL for waste disposal matter.
We do not provide waste disposal or consultation service.