Switch Based on Contact (SPST, SPDT, DPST, DPDT)

by : Antonius (@sw0rdm4n)
http://www.ringlayer.net

Understanding switch types is very important when developing an electronic circuit. Below is just several example of switches (not a complete list) classified by pole(s) and throw(s).

SPST

spst

SPST stands for single pole single throw.  Pole means how many circuit(s), a switch can control. Throw means how many conducting position for a switch. This one is the basic form of a switch, where this switch has only 2 terminals. When the throw is closed means current can flow, meanwhile when the throw is open, current is break.

In order to understand more, let’s take a look here (sorry for bad drawing skills)

spst_open

 

For example here we have a gate when the gate is open, means the electrical flow is break.

spst_closed

When the gate is closed means current can flow and the lamp is on. Since this only has 1 circuit (the lamp in this case), and only 1 throw (only 1 conducting position that will turn the light on, so this switch is called SPST).

Real life example:

spst2

SPDT

spdt

SPDT stands for single pole double throw. As we can see from the symbol, a single pole double throw switch has 3 terminals.

In order to understand more, let’s take look at below example:

spdt_open

This one is similar to knife switch model, where the condition is open (current can not flow). The throw can be connected whether on right or left terminal.

spdt_closed2

spdt_closed1

Real life example

spdt2

DPST

dpst

DPST stands for double pole single throw.

In order to understand about double pole single throw, take a look on below example.

dpst_open

in dpst , the throw only have one possible conducting, meanwhile it has 2 separate poles.

dpst_closed

When the condition is closed the current can flow to light both 2 circuits. The while lines are any conducting materials.

DPDT

dpdt

DPDT stands for double pole double throw. This one has 2 poles and 2 throws. This one has 6 terminal(s).

Check out below example:

dpdtx

 

Real life example:

dpdgt

 

 

I hope this guide can be a light for those who wanted to understand more about switching in order to do the “Art of controlling the electron”.

 

Reference:

http://en.wikipedia.org/wiki/Switch

http://www.colehersee.com/home/spst_spdt_dpst_dpdt

Advertisements

H-Bridge Circuit Control Using Arduino and BananaPi

by : Antonius (@sw0rdm4n)
http://www.ringlayer.net

H-bridge is an electronic circuit which allow you to reverse the flow of electron in either direction.
To control a h-bridge circuit here, we’ll be using an arduino mega 2560 and arduino ethernet shield (that suitable for arduino mega 2560 with no electronic hacks). What we’re gonna do here is simply can be explained using below diagram :

scheme

 

The main purpose is to send some command(s) such as : forward / backward / left or right from banana pi to arduino mega. Then arduino mega will receives the command over ethernet and apply the suitable voltage over it’s pin(s) for h-bridge. The h-bridge then will apply suitable load for those 2 motor dc(s).

Communication Between Arduino and Banana PI or Raspberry PI or beagle bone to arduino can be accomplished using several method(s) such as using logic level converter (https://www.sparkfun.com/products/12009) or cape (for beagle bone) or maybe you can use arduino wifi shield and plug some wireless usb adapter to credit card size board. Within this example, we’ll be using ethernet to communicate between arduino and banana pi. Why use ethernet shield ? the programming will be easier, what you need is a knowledge on socket programming.

Hardware Requirements:

– 1 banana pi or raspberry pi or another credit card size board with linux os installed

– 1 arduino mega 2560

– 1 ethernet shield for arduino mega 2560

– 1 half size breadboard

– some jumper wire(s)

– 1 sn75441one or l293dne (h-bridge ic)

– 2 motor dc

Step 1 . Prepare H-Bridge circuit

Before making h-bridge circuit, plug the ethernet shield to arduino mega. So the pin(s) will be plugged on the ethernet shield.

In order to make h-bridge circuit, you can follow these tutorials:

– http://www.instructables.com/id/Duel-Motor-Driver-with-Arduino-using-a-SN754410NE-/

– https://itp.nyu.edu/physcomp/labs/motors-and-transistors/dc-motor-control-using-an-h-bridge/

Here comes the arduino mega 2560 with ethernet shield connected to h-bridge circuit :

IMG_20150512_003504

Step 2. Prepare the code for arduino

Here comes the source code

/* arduino mega 2560 control receive command over ethernet and apply voltage to h-bridge circuit 
source code made by : Antonius (Sw0rdm4n)
*/
#include <SPI.h>
#include <Ethernet.h> 

byte mac[] = { 0xDE, 0xA2, 0xDA, 0x0F, 0x17, 0xD9 }; 
IPAddress ip(10,0,0,3); 
IPAddress gateway(10,0,0,2); 
IPAddress subnet(255,128,0,0); 
EthernetServer server(23); 
boolean alreadyConnected = false;

/* h-bridge code for arduino Modified from http://itp.nyu.edu/physcomp/Labs/DCMotorControl */

int motorkanan_1 = 6;    
int motorkanan_2 = 7;   
int enablePin_1 = 9;   
int enablePin_2 = 8;   
int motorkiri_1 = 5;    
int motorkiri_2 = 4;    
int half_speed = 127;
int slow_sleep = 60;
int full_speed = 255;
int i = 0;
#define fwd 1
#define bwd 2
#define lft 3
#define rht 4
#define stp 5
int last_cmd = 0;

void setup() {
    Ethernet.begin(mac, ip);   
    server.begin(); 
    Serial.begin(9600);
    Serial.println("\nrobot motoric started\n");
    pinMode(motorkanan_1, OUTPUT); 
    pinMode(motorkanan_2, OUTPUT); 
    pinMode(motorkiri_1, OUTPUT); 
    pinMode(motorkiri_2, OUTPUT); 
    digitalWrite(enablePin_1, HIGH); 
    digitalWrite(enablePin_2, HIGH); 
}
void tfwd()
{
      Serial.println("\nmaju\n");
      digitalWrite(motorkanan_1, LOW);  
      digitalWrite(motorkanan_2, HIGH);  
      digitalWrite(motorkiri_1, LOW);   
      digitalWrite(motorkiri_2, HIGH);  
}
void tstop()
{
    Serial.println("stop");

    digitalWrite(motorkanan_1, LOW);  
    digitalWrite(motorkanan_2, LOW);
      
    digitalWrite(motorkiri_1, LOW);  
    digitalWrite(motorkiri_2, LOW);
    delay(1000);
}
void tback()
{
      Serial.println("\nmundur\n");
      digitalWrite(motorkanan_1, HIGH);   //right
      digitalWrite(motorkanan_2, LOW);
      digitalWrite(motorkiri_1, HIGH);   //left 
      digitalWrite(motorkiri_2, LOW);
}
void tleft()
{
      Serial.println("left");
      digitalWrite(motorkanan_1, HIGH);  
      digitalWrite(motorkanan_2, LOW);  
      digitalWrite(motorkiri_1, LOW);  
      digitalWrite(motorkiri_2, HIGH);
      delay(1000);
      tstop(); 
      last_cmd = 0; 
}
void tright()
{
      Serial.println("right");
      digitalWrite(motorkanan_1, LOW);  
      digitalWrite(motorkanan_2, HIGH);  
      digitalWrite(motorkiri_1, HIGH);   
      digitalWrite(motorkiri_2, LOW);
      delay(1000);
      tstop(); 
      last_cmd = 0;
}


void get_ethernet_cmd()
{
    char cmd;
    
    /* modified from arduino ethernet chat server */ 
    EthernetClient client = server.available();
    if (client) {
        if (!alreadyConnected) {
              client.flush();    
              Serial.print("\nReady !\n");
              client.println("motoric ready to receive command !"); 
              alreadyConnected = true;
        }
        if (client.available() > 0) {
               Serial.print("reading from client");
               cmd = client.read();
               Serial.print("\ngot command:");
               Serial.print(cmd);
               switch (cmd) {
                   case 'f':
                   last_cmd = fwd;
                   delay(100);    
                   break;
                   case 'b':
                   last_cmd = bwd;
                   delay(100);      
                   break;
                   case 's':
                   last_cmd = stp;
                   break;
                   case 'l':
                   last_cmd = lft;
                   break;
                   case 'r':
                   last_cmd = rht;               
                   break;
               }
        } 
    } 
}

void net_op()
{
   get_ethernet_cmd();
   if (last_cmd == 0) {
      tstop(); 
   }
   else {
      switch (last_cmd) {
        case fwd:
        tfwd();
        break;
        case bwd:
        tback();
        break;
        case stp:
        tstop();
        break;
        case lft:
        tleft();
        break;
        case rht:
        tright();
        break;
      } 
   } 
  
}
void loop() {
     net_op();
}

Step 3. Plug rj45 to arduino and connect it to banana pi

Once you have done everything correctly, we can control h-bridge circuit using banana pi.
Based on above source, arduino ip address is at 10.0.0.3 where it’s gateway is 10.0.0.2 (our banana pi). From banana pi terminal what to do is simple:
ifconfig eth0 10.0.0.2 netmask 255.128.0.0 up

Now, from banana pi terminal, we can send  some command(s) to make our 2 motor dc(s) move forward, backward, left or right.

From terminal, type :

telnet 10.0.0.3

Then we’ll be connected to arduino mega 2560

In order to make motor dc moves forward, type: f

In order to make motor dc moves backward, type: b

In order to make motor dc moves left, type: l

In order to make motor dc moves right, type: r

In order to make motor dc stop, type: s

 

 

 

 

 

 

Introducing Haxtronic – A Robotic Brain That Can Scan for Wireless Network Around

Introducing Haxtronic – A Robotic Brain for Scanning Wireless Network Around, this robotic brain is powered by kali linux and Banana PI. This robotic brain can be connected to arduino as motoric using various way such as using ethernet, power level shifter, etc.

Actually this robot can use aircrack-ng already. Currently programming for visual functionality for this robot using opencv.

Mathematic Algebras

Algebra is a method to simplify calculation, a method to reunite broken parts, a method to solve puzzles. Algebra skills are very important for an electronic engineer (or maybe for hackers) to solve any circuit problems related to mathematic. Not too much words, below is example of algebra problems and the problem solver:

Algebra Problem 1. simplify :

4a + 3b² – a + 2 = 38

Problem Solving:

4a + 3b² – a + 2 = 38

(4a – a) + 3b² = 38 – 2

3a + 3b² = 36

√3a + 3b = 6

Algebra Problem 2, find y :

5y+50 = 2 (3y + 10 )

Problem solving:

5y+50 = 2 (3y + 10 )

5y+50 = 6y + 20

5y +50 – 20 = 6y

5y + 30 = 6y

30 = 6y – 5y

y = 30

Example problem 3, find value of i:

2 = i + √3

Problem Solving:

2² = i² + 3

4 = i² + 3

i = 1

Example problem 4:

Simplify: 2x + 3(x + 10) = 55

Problem Solving

2x + 3x + 30 = 55

5x = (55-30)

5x = 25

x = 5

 

Basic Trigonemetric for Robotic Mechanical Joints

Trigonemetric is a branch of mathematic which frequently used in robotics where it’s commonly used in inverse kinematics of mechanical leg / joints, forward kinematics, etc. Trigonometric calculates about angles and sides of a triangle. In trigonemetric, there’s ratios for acute angles:

– sin = opposite  /  hypotenuse

– cos = adjacent / hypotenuse

– tan = opposite  / adjacent

– secant = hypotenuse / adjacent

– cosecant = hypotenuse / opposite

– cotangent = adjacent / opposite

For example here we have a triangle:

adjacent-opposite-hypotenuse

it’s known that adjacent’s length is 4 and hypotenuse’s length is 5. Based on phytagoras theorem:

 

pita

So :

4²  + b² = 5²

16 + b² = 25

b = √9 = 3

So we got :

Sin R = b / c = 3 / 5, Cos R = a / c = 4 / 5, Tan R = b/a = 3/4, Secant R = c/a = 5/4, Cosecant R = c  / b =5/3, cotangent R = a/b = 4/3

Trigonometric on Equilateral Triangle

For example here, we have an equilateral triangle:

x

Actually that equilateral triangle can be divide into 2 area, something like this :

x

That equilateral triangle when divided into 2 areas, has each 30 degress for it’s top.

Let’s just give name for each angle on cartesius coordinate as x and y:

x

How to calculate sin x, cos x , tan x, sin y, cos y and tan y ?

Have a check on special table of trigonometry :

spec

Since sin x is 30 degree = 1/2, where sin = opposite  /  hypotenuse, so sin x = b / c, we figure out that b = 1 and c = 2. To find a based on phytagoras theory:

c² = a² + b²

2² = a² + 1²

4 = a² +  1

a = √3

So cos x = adjacent / hypotenuse  = a / c = √3 / 2

tan x = opposite  / adjacent = b / a = 1/√3

The same goes for sin, cos and tan y.

 

Making an Electronic Torch – Schematic, PCB Version and Breadboard Version

by : Antonius (@sw0rdm4n)
http://www,ringlayer.net

Electronic Torch is an unique electronic circuit to learn about how electric flow through each components. Below is the electronic circuit:

torches

Part Lists Based on Above Schematic

– 2 resistor 330 ohm or 320 ohm. (breadboard version can uses up to 3 resistors)

– 3 led

– 3 switch

– 1 Dioda in4001

How this works on PCB Version ?

Below is the electronic circuit logic flow :

– If switch is on,  the current will flow  through:

D1 (since it’s a dioda it will prevent reverse current) ->  switch ->  R1 -> led1 -> led2 -> ground

– If s1 is on,  the current will flow  through:

D1 -> S1 -> R1 -> led1 -> led2 -> ground.

– if s2 is on, the current will flow through:

D1 -> S2 -> R2 -> led 3 -> ground

Solder each component based on above schematic

solder

Note:

– Clean your solder with sponge before soldering

– Before soldering drop some soldering tin on top of your solder

– Don’t use to much soldering tin

And here comes the pcb version of the torch :

torch

Breadboard Version

We can also making breadboard version, vero board version, and so on. Here’s the breadboard version of this electronic torch with 3 resistor (1 resistor 330 ohm and 2 resistor 320 ohm).

bread

To see how this circuit works, you can see this video: