Labels

Sunday, May 3, 2020

Sorting a Crystal Reports Cross-Tab: A Step-by-Step Guide

In Specified Order (Crystal Report Cross tab)


Learn how to precisely control the order of your Cross-Tab groups with the "In Specified Order" sorting option.

Introduction 

Using this option, you can sort your Cross-Tab's rows and columns. Specifically, the "In Specified Order" option is helpful for sorting data that cannot be sorted in the regular alphabetical or numerical way.

For a real-world example, let's consider a scenario where we want to sort a Cross-Tab by month name. Here's how to do it.

1. To begin, right-click on the Cross-Tab in your report. From the menu that appears, click                  "Cross-Tab Expert..."
Select Cross-Tab Exprert


2. Below the column and row sections, you will find the "Group Options" button. Select the              column or row field that you need to sort in a specific order, and then click this button.
Group Option


3.  Select Common tab and Select In Specified Order from drop down.
In specified order.


4.  Next, select the "Specified Order" tab and click the "New" button to add an item to your custom sort order.

You will then enter the Group Name and select a condition, followed by its corresponding value. For our scenario, you would enter January as the Group Name, select the "is equal to" condition, and enter January as the value.

You will need to repeat this process for all the months of the year to create your desired sort order.
User define order

Wednesday, April 29, 2020

The Ultimate Guide to PIR Sensors

PIR Motion Sensor ( DYP-ME001)


PIR Sensor

An Introduction to PIR Motion Sensor

PIR sensors are primarily used to detect motion, and they are especially popular for sensing human movement. These small, low-power, and inexpensive sensors are staples in security and automation projects.

While most commonly referred to as PIR (Passive Infrared) sensors, they are also known as Pyroelectric or IR Motion sensors. At their core, a PIR sensor works by capturing infrared radiation.

There are many types of PIR sensor modules available, such as the HC-SR501 and the DYP-ME001. In this guide, we'll focus on the DYP-ME001 sensor module and how to use it with an Arduino. (Note that these sensors can also be used without a microcontroller.)

DYP-ME001


Specification Of  DYP-ME001

Input Voltage - DC 4.5 - 20V
Static Current - 500uA
Block Time - 2.5s
Delay Time - 5s
Sentry Angle < 110
Sentry Range -3m to 7m

The Science Behind Detecting Heat and Motion

When a heat source (like a human or animal) passes through the sensor's field of view, it first intercepts one of the two sensitive slots. This creates a positive differential change between the two slots.

When the warm body leaves the sensing area, the reverse happens, and the PIR sensor generates a negative differential change. The sensor's circuitry detects these changes, which is how it recognizes motion.


PIR Setting

Trigger Mode Jumper

The DYP-ME001 sensor module does not have a configurable jumper setting, so it is connected to the 'H' (High) position by default. In contrast, other PIR sensors like the HC-SR501 allow you to change the jumper settings.

L position

When a warm body moves in front of the sensor, it will trigger an output signal.

The behavior of this signal depends on the mode the sensor is configured for:

Non-Retriggering (Single Trigger) Mode: In this mode, the sensor triggers once when motion is first detected. It will then remain 'ON' for a pre-set duration and will not re-trigger, even if motion is still present. This means that after the initial trigger, the output will turn 'OFF' after its set time has expired and will not turn on again until a new motion event is detected.

Retriggering Mode (Commonly set as 'H' on HC-SR501): This is the more common mode. As long as motion is continuously detected, the sensor's output will stay 'ON'. The timer will reset every time motion is detected, ensuring the signal remains active. The output only turns 'OFF' after motion has ceased for the duration of the pre-set time.

H position

Sensor will turn on entire time that something is moving. So we call this as retriggering or repeatable trigger mode.

Sensitivity and Time Adjustment

Sensitivity

According to PIR motion sensor (DYP-ME001) specification adjustable range is from 3m to 7m. Here is way adjust.

Clockwise or Right side -- decrease sensitivity, so it fully right and range will be approximately 3m.

Counter Clockwise or Left side --increase sensitivity , so it fully right and range will be   approximately 7m.

Time Adjustment

This adjustment  determined how long of  PIR sensor will remain high after motion detected.

Clockwise or Right side -- Increase  delay,So it fully right and delay will be approximately 5 second.

Counter Clockwise or Left side -- decrease delay , So it fully left and delay will be approximately 3 second


Code Sample 

int motion_in =2;
int led_out=3; 

void setup() {
pinMode(motion_in ,INPUT);
pinMode(led_out,OUTPUT);    }

void loop() {
  // put your main code here, to run repeatedly:
 
int pir_read = digitalRead(motion_in);
if(pir_read==1)

  digitalWrite(led_out ,HIGH);
  delay(1000);
}
else
{
    digitalWrite(led_out,LOW);
    delay(300);
}}




Wednesday, July 26, 2017

Livit Fitness Band

  



I bought Dialog LIVIT Fitness Band couple of week ago. So, I would like to share my experience it. LIVIT is low price fitness band. So I bought this fitness band for 1745 LKR (Discounted Price). I think it good for that price. However, LIVIT doesn't have heartbeat sensor.

 Features

  1. All day activity tracking (steps,distance,calories burned,active minits,hourly activity).
  2. Notification and calender alerts - (Call,text,facebook,Twitter,WhatApps,skype,Gmail).
  3. Reminder to move (encorage you to take steps every hour).
  4. Auto Sleep Traking (how long well you sleep).
  5. Sync Wirless (Bluetooth 4.0 with Android and Apple devices).
  6. USB Charge.
  7. Easy Touch and Gesture Control (High sensitivity  touch screen).

Support

 IOS : 4S/ 5/ 5S/ 5C/ IPad 3 IOS 8.0 above.
 Android : Android 4.4 above

Friday, July 21, 2017

SQL Server Database Mail Configuration

SQL Server Mail Configuration


I'm going explain, how to config SQL Server Mail Service step by step

Step 01

Log in to SQL Server , Extract Management and Right click on Database Mail. Then select Configure Database Mail.



Step 02

Following window will appear , Then click Next button

 

Step 03

Select  Set Up Database Mail by performing the Tasks and Click Next.



Step 04

 If this feature disable , wizard will ask to enable it. So Enable it. Then below window will appear.
Enter Profile and Description and click ADD button on Right side.



Step 05

 Here we have enter more detail. First enter Account Name and Description. Then enter SMTP mail server configurations .
  1.  email address
  2. Display Name (optional)
  3.  Reply email (optional)
  4.  SMTP Server
  5.  Port Number ex- (25 ,457 ,587) 

Select Basic Authentication under the SMTP Authentication. Then enter mail sending email account's Username and Password and click Add .



Step 06

 Then window will appear. it shows your created profile and click Next.

Step 07

 Then another window will , the Configure System Parameters description is shown.


Step 08

Then Click Next. It will show confirmation about your profile , so click Finish.



Step 09

Now SQL server was configured email service and click close .

Step 10
Run following SQL Query

sp_CONFIGURE 'show advanced', 1
GO
RECONFIGURE
GO
sp_CONFIGURE 'Database Mail XPs', 1
GO
RECONFIGURE
GO

How to test SQL Sever mail

Then again right click on Database Mail and select Send Test Email. Then select Database mail profile and enter receiver mail address ,  mail subject.



How to view Database Mail Log

Right click on the Database mail and select View Database Mail Log
 
  

Wednesday, June 14, 2017

SQL Server - T-SQL Query to find Monday of current week

T-SQL Query to find Monday of current week


We can write simple SQL query to get Monday of current week.

SELECT DATEADD(WK, DATEDIFF(WK,0,GETDATE()), 0)
SELECT DATEADD(WEEK, DATEDIFF(WEEK,0,GETDATE()), 0)


Above two query will return date of Monday in current week ex -2017-06-12 . So if you want to get other days like Tuesday, Wednesdays etc of current week, you can simply change int value in function.

 SELECT DATEADD(WK, DATEDIFF(WK,1,GETDATE()), 1)  -- Tuesday
 SELECT DATEADD(WK, DATEDIFF(WK,2,GETDATE()), 2)  --- Wednesday

Thursday, May 4, 2017

Measuring Distance with Arduino: A Guide to the HC-SR04 Ultrasonic Sensor

HC-SR04 Ultrasonic Sensor




The HC-SR04 sensor uses ultrasonic sound to determine the distance to an object. It can measure distances from 2 cm to 400 cm. Its operation is not affected by sunlight or black surfaces, but temperature and humidity can affect the accuracy of its readings. It also has difficulty detecting soft materials, such as cloth. The HC-SR04 sensor has an ultrasonic receiver and transmitter.

Here, my goal is to help you understand how this sensor works and how to program it with Arduino.

HC-SR04 Ultrasonic sensor Technical Specification

HC-SR04

power supply                  :- 5DC
Quiescent Current           :- 2mA
Working Current               :-15mA
Effect Angle                    :<15 degrees
Distance                           :- 2cm to 400cm
Resolution                        :-0.3cm
Trigger input pulse width :-10us
Ultrasonic Frequency       :-40KHz

Pins


VCC  :- arduino 5v pin
TRIG  :- arduino Digital pin
ECHO :- arduino Digital pin
GND  :- arduino GND pin

The TRIG pin is used to send ultrasonic sound, and the ECHO pin is used to listen.


Example

int triggerPin= 8;
int echoPin= 7;
long pulsDuration =0;
long distanceCM =0;
long distanceINC =0;
void setup() {
  // put your setup code here, to run once:
  pinMode(triggerPin,OUTPUT);
  pinMode(echoPin,INPUT);

  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
   digitalWrite(triggerPin,LOW);
   delayMicroseconds(5);
   digitalWrite(triggerPin,HIGH);
   delayMicroseconds(10);
   digitalWrite(triggerPin,LOW);

  pulsDuration =pulseIn(echoPin,HIGH);

  distanceCM = (pulsDuration/2) / 29.1;
  distanceINC = (pulsDuration/2) / 74; 

   Serial.println("CM");
  Serial.println(distanceCM);

   Serial.println("INCH");
  Serial.println(distanceINC);

  delay(1000);

   Serial.println("**********************************************");
}








Thursday, April 20, 2017

How do i program IR Sensor - Arduino

FC-51 IR Sensor Module


FC-51 IR sensor module is a proximity sensor module. We can identify obstacle in front of sensor. So it has built in IR transmitter and IR receiver. It also has built in potentiometer to adjust distance rage. IR sensor module operate in 2cm-30cm range. FC-51 is compatible with Arduino.



Technical Specification 

1. Operation Voltage - 3.3V - 5V
2. Detection Angle   -35 degrees
3 Active Output level - Outputs Low logic level when obstacle is detected
4.Detection range: 2cm – 30cm (Adjustable using potentiometer)

PIN Out & In

1. VCC - 3.3V-5V DC power input
2. GND -0V Power pin
3. OUT -  Digital Output Pin


Programming 

There are may way to do it. So here i try to use IR sensor with Arduino Uno board. When obstacle is detected by sensor, it will generate LOW output, otherwise output is HIGH.


Example 1 

int irSenRead =7;
int isObstacle = HIGH;
void setup() {

  pinMode(irSenRead ,INPUT);
   Serial.begin(9600);

}

void loop() {

  isObstacle = digitalRead(irSenRead); // // Read IR sensor output
   Serial.println(digitalRead(irSenRead)); // // print the output

  // // isObstacle ==low there is obstacle infront of sensor
  // // using serial monitor we can see this output
  if (isObstacle == LOW) {
    Serial.println("OBSTACLE");
  }
  else
  {
    Serial.println("NO");
  }

  delay(500);
}

Example 2
In below code sample .LED bulb will be on when obstacle detected

int irSenRead =7;
int LED=6;
int isObstacle = HIGH;
int delayRead =100;
void setup() {

  pinMode(irSenRead ,INPUT);
   pinMode(LED ,OUTPUT);
   Serial.begin(9600);

}

void loop() {

  isObstacle = digitalRead(irSenRead);
   Serial.println(digitalRead(irSenRead));

   // isObstacle ==low there is obstacle infront of sensor
  if (isObstacle == LOW) {
    digitalWrite(LED ,HIGH);
  }
  else
  {
    digitalWrite(LED ,LOW);
  }

  delay(delayRead);
}