September 17, 2014

Smartphone Controlled Home

This post describes a low cost open source home automation system that you can build your self. The goal is to use a smartphone as remote controller for your home. The system is based on the openHAB software and MySensors Arduino library.

Home automation enables you to observe and control your home. You can observe temperature, humidity, energy consumption and so on. It will also let you control your lights, media units, window blinds and other objects in your home. You can also create rules based on senors value, time of day or other conditions that will automatically control your home.


Home Automation System Parts
A standard WiFi router is used to connect the smartphone to your local network. The Server (or Controller) is a computer running openHAB runtime core. This is the heart in the system that keeps track of the system. This can be a Window or Linux computer. A Raspberry Pi will do the job. The Gateway (or Access Point) is an Arduino board running the myControler software. The sensor network is a radio network connecting the sensors and the Gateway.

User Interface
Below is a screenshot of the openHAB smart phone user interface. A web browser can also be used.


Security
The openHAB software with enabled encryption and authentication is fairly secure. But the sensor network has very few security features. Since the range of the sensor are limited it should not be a problem unless you live in a densely populated area. I would not connect it to my door lock or something that could cause damage or fire.

References
MySensors - Arduino library for the sensor radio network.
openHAB - Vendor and technology agnostic open source home automation software.

May 20, 2014

Add Verilog files recursively in Altera Quartus II

This post describes how you add multiple Verilog files recursively to your project in Altera Quartus II. If you are using VHDL you can simply change the file matching from "*.v" to "*.vhd*".

Create a file named "addallv.tcl" in your project folder with the contents listed below. Change "myfolder" to the name of the sub-folder below your project folder that contains the files (or folders with files) you would like to add. Run it in the Tcl Console with:

source addallv.tcl

addall.tcl:

package require ::quartus::project
package require fileutil
#addallv.tcl by http://www.thalin.se

set folderName "myfolder"

foreach file [fileutil::findByPattern $folderName *.v] {
    puts $file
    set_global_assignment -name VERILOG_FILE $file
}

Hints
You have to enable the the Tcl Console by selecting View -> Utility Windows -> Tcl Console.


Run the command by typing it in front of tcl> and press return.




May 16, 2014

8051 on Altera Cyclone IV

The 8051 microcontroller (aka MCS-51 or 80C51) was develop by Intel in 1980. Still over 30 year later its architecture is widely used. In this post am using the lightweight 8051 compatible core ligth52 from Open Cores on the Altera Cyclone IV TB276 board from my previous posts. This implementation runs the core at 75 MHz. It has some precompiled examples. To develop your own code you need the free SDCC C-compiler.You will also need python. I use python xy.

Download the design adopted to TB276 here.

Resource usage:
Logic elements: 1,239 / 6,272 ( 20 % )
Memory bits: 20,480 / 276,480 ( 7 % )
Embedded Multiplier 9-bit elements: 1 / 30 ( 3 % )
Total PLLs: 1 / 2 ( 50 % )

To get the serial port output I used an FTID cable (3.3 Volt version) with the following connections:
Black to GND
Oragen to pin 7
Yellow to pin 10
Others are unconnected.

Press button Key2 on the board to reset the core and start the output on the serial port. I used RealTerm to capture the output. Settings are 19200,8,N,1

8051

May 11, 2014

Example design for TB276 Altera Cyclone IV E FPGA board

This is an example design that defines the clock, led and button pins for the Canton-electronics TB276 board in one of my previous posts. It implements a small demo with the leds and buttons. Download the Verilog source code and project file from here: brd_test.qar. The .qar-file is an archive that can be extracted with Altera Quartus II.

How to build and download to the FPGA

1. Double click the .qar file to open it in Quartus II.

2. Press OK to extract the files and open the project.

3. Double click on Compile Design as illustrated below and wait for the compile to finish. It will take a few seconds.

Make sure that you have connected the power and the programming cable to the board. Make sure that the driver for the cable is installed. See my previous post for driver installation.



5. Hit the download button in the toolbar.

This will open the programmer window.

6. Press Hardware Setup to configure the programming cable.

7. Press Start to program the FPGA. Please note that this will program the FPGA directly and so the configuration is lost if power is cycled.

Here is a video of the result.

April 30, 2014

Ultimaker Cura slicer settings for RepRapPro Huxley

Here is how I configure Ultimaker Cura Slicer software for the RepRapPro Huxley 3D printer. The settings are for Cura 14.03 but will probably work for later versions also. The settings are for 1.75 mm PLA with 0.5 mm nozzle. When launching Cura a wizard will open.  I use these settings for my Huxley:

Step 1. RepaRap
Step 2. W=140,  D=140,  H=110, Nozzle = 0.5, Heated bed=yes, Bed center is (0,0,0) = no

Dowload my Cura profile from here.

In Cura load the file with: File -> Open profile...

I generate gcode files that i put on an SDCARD. I then use Pronterface to start the print.

Below are some screenshots of how is should look after loading the profile file.

Basic:


Advance:


End gcode. I have only changed the circled line:

April 22, 2014

Low cost Altera FPGA board

After using Xilinx FPGAs for many years I decide that it was time to take a look at Altera. I googled for a suitable low cost development board that would work with the free version of the Altera tools. Most boards are quite expensive but there are less expensive alternatives. I found a promising board from a vendor in China called Canton-electronics for only ~$40 this also includes a JTAG cable. I couldn't  resist from buying it. Two weeks later it arrived. My first tests show that the board and the cable works fine. I will post more details when I have tested it more thoroughly.

Hardware
Board: TB276
Download cable: Altera USB Blaster
Bundle with board and cable ~$40 from Canton-electronics.

Board specs
FPGA: Altera Cyclone IV E 4EP4CE6E22C8N
Flash chip: EPCS4, 4Mbit
Onboard oscillator: 25MHz
10 LEDs
2 Buttons

FPGA specs
Device: Altera Cyclone IV E 4EP4CE6E22C8N
Number of logic elements: 6272 LE
Number of IO pins: 92
Embedded memory: 270 Kbits
Embedded Multiplier 9-bit: 30 instances (18-bit: 15 instances)
Embedded PLLs: 2 instances
Serial Transceivers: None

Software
Altera Quartus II Web Edition (free version) download from: www.altera.com

Installing cable drivers
The USB-Blaster driver needs to be manual installed in the device manager. You find them here after installing Quartus II: C:\altera\13.1\quartus\drivers\usb-blaster

Programming the flash
If you want the FPGA to start with your configuration you need to program the EPCS4 flash chip. Here is a guide how to do this: http://retroramblings.net/?p=622