Latest Updates

Uploading Bootlaoder to Arduino using USBASP Programmer

August 05, 2017
If you are building your own Arduino, or need to replace the microcontroller of your arduino board you have to burn bootloader before using your chip with Arduino IDE.
Atmel AVRs are great little ICs, but they can be a bit tricky to program. You need a special programmer and some fancy .hex files, and its not very beginner friendly. The Arduino has largely done away with these issues. They’ve put a .hex file on their AVR chips that allows you to program the board over the serial port, meaning all you need to program your Arduino is a USB cable.
The bootloader is basically a .hex file that runs when you turn on the board. It is very similar to the BIOS that runs on your PC. It does two things. First, it looks around to see if the computer is trying to program it. If it is, it grabs the program from the computer and uploads it into the ICs memory (in a specific location so as not to overwrite the bootloader). That is why when you try to upload code, the Arduino IDE resets the chip. This basically turns the IC off and back on again so the bootloader can start running again. If the computer isn’t trying to upload code, it tells the chip to run the code that’s already stored in memory. Once it locates and runs your program, the Arduino continuously loops through the program and does so as long as the board has power.

Requirement:

1. USBASP Programmer.
2. Any Arduino board.
3. Arduino IDE installed in your PC.

Hardware Setup:



Uploading Bootloader:

Fix your new microcontroller (Atmega 328 for Arduino UNO) in your Arduino Board. Open ArduinoIDE.
Select your Board:Arduino UNO in this case.You can upload Bootloader in all type of Arduino board using USBASP programmer.


Select Programmer:


Start uploading by clicking on Burn Bootloader.

Arduino is ready to use.

Electron Draggable Window | Ebots

July 03, 2017


Today we make Electron window menu bar and make it draggable..

Make menu bar

Find out  index.html and edit it.  add some style code.

final out put will be




<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
<link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet'>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
border: 1px solid #e7e7e7;
background-color: #f3f3f3;
-ms-overflow-style: scrollbar;
-webkit-app-region:drag;
}

li {
float: left;
font-size: 16px;
}

li a {
display: block;
color: #666;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}

li a:hover:not(.active) {
background-color: #ddd;
}

li a.active {
color: white;
background-color: #4CAF50;
}
</style>

</head>

<style>
body {
font-family: 'Roboto';font-size: 48px; font-weight: 300;
background-color: #2B2E3B; margin: 0; padding: 0;
color: #C1F4FE;
}
#svg{
margin: 200px 0 0 0;
}
</style>

<body align="center">

<ul>
<li><a href="#home">Home</a></li>

</ul>


<div id="svg"> <img src="electron.svg" alt="electron"> </div>
<p>Draggable Window</p>

</body>
</html>



here in the ui style code



-ms-overflow-style: scrollbar;
-webkit-app-region:drag;


 is used to enable dragging. Drag is enable only for menu bar.

output screen will be like




code used in this can be download here .






Electron frameless window | Ebots

July 03, 2017


Today we make Electron window frameless. In this window body parts like toolbars are not present.

Frame:false


Find out the text in index.js 



win = new BrowserWindow({ width: 800, height: 600,frame: true,})



replace with 


win = new BrowserWindow({ width: 800, height: 600,frame: false,})




then run the electron app, you may have a window like this.



titleBarStyle Hidden

This is the macOS only alternative. It removes the titlebar but leaves the stop light buttons.


win = new BrowserWindow({ width: 800, height: 600,titleBarStyle: 'hidden',})







Download the code here.

Electron hello world app | Ebots

June 29, 2017


Electron is a framework for building desktop apps with CSS, Javascript and HTML.
Here is a five minute guide line to start with electron.

Video introduction

 


1. Installing Node.js

Install node.js. Download and install it.
2. Install electron
Open command terminal (cmd.exe for windows)
change the directory to your app folder.
enter the command









npm install electron --save-dev

3. File structure

Electron app is structured like this.


Hello_world/
├── package.json
├── index.js
└── index.html

Create a folder named "Hello_world" or any as your wish.


4. package.json

Inside the folder create a file named "package.json" 

{
  "name"    : "Hello_world",
  "version" : "0.1.0",
  "main"    : "index.js"
}


5. index.js

Inside the folder create a file named "index.js"  








const {app, BrowserWindow} = require('electron')
const path = require('path')
const url = require('url')

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win

function createWindow () {
// Create the browser window.
win = new BrowserWindow({ width: 800, height: 600, frame: true, })

// and load the index.html of the app.
win.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}))



// Emitted when the window is closed.
win.on('closed', () => {
win = null
})
}

app.on('ready', createWindow)

// Quit when all windows are closed.
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})

app.on('activate', () => {
if (win === null) {
createWindow()
}
})



























































































6. index.html

Inside the folder create a file named "index.js"  








<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
<link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet'>
</head>
<style>
body {
font-family: 'Roboto';font-size: 48px; font-weight: 300;
background-color: #2B2E3B; margin: 0; padding: 0;
color: #C1F4FE;
}
#svg{
margin: 200px 0 0 0;
}
</style>
<body align="center">
<div id="svg"> <img src="electron.svg" alt="electron"> </div>
<p>Hello World!</p>
</body>
</html>


























































































place the electron logo in the  folder.


7. Run Electron hello world app
Now let’s get back to the electron . command. run 









electron .





You have a window like this:


Now make your own app. You can get all the code I used here.




Plot 2d graph in c++

November 26, 2016

Source Code:


#include<stdio.h>
#include<math.h>
#include<conio.h>
#include<graphics.h>
int itr = 0,fn,fc;
float i,j,jp;
float xl,xu,x,xo=0,e;
float f(float );
void cdraw(float );
void pdraw(float );
void gplot(void );
int braketing(void);
void xr(void);
float err(void);


float f(float x)
{
    switch(fn)
    {
        case 1:return (pow(x,10)-1);
        break;
        case 2:return (2*log10(x)-1);
        break;
        case 3:return (exp(-x)-x);
        break;
        case 4:return (log(x)-1);
        break;
        case 5:return (sin(2*x));
        break;
    }
}
void pdraw(float a)
{
    i=300+a*100;
    jp=f(a);
    j=300-jp*100;
    setcolor(2);
    circle(i, j, 3);
    putpixel(i,j,4);
}
void cdraw(float a)
{
    i=300+a*100;
    jp=f(a);
    j=300-jp*100;
    putpixel(i,j,4);
}
void gplot(void )
{
    float d;

   for(d=-5;d<7;d=d+.001)
    cdraw(d);
}

int main()
{
    float x,d;
   // while(fn!=6)
    {
        printf("1.Power: X^10-1\n2.Log: 2logX-1\n3.Exp: e^-x-X\n4.ln: ln(X)-1\n5.Sin: Sin(X)-1\n6.Exit\nEnter your choice:\n");
        scanf("%d",&fn);
       //fn=3;
        int gdriver =DETECT, gmode;
        initgraph(&gdriver,&gmode,"c:\\TC\\BGI");
        line(20,300,800,300)  ;
        line(300,0,300,600)  ;
        gplot();
    }


       getch();
    //  return 0;
}


Output:






Graphics on codeblocks | Ebots

November 07, 2016


Download the library



1.copy graphics.h & winbgim.h file to C:\Program Files (x86)\CodeBlocks\MinGW\include\

2. copy libbgi.a  to C:\Program Files (x86)\CodeBlocks\MinGW\lib
3. open codeblock
4. settings>compiler>linker setting>add    libbgi.a
5. paste the text to other linker option

Matlab : Flat top sampling using matlab

November 07, 2016



clear all;
close all;

p=0.001:.001:1;

o=ones(1,length(p));
z=zeros(1,length(p));

m=repmat([z o z o z o z o z o z o z o z o z o z o],[1,4]);

t=0.001:.001:length(m)/1000;

    y=.5*sin(t/10);
     

    x=y.*m;

    y1=x;
for i = 2:length(t)
    if m(i) == 1 && m(i-1) == 0 %if the rising edge is detected
        y1(i) = m(i) * y(i);    %sampling occurs
    elseif m(i) == 1 && m(i-1) == 1 %and while the carrier signal is 1
        y1(i) = y1(i-1);              %the value of y1 remains constant
    else
        y1(i) = 0;                %otherwise, y is zero
    end
end
 
   
subplot(3,1,1);
plot(t,y);

subplot(3,1,2);
plot(t,x);

subplot(3,1,3);
plot(t,y1);

Matlab : Gibbs phenomenon of given harmonics

November 05, 2016
Gibbs phenomenon of given harmonics

Code:


clc;
clear all;
close all;


t=linspace(-2,2,2000);
u=linspace(-2,2,2000);
sq=[zeros(1,500),2*ones(1,1000),zeros(1,500)];
k=2;
prompt='Enter Harmonics No: ';
N =input(prompt);
%N=[5];
for n=1:1;
an=[];
for  m=1:N(n)
    an=[an,2*k*sin(m*pi/2)/(m*pi)];
end;
fN=k/2;
for m=1:N(n)
    fN=fN+an(m)*cos(m*pi*t/2);
end;
nq=int2str(N(n));
plot(u,sq,'r','LineWidth',2);hold on;
plot(t,fN,'LineWidth',2); hold off; axis([-2 2 -0.5 2.5]);grid;
xlabel('Time'), ylabel('y_N(t)');title(['N= ',nq]);
end;


Output: 




Matlab : 2 | Input number

November 05, 2016



Take number input by this code


prompt='Enter your name: ';
N =input(prompt)





Matlab : 1 | Add two number

November 05, 2016



Open Matlab>New Script>


paste this code

a=12;
b=34;
c=a+b



Run/Press F5

An Overview of the 555 Timer

August 17, 2016
555, The low cost timer IC that widely used as commercial timer ic. 555 is also popular to the students, electronics hobbyists for its simple interface and cheap rate. 

Here the 555 timer & its pin out,

555
internal diagram of 555


Pins:

  1. Ground : Connected to the 0V.
  2. Trigger : Detects 1/3 of rail voltage to make output HIGH
  3. Output : Result output
  4. Reset: To reset must be taken under .8V
  5. Control :To vary timing of RC network
  6. Threshold : Detects 2/3 of rail voltage to make output LOW
  7. Discharge : Discharge
  8. VCC : Connected to the supply

 
Copyright © Ebots.