WebsiteSpark

Monday, 15 August 2016

Driving a DC motor using Arduino UNO and L293D driver.

Driving a DC motor using Arduino UNO and L293D driver.

Components required:
1)      Arduino UNO
2)      L293D IC
3)      Breadboard
4)      DC Motor(s)
5)      Connecting wires / jumpers
Connection  

Arduino to L293D to DC Motor.

Pinout diagram of L293D IC












Connectivity

1
Arduino
L293D
Motor
2
D2
1A(2)

3
D3
1B(7)

4
D4
1E(1)

5

M1A
Terminal 1
6

M1B
Terminal 2
7

+VMotor  to External Source

8
GND
GND


Arduino program to control the motor

const int M1A = 2;
const int M1B = 3;
const int M1E = 4;

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(M1A, OUTPUT);
  pinMode(M1B, OUTPUT);
  pinMode(M1E, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  //Enable
  digitalWrite(M1E, HIGH);
    
  // forward
  digitalWrite(M1A, HIGH);
  digitalWrite(M1B, LOW);
  delay(5000);              // wait for 5 seconds

  //Reverse
  digitalWrite(M1A, LOW);
  digitalWrite(M1B, HIGH);
  delay(5000);              // wait for 5 seconds 
 
  }
 

  

Driving DC motor using Raspberry Pi GPIO , L293D driver and Python.

Driving DC motor using Raspberry Pi GPIO , L293D driver and Python.

Driving DC motor using Raspberry Pi GPIO , L293D driver and Python.

Components required:
1)      Raspberry Pi
2)      L293D IC
3)      Breadboard
4)      DC Motor(s)
5)      Connecting wires
6)      Pi Cobbler, not mandatory though I have used in my circuit.

Connection  
Pi GPIO to L293D to DC Motor.

Pinout diagram of L293D IC 




Connectivity
1
RPi
L293D
Motor
2
GPIO23 (16)
1A(2)

3
GPIO24(18)
1B(7)

4
GPIO25(22)
1E(1)

5

M1A
Terminal 1
6

M1B
Terminal 2
7

+VMotor  to External Source

8
GND
GND


Python program to control the motor
import RPi.GPIO as gpio
from time import sleep

gpio.setmode(gpio.BOARD)

Motor1A = 16
Motor1b = 18
Motor1e = 22

gpio.setup(Motor1A, gpio.OUT)
gpio.setup(Motor1b, gpio.OUT)
gpio.setup(Motor1e, gpio.OUT)

gpio.output(Motor1A, gpio.HIGH)
gpio.output(Motor1b, gpio.LOW)
gpio.output(Motor1e, gpio.HIGH)

sleep(5)
# reverse
gpio.output(Motor1b, gpio.HIGH)
gpio.output(Motor1A, gpio.LOW)

sleep(5)

gpio.cleanup()



Saturday, 10 October 2015

Arduino based controlled garden irrigation with submersible pump.


The aim of this application is to keep the garden plants alive, when we are on vacation.
This uses Arduino UNO to control the submersible pump, based on the timings and additional parameters like water level in the tank as a protection to the submersible pump.

Equipment inventory
Submersible Pump
1
Used in small water fountains or aquariums
Arduino UNO
1
The main microcontroller
Single channel Relay
1
To control the current through solenoid
DTH 11
1
Temperature& humidity  measurement
Water level sensors
1
To detect the water level as an additional check for protecting the pump
Power supplies
1.       5V for Arduino
2.       220V for Pump
3.       Optionally 12V for relay

1
1
1

Drip irrigation water feeder tube

Length varies according to the number of plants / pots to be irrigated
Plumbing accessories

To connect the drip irrigation system to main water inlet.

Arduino library
1)      Time Library (http://www.pjrc.com/teensy/td_libs_Time.html)
2)      Time Alarms Library(http://www.pjrc.com/teensy/td_libs_TimeAlarms.html)
3)      DHT11 Library(http://playground.arduino.cc/Main/DHT11Lib)
Connection block diagram


Arduino Code

#include <Time.h>
#include <TimeAlarms.h>
#include <dht.h>


int pin = 10;
int pin2 = 13;
int levelOut = 8;
int levelIn = 9;

dht DHT;
#define dht_dpin A0;

//#define relay 5;
//#define relay 12;

int relay = 5;

void setOn(){
  if(relay == 5) {
    digitalWrite(pin,LOW);
  digitalWrite(pin2,HIGH); 
  }
  else
  digitalWrite(pin,HIGH);
 
  digitalWrite(pin2,LOW); 
 }

void setOff(){
  if(relay == 5) {
    digitalWrite(pin,HIGH);
  digitalWrite(pin2,LOW);
   
  }
  else
  digitalWrite(pin,LOW); 
  digitalWrite(pin2,HIGH);
  }

void setup()
{
  pinMode(pin, OUTPUT);
  pinMode(pin2, OUTPUT);
  pinMode(levelOut, OUTPUT);
  pinMode(levelIn, INPUT);
  //digitalWrite(pin,LOW);
  setOff();
  //digitalWrite(pin2,LOW); // don't want the LED on pin 13 glowing
  Serial.begin(9600);

  setTime(22,37,00,27,9,2015); // set the date time of your Arduino
 
  Alarm.alarmRepeat(6,0,0, EarlyMorning); // 6:00am every day
  Alarm.timerRepeat(60, Hourly);  // timer for every 2 hours  

  Serial.println("");
}

void loop() {
  Alarm.delay(1000); // wait one second between clock display
}

void EarlyMorning(){
  // first thing in the morning open Pump for 2 mins
  Serial.println("Early morning");
  Pump(2);
}

void Pump(int min)
{
  //digitalWrite(pin,HIGH); // Open Pump
  if(ChkLevel()){
  setOn();
  delay(min * 6 * 1000);
  //delay(min * 60 * 1000);
  //digitalWrite(pin,LOW); // shut Pump
  setOff(); 
  }
}

void Hourly()
{
  Serial.println("Hourly");
  // check during daytime only
  if( hour() >= 8 && hour() <= 17 && ChkTemp())
      Pump(1);
}
int relay = 5;

void setOn(){
  if(relay == 5) {
    digitalWrite(pin,LOW);
  digitalWrite(pin2,HIGH); 
  }
  else
  digitalWrite(pin,HIGH);
 
  digitalWrite(pin2,LOW); 
 }

void setOff(){
  if(relay == 5) {
    digitalWrite(pin,HIGH);
  digitalWrite(pin2,LOW);
   
  }
  else
  digitalWrite(pin,LOW); 
  digitalWrite(pin2,HIGH);
  }



bool ChkTemp()
{
  DHT.read11(A0);
  // if temp > 30 and humidity > 75%
  return (DHT.temperature >= 30 || DHT.humidity >= 75   );
}

bool ChkLevel(){
   return true;
  // since we are using water level switch in serial manner
    /*digitalWrite(levelOut,HIGH);
    bool val = digitalRead(levelIn);
  return (val == LOW)    ;*/
}


Sunday, 27 September 2015

Arduino based, Solenoid controlled small garden irrigation

The aim of this application is to keep the garden plants alive, when we are on vacation.

This uses a solenoid valve, controlled by Arduino UNO for feeding the micro irrigation kit.

Equipment inventory
Solenoid valve
1
Electronically controlled water valve
Arduino UNO
1
The main microcontroller
Single channel Relay
1
To control the current through solenoid
Power supplies
            5V for Arduino
             24 V for solenoid
            Optionally 12V for relay

1
1
1

Drip irrigation water feeder tube

Length varies according to the number of plants / pots to be irrigated
Plumbing accessories

To connect the drip irrigation system to main water inlet.

Arduino library
         Time Library (http://www.pjrc.com/teensy/td_libs_Time.html)
         Time Alarms Library(http://www.pjrc.com/teensy/td_libs_TimeAlarms.html)
          DHT11 Library(http://playground.arduino.cc/Main/DHT11Lib)


Connection block diagram

Arduino Code

#include <Time.h>
#include <TimeAlarms.h>
#include <dht.h>


int pin = 10;
dht DHT;
#define dht_dpin A0;

void setup()
{
  pinMode(pin, OUTPUT);
  pinMode(13, OUTPUT);
  digitalWrite(pin,LOW);
  digitalWrite(13,LOW); // don't want the LED on pin 13 glowing
  Serial.begin(9600);

  setTime(22,37,00,27,9,2015); // set the date time of your Arduino
 
  Alarm.alarmRepeat(6,0,0, EarlyMorning); // 6:00am every day
  Alarm.timerRepeat(3600, Hourly);  // timer for every 2 hours  

  Serial.println("");
}

void loop() {
  Alarm.delay(1000); // wait one second between clock display
}

void EarlyMorning(){
  // first thing in the morning open solenoid for 2 mins
  Serial.println("Early morning");
  solenoid(2);
}

void solenoid(int min)
{
  digitalWrite(pin,HIGH); // Open solenoid
  delay(min * 60 * 1000);
  digitalWrite(pin,LOW); // shut solenoid 
}

void Hourly()
{
  Serial.println("Hourly");
  // check during daytime only
  if( hour() >= 8 && hour() <= 17 && ChkTemp())
      solenoid(1);
}


bool ChkTemp()
{
  DHT.read11(A0);
  // if temp > 30 and humidity > 75%
  return (DHT.temperature >= 30 || DHT.humidity >= 75   );
}

Further improvements, to control the solenoid hourly reoccurring function additionally based on moisture level present in the soil rather than just atmospheric temperature and humidity levels.

Monday, 21 July 2014

TSQL SQL Server Auditing setup

/*STEP1 Create server Audit specification*/


USE [master]
GO

CREATE SERVER AUDIT [TestAudit]
TO FILE 
( FILEPATH = N'D:\temp\' /*Specify the folder path here*/
,MAXSIZE = 0 MB
,MAX_ROLLOVER_FILES = 2147483647
,RESERVE_DISK_SPACE = OFF
)
WITH
( QUEUE_DELAY = 1000
,ON_FAILURE = CONTINUE
)
GO


/*STEP 2 Create Database Audit specification*/

USE [MyDB]
GO

CREATE DATABASE AUDIT SPECIFICATION [TestDBAudit] 
FOR SERVER AUDIT [TestAudit]
ADD (DELETE ON OBJECT::[dbo].[MyTbl] BY [db_owner]),  /* Object name is the table name */
ADD (UPDATE ON OBJECT::[dbo].[MyTbl] BY [db_owner]),   /* Object name is the table name */
ADD (INSERT ON OBJECT::[dbo].[MyTbl] BY [db_owner])   /* Object name is the table name */
WITH (STATE = OFF)
GO


/*STEP 3 Enable database Audit*/

USE [MyDB]
GO
Alter DATABASE AUDIT SPECIFICATION [TestDBAudit]
WITH (STATE = ON)
GO


/*STEP 4 Enable Server Audit*/

USE [master]
GO
Alter SERVER AUDIT [TestAudit]
With (STATE = ON)
GO


/*STEP 5 View the audit file */

SELECT * FROM sys.fn_get_audit_file 
(N'D:\temp\<FileName>.sqlaudit',
default,default);
GO

Tuesday, 23 April 2013

Non-Functional requirements NFRs

Non-Functional requirements NFRs

NFRs are vital to an application similar to the functional requirements. Most of the projects undertaken stresses mostly on the functional requirements while ignoring or devoting very less time to NFRs. But off late the software industry has accepted NFRs to be at par with functional requirements and is now being considered upfront during the pre-development (RFP) stages.
A/c ISO 9126, NFRs are classified into 6 main categories namely
1)      Functionality
2)      Reliability
3)      Usability
4)      Efficiency
5)      Maintainability and
6)      Portability

Functionality
Functionality NFR deals with the way the system delivers the functionality or the functional requirements. This is further classified into categories as described below.
A.      Suitability
B.      Accuracy
C.      Interoperability
D.      Compliance
E.       Security

Reliability
Reliability NFR deals with the reliability and recoverability of the system as classified below.
A.      Maturity
B.      Recoverability
C.      Fault Tolerance

Usability
Usability NFR deals with the way user adapts to the system under consideration, classified as below.
A.      Learnability
B.      Understandability
C.      Operability
     Efficiency
This NFR deals with how efficiently the system utilizes the resources, classified as below.
A.      Time Behavior
B.      Resource utilization

Maintainability
This NFR deals with system maintenance and enhancement aspects, classified as below.
A.      Stability
B.      Analyzability
C.      Changeability
D.      Testability

Portability

This NFR comes into place where the system needs to operate in multiple distributed environments, further classified as below.
A.      Install ability
B.      Replace ability
C.      Adaptability
Following are a set of check lists for each of the NFRs categories. This by no means is an exhaustive list. This was developed based on experience and readings.


Functionality

Does the system meets all the functional requirement of the business users ?

How well can this system adapt to unanticipated business changes ?
Security

How critical is this system ?

What is the expected impact of security failure ?

How r security failures identified ?

Was there any security failures in the past ? What was then impact ?

Are there known vulnerabilities ?

How are users trained in security issues ?

Are there any response team to handle security breach ?

Authentication and authorization process ?

Secure communications between the system ?

Intended users for this application ?
Inerrability

Does the system interacts / communicates with other applications ?

Are the technologies used to communicate with other systems based on standards ?

Are the component design consistent and understandable ?

Versioning policy & processes ?

Special prototype requirements ( IPv6) ?
Conceptual integrity

Do people understand the architecture very well ?

What are the architectural styles used / followed in the application ?

Design patterns followed during the design & development of the application ?

Were contradictory decisions made about the architecture ?

Do new requirements fits easily in the architecture or do they need modifications in architecture ?
Build ability

Are enough time , money and resources available to build an architecture baseline for projects ?

Is the architecture too complex ?

Is the architecture sufficiently modular to promote parallel development ?

Are there too many technical risks ?
Reusability

Is this system start of new product line ?

Will /does other system be buli / in place , that matches the characteristics of current system under development ?

Will the components of this system be used in other systems ?

Are there any reusable components already in place , which can be used in this system ?

Are there any existing framework or code assets, which can be reused in this application ?

is there existing technical infrastructure that this application will use ?

will this technical infrastructure build by this application be reused by other application ?

What are the associated cost , risk and benefits of building reusable component ?

What are the policy processes and standards defined for developing any reusable components ?

Reliability (General)

What is the impact of failure of this system on business?

How is bad performance impacted on business?

What is the impact of unreliable system on business?

Can the integrity of data be compromises?
Availability

What is the impact of failure of this system?

What are the different failures classified as?

How r hardware & software failures identified?

How quick must the system be operational after a failure?

How are failures identified?

Are there any redundant system that can cover in case of failure ?

How do we know that all the critical functions are replicated ?

Are the system backup done ?

What are the different kinds of backup ?

How long does it take to backup and restore the system ?

What are the expected operational hours ?

What is the expected up time (month / Year) any specific season ?

How is the availability of current system ?

Is the availability of current system within the accepted range ?


Usability

Is the user interface understandable (self-explanatory) ?

Is the UI adaptable to support people with disability ?

Does the developer find the tools used in developing this application usable & understandable ?

Do we need special development skills for this application ?


Performance (Efficiency)

What are the expected response time for each use case ?

What are the average / Min and Max expected response time ?

What resources are being used (CPU,RAM,HD) ?

What is the resource consumption ?

What is the resource arbitration policy ?

What is the expected number of concurrent session (Users) ?

Any long computation in the application ?

Any long wait period under any use case / state ?

Are the server processes single or multithreaded ?

Is there sufficient network bandwidth for all the participating node on the network ?

Are there multiple threads accessing any shared resource ? How ?

Will bad performance effect usability ?

is the response time synchronous or asynchronous ?

What is the expected batch processing time ?

performance variation based on time of day / month/year/ events ?

What is the expected growth of system load ?

Maintainability
Changeability

How often changes requested for this system ?

What are the anticipated new functionalities ?

How are new releases handled for current platform ?

Global components and variables ?

Does the application use any indirect mechanism ( async calls) like publish subscribe ?

how are changes in message formats handled ?

Were design compromised for performance / security / others ?

Does the change in functionality result in changes in interfaces (framework) ? If yes then how often ?

Does the software involve any configuration ?

is the UI independent of business logic ( can UI change without business logic changes or business requirement change without change in UI) ?

Impact of changes in data model ?

Is the system prepared for multi-processor environment ?

Is the system prepared for multi user (sharing on single server ) environment ?

How long does it take to implement business requirement changes ?

Who does the changes ?
Testability

Are there tools, techniques, processes in place to test the code, classes, components and services of this application ?

Are there hooks in framework to perform Unit Tests ?

Can the tests be automated or are there automated test scripts ?

Can the system run in a debug mode ?

Is there any mechanism to capture debug information (logs etc) ?
Subset ability

Is the system modular ?

Are there many dependencies between the modules ?

Does a change in one module propagate changes in other modules ?

Portability

Do the benefit of proprietary platform outweigh the drawbacks ?

Can the expense of creating a separation layer be justified ?

At what level should the system portability be provided (UI/BL/DAO/DB) ?