Category: electronics

Compiling the Circuit Simulator kTechLab

I was searching for a circuit simulator for Linux and found kTechLab.

There is not a built package for Ubuntu (I’m using Ubuntu 16.04) then I compiled it from source code:

$ git clone https://github.com/ktechlab/ktechlab
$ cd ktechlab/
$ sudo apt-get install libqt4-dev
$ sudo apt-get install kdelibs5-dev
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install

Then I just execute:

$ ktechlab

And kTechLab starts in all its glory!

Advertisements

SDCC went from worst STM8 compiler to best in a very short time

I never used STM8 but I’m impressed with this achievement of SDCC compiler.

The ST marketing materials put STM8 Dhrystone performance at 0.29 DMIPS / Mhz.

Commercial compilers as Raisonance achieves 0.289 DMIPS / Mhz, Cosmic achieves 0.296 DMIPS / Mhz and IAR achieves 0.347 DMIPS / Mhz. See benchmark comparison here: http://colecovision.eu/stm8/compilers.shtml

SDCC 3.5.0 achieves 0.151 DMIPS / Mhz and SDCC 3.6.0 achieve 0.167 DMIPS / Mhz.

Now the SDCC in the repository (Revision #9652) outperforms them all at 0.355 DMIPS / Mhz.

If you want to use STM8 on Linux, these links could be useful:
http://embedonix.com/articles/linux/setting-up-development-and-programming-for-stm8-on-linux/
http://www.cnx-software.com/2015/04/13/how-to-program-stm8s-1-board-in-linux/

Source: Philipp Klaus Krause email in the SDCC mailing list “STM8 Dhrystone performance – new record at 0.355 DMIPS / Mhz using SDCC”.

How to copy a schematic block in the KiCAD

KiCAD is a very nice EDA software, but it try to avoid copying blocks from a schematic to another (from different projects in this case).

Don’t worry! There is a way to you do that:

1) Select the block you want to copy;
2) Using the right mouse button select: "Save Block";
3) Insert a Hierarchical Sheet: menu Place -> Hierarchical Sheet;
4) Choose a "File name" for new sheet and click OK;
5) Press ESC and double click over the Hierarchical Sheet block;
6) Past (Ctrl+V) the saved block in this new sheet, save and close;
7) Open the other schematic where you want to include this block and import it:
   File -> Import Schematic Sheet Content

It might be easier, but KiCAD folks want to avoid users to mess.

Using OpenOCD to program a homebrew nRF51822 board

I created a board to test the Bluetooth Low Energy using Nordic nRF51822 chip, see:

I did everything today (schematic, pcb routing, board etching, soldering SMD components and software test).

I used the nrf51-sdk from here:
https://github.com/relayr/nrf51-sdk.git

For flash programming I used OpenOCD with STLink-v2, this is my openocd.cfg:

$ cat openocd.cfg 
# nRF51822 Target

# Using stlink as SWD programmer
source [find interface/stlink-v2.cfg]

# SWD as transport
transport select hla_swd

# Use nRF51 target
set WORKAREASIZE 0x4000
source [find target/nrf51.cfg]

Then I just execute it from terminal:

$ sudo openocd -f openocd.cfg 
[sudo] password for alan: 
Open On-Chip Debugger 0.10.0-dev-00040-gd52070c (2015-11-01-10:42)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Info : STLINK v2 JTAG v17 API v2 SWIM v4 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.233751
Info : nrf51.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : accepting 'telnet' connection on tcp/4444
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0xc1000000 pc: 0x00000a40 msp: 0x20004000
auto erase enabled
Info : nRF51822-QFAC(build code: A1) 256kB Flash
Info : Padding image section 0 with 2112 bytes
Warn : using fast async flash loader. This is currently supported
Warn : only with ST-Link and CMSIS-DAP. If you have issues, add
Warn : "set WORKAREASIZE 0" before sourcing nrf51.cfg to disable it
target state: halted
target halted due to breakpoint, current mode: Thread 
xPSR: 0x61000000 pc: 0x2000001e msp: 0x20004000
wrote 93184 bytes from file s110_softdevice.hex in 4.252896s (21.397 KiB/s)
auto erase enabled
Warn : using fast async flash loader. This is currently supported
Warn : only with ST-Link and CMSIS-DAP. If you have issues, add
Warn : "set WORKAREASIZE 0" before sourcing nrf51.cfg to disable it
target state: halted
target halted due to breakpoint, current mode: Thread 
xPSR: 0x61000000 pc: 0x2000001e msp: 0x20004000
wrote 13312 bytes from file bletest.bin in 0.629010s (20.667 KiB/s)
Info : dropped 'telnet' connection

And in other terminal I execute:

$ telnet localhost 4444
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger

> reset halt
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0x00000a40 msp: 0x20004000

> flash write_image erase s110_softdevice.hex 0
auto erase enabled
nRF51822-QFAC(build code: A1) 256kB Flash
Padding image section 0 with 2112 bytes
using fast async flash loader. This is currently supported
only with ST-Link and CMSIS-DAP. If you have issues, add
"set WORKAREASIZE 0" before sourcing nrf51.cfg to disable it
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000001e msp: 0x20004000
wrote 93184 bytes from file s110_softdevice.hex in 4.252896s (21.397 KiB/s)

> flash write_image erase bletest.bin 0x18000
auto erase enabled
using fast async flash loader. This is currently supported
only with ST-Link and CMSIS-DAP. If you have issues, add
"set WORKAREASIZE 0" before sourcing nrf51.cfg to disable it
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000001e msp: 0x20004000
wrote 13312 bytes from file bletest.bin in 0.629010s (20.667 KiB/s)

> exit
Connection closed by foreign host.

 

I connected the OpenOCD to SWD pins as explained here:
https://github.com/RIOT-OS/RIOT/wiki/Board:-yunjia-nrf51822

That’s it!

VSCP: Very Simple Control Protocol

I found about VSCP (www.vscp.org) in the Twitter and just start reading its specification and documentation.

VSCP is a control protocol developed by Åke Hedman since 2000, then it is about 15 years old! Many people are using it for home automation: http://www.vscp.org/wiki/doku.php/who_why_where/the_vscp_team.

The source code is released as GPL/LGPL but has some modified clauses that let users to use it in a “non-viral” mode. You just need to release the modifications you did (if you did it) in the VSCP code. This is similar to FreeRTOS GPL license in this sense.

It is a surprise to know that 8devices USB2CAN dongle has a VSCP driver:
http://www.8devices.com/usb2can

The 8Devices owner is a nice guy, even the USB2CAN schematic is released:
http://www.8devices.com/media/files/usb2can.pdf

Novo site sobre eletronica e arduino

Há alguns dias o Augusto Campos do BR-Linux lançou um novo site para documentar suas experiências durante seu aprendizado de eletrônica e arduino. Seu novo site se chama BR-Arduino.org.

Neste curto espaço de tempo o Augusto já publicou vários posts interessantes sobre o tema. Leitura recomendada a todos que queiram aprender sobre Arduino.

Boa sorte Augusto e parabéns pela iniciativa!

Como projetar placa no KiCAD para facilitar a montagem em empresa externa

Você já viu aqui algumas dicas de como preparar seu projeto para fabricar a PCB.

Felizmente seu projeto deu certo e o cliente pediu milhares de placas! “Ôh, e agora? Quem poderá montar minhas placas?” Existem várias empresas que podem montar os componentes na sua placa, mas será que você desenhou sua placa pensando nos detalhes para montagem numa empresa externa?

Neste artigo você encontrará várias dicas de como preparar seu projeto pensando na montagem externa:
http://rheingoldheavy.com/design-assembly-kicad/