Skip to content

Margus Roo –

If you're inventing and pioneering, you have to be willing to be misunderstood for long periods of time

  • Cloudbreak Autoscale fix
  • Endast

Category: Linux

Basys2 with external clock

Posted on October 24, 2016 - October 24, 2016 by margusja

Recently discovered that internal build in clock is quite unstable. Making a simple stopper was quite unsharp.

Added external clock (25Mz) and the picture is much better.

20161023_115610

Posted in LinuxTagged FPGA

(Arduino -> Atmega328P) + RTC + MCP23008 + LCD = kell

Posted on January 26, 2016 - February 9, 2016 by margusja

Tuli tahtmine kella ehitada.

Vanast ajast oli olemas LCD 16X4, RTC ja arduino R3

Ullult olin soetanud LCD expanderi – https://taaralabs.eu/lcd-plug/

RTC annab kella võimaluse. Kui toide välja võtta, siis kenasti tiksub edasi ja hoiab kellaaega õigena.

MCP23008 – annab vabaks hulga arduinio porte, vastasel juhul poleks ilmselt RTC ka kuhugi panna.

Hetkel selline laiali prototüüp, kes teab kas see kuhugi kaugemale jõuabki.

2016-01-26 22.09.30

Koodiosa tuleb kõvasti tuunida, hetkel suht häbi selle osa üle.

Näiteks on nädalapäev ühe päeva võrra nihkes.

Esimene versioon tõesti halba koodi – https://github.com/margusja/ArduinoRTC

 

Osa2

Kuna kogu arduino plaati ühe kella alla matta on minu jaoks liigne luksus, siis otsustasin selle osa eraldi Atmega328P kätte anda. Alguses oli plaan ilma välise kellata, aga hetkel on siis välise 16MH kellaga.

Ühendasin ISP atmega328P’ga:

icsp_hookup

Allikas: http://upvector.com/atmega/

 

Minul sai selline asi. Programmaator on mul avrispmkII

2016-01-28 21.55.22

Ja oh seda õnne:

margusja@IRack:~/Documents/Arduino/hardware/breadboard/avr$ avrdude -c avrispmkII -v -p ATMEGA328P -P usb

avrdude: Version 5.11.1, compiled on Feb 12 2013 at 01:24:54
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is “/usr/local/CrossPack-AVR-20130212/etc/avrdude.conf”
User configuration file is “/Users/margusja/.avrduderc”
User configuration file does not exist or is not a regular file, skipping

Using Port : usb
Using Programmer : avrispmkII
avrdude: usbdev_open(): Found AVRISP mkII, serno: 000200133546
AVR Part : ATMEGA328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
———– —- —– —– —- —— —— —- —— —– —– ———
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : STK500V2
Description : Atmel AVR ISP mkII
Programmer Model: AVRISP mkII
Hardware Version: 1
Firmware Version Master : 1.23
Vtarget : 5.1 V
SCK period : 8.00 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e950f
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DE
avrdude: safemode: efuse reads as 5

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DE
avrdude: safemode: efuse reads as 5
avrdude: safemode: Fuses OK

avrdude done. Thank you.

Part 3

Peale juhtmete ümbertõstmist ja uue kivi programmeerimist on pilt ikka segane, aga arduino sai vahelt minema.

2016-01-29 20.00.32

 

Kuna on plaanis kivil lock bitte ja fuses muuta, siis tundub, et siinkohal on ka õige praegused setingud maha kirjutada

avrdude -c avrispmkII -v -p ATMEGA328P -P usb -U lfuse:r:-:h -U hfuse:r:-:h -U efuse:r:-:h

Reading | ################################################## | 100% 0.00s

avrdude: writing output file “<stdout>”
0xff
avrdude: reading hfuse memory:

Reading | ################################################## | 100% 0.00s

avrdude: writing output file “<stdout>”
0xda
avrdude: reading efuse memory:

Reading | ################################################## | 100% 0.00s

avrdude: writing output file “<stdout>”
0x5

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DA
avrdude: safemode: efuse reads as 5
avrdude: safemode: Fuses OK

Ja ega ma neid peast ei arvuta – http://www.engbedded.com/fusecalc/

 

Part 4.5 – Asja lihtsustamiseks võtsin kasutusele sisemise kella (avrdude: safemode: lfuse reads as C2).

Nüüd on prototüüp võimalikult lihtne.

Posted in Elektroonika, Linux

bash shortcuts

Posted on November 25, 2015 by margusja

No ei jää meelde. Seega endale siia väike spikker.

Moving the cursor:

  Ctrl + a   Go to the beginning of the line (Home)
  Ctrl + e   Go to the End of the line (End)
  Ctrl + p   Previous command (Up arrow)
  Ctrl + n   Next command (Down arrow)
   Alt + b   Back (left) one word      or use Option+Right-Arrow
   Alt + f   Forward (right) one word  or use Option+Left-Arrow
  Ctrl + f   Forward one character
  Ctrl + b   Backward one character
  Ctrl + xx  Toggle between the start of line and current cursor position

Editing:

 Ctrl + L   Clear the Screen, similar to the clear command

  Alt + Del Delete the Word before the cursor.
  Alt + d   Delete the Word after the cursor.
 Ctrl + d   Delete character under the cursor
 Ctrl + h   Delete character before the cursor (backspace)

 Ctrl + w   Cut the Word before the cursor to the clipboard.
 Ctrl + k   Cut the Line after the cursor to the clipboard.
 Ctrl + u   Cut/delete the Line before the cursor position.

  Alt + t   Swap current word with previous
 Ctrl + t   Swap the last two characters before the cursor (typo).
 Esc  + t   Swap the last two words before the cursor.

 ctrl + y   Paste the last thing to be cut (yank)
  Alt + u   UPPER capitalize every character from the cursor to the end of the current word.
  Alt + l   Lower the case of every character from the cursor to the end of the current word.
  Alt + c   Capitalize the character under the cursor and move to the end of the word.
  Alt + r   Cancel the changes and put back the line as it was in the history (revert).
 ctrl + _   Undo
 
  TAB       Tab completion for file/directory names

For example, to move to a directory ‘sample1’; Type cd sam ; then press TAB and ENTER.
type just enough characters to uniquely identify the directory you wish to open.

History:

  Ctrl + r   Recall the last command including the specified character(s)
             searches the command history as you type.
             Equivalent to : vim ~/.bash_history. 
  Ctrl + p   Previous command in history (i.e. walk back through the command history)
  Ctrl + n   Next command in history (i.e. walk forward through the command history)
   Alt + .   Use the last word of the previous command
  Ctrl + s   Go back to the next most recent command.
            (beware to not execute it from a terminal because this will also launch its XOFF).
  Ctrl + o   Execute the command found via Ctrl+r or Ctrl+s
  Ctrl + g   Escape from history searching mode

Process control:

 Ctrl + C   Interrupt/Kill whatever you are running (SIGINT)
 Ctrl + l   Clear the screen
 Ctrl + s   Stop output to the screen (for long running verbose commands)
 Ctrl + q   Allow output to the screen (if previously stopped using command above)
 Ctrl + D   Send an EOF marker, unless disabled by an option, this will close the current shell (EXIT)
 Ctrl + Z   Send the signal SIGTSTP to the current task, which suspends it.
            To return to it later enter fg 'process name' (foreground).
Posted in Linux

Closures

Posted on September 10, 2015 - September 10, 2015 by margusja

Closures paradigm is amazing. It is supported mainly from functional languages.

Let’s make an example.

function first(x) {

function second(y) {

return x + y

}

return second(y)

}

So calling first(10) we will get return function(y) { return 10 + y}

in example:

add_10 = first(10)

add_10(2) returns 12

Posted in Linux

K-means find clusters

Posted on August 18, 2015 by margusja

Initial set of two dimensional data and k=3. Set initial centroids randomly.

Screen Shot 2015-08-18 at 14.30.35

 

Find instances to closest centroids

Screen Shot 2015-08-18 at 14.31.33

Calculate new positions for centroids

Screen Shot 2015-08-18 at 14.35.33

Find again closest instances to centroids

Screen Shot 2015-08-18 at 14.36.42

Calculate again new position of centroids

Screen Shot 2015-08-18 at 14.38.49

Find again closest instances to centroids

Screen Shot 2015-08-18 at 14.40.09

Posted in Linux

In a group of 365 people it is very unlikely that everyone has a different birthdate

Posted on August 12, 2015 by margusja

In a group of 365 people it is very unlikely that everyone has a different birthdate. The probability is 365!/365365 ? 1.454955 × 10?157 ? 0, i.e., incredibly small

Posted in Linux

Confusion matrix for two classes and some performance measures for classifiers

Posted on August 12, 2015 by margusja

Screen Shot 2015-08-12 at 13.07.02

Posted in Linux

List of active ports in MacOsX

Posted on July 1, 2015 by margusja

margusja@IRack:~$ sudo lsof -i -n -P | grep TCP

Posted in Linux, Mac

Advantages of XMPP

Posted on April 2, 2015 - April 2, 2015 by margusja

Choosing IoT protocol it is important to make right choice. I found good table that helped me from

http://claysterworld.tumblr.com/

Just click to the picture to have bigger and clear view.

Screenshot 2015-04-02 10.18.59

Posted in LinuxTagged IoT

Linear regression with one variable and gradient descent with python

Posted on April 1, 2015 - April 1, 2015 by margusja

Linear regression with one independent variable is easy. It is easy to us for humans. But how machine knows what is the best line thru points? Math helps again!

In example lets take very trivial dataset in python:

points = [ [1,1], [2,2], [3,3], [4,4], [5,5], [6,6], [7,7], [8,8], [9,9]  ]

And some lines of python code

a_old = 34 # random initial value
a_new = -2 # random initial value
b_old = 34 # random initial value
b_new = 3 # random initial value
learningRate = 0.01 # step size
precision = 0.00001
while abs((a_new – a_old)-(b_new – b_old) ) > precision:
    ret = stepGradient(b_new, a_new, points, learningRate)
    a_old = a_new
    b_new = ret[0]
    b_old = b_new
    a_new = ret[1]
    print ret[0]
    print ret[1]
    print “—-“

And  stepGradient code is behind gradient descent formula

Screenshot 2015-04-01 15.32.31

def stepGradient(b_current, a_current, points, learningRate):
    b_gradient = 0
    a_gradient = 0
    N = float(len(points))
    for i in range(0, len(points)):
       b_gradient += -(2/N) * (points[i][0] – ((a_current*points[i][1]) + b_current)) 
       a_gradient += -(2/N) * points[i][1] * (points[i][0] – ((a_current * points[i][1]) + b_current))
    new_b = b_current – (learningRate * b_gradient)
    new_a = a_current – (learningRate * a_gradient)
    return [new_b, new_a]

After running our code, at least in my computer the last two rows are:

0.0152521614476
0.997576043517

So the first one is basically 0 and the last one in 1 – pretty perfect in our case.

 

Posted in Linux, Math

Posts navigation

Older posts
Newer posts

The Master

Categories

  • Apache
  • Apple
  • Assembler
  • Audi
  • BigData
  • BMW
  • C
  • Elektroonika
  • Fun
  • Hadoop
  • help
  • Infotehnoloogia koolis
  • IOT
  • IT
  • IT eetilised
  • Java
  • Langevarjundus
  • Lapsed
  • lastekodu
  • Linux
  • M-401
  • Mac
  • Machine Learning
  • Matemaatika
  • Math
  • MSP430
  • Muusika
  • neo4j
  • openCL
  • Õpetaja identiteet ja tegevusvõimekus
  • oracle
  • PHP
  • PostgreSql
  • ProM
  • R
  • Turvalisus
  • Varia
  • Windows
Proudly powered by WordPress | Theme: micro, developed by DevriX.