Friday, 26 May 2017

8051timer0Mode_1(16Bit mode)

Circuit Diagram : 




Source code :

#include <reg52.h>
#include <stdio.h>

sbit LED = P1^0;            // Defining LED pin
static unsigned long overflow_count = 0;
bit flag=0;
void timer0_ISR (void) interrupt 1
{
  overflow_count++;   /* Increment the overflow count */

if(overflow_count>=10){    // for 500ms seconds loop
if(flag==1){LED=1;flag=0;}
else if(flag==0){LED=0;flag=1;}
overflow_count=0;
}
TF0=0;    // clear timer interrupt
}


void main (void)
{

TMOD=0x01;
TL0=0xFD;
TH0=0x4B;                     // load Calculated value for 50ms delay
ET0 = 1;                      /* Enable Timer 0 Interrupts */
TR0 = 1;                      /* Start Timer 0 Running */
EA = 1;                       /* Global Interrupt Enable */

while (1)
  {
  }
}


Simulation Link : https://youtu.be/70hKILTVs1M


Thursday, 25 May 2017

8051 LED Blink With Simulation

Circuit Diagram :





Code: 

#include<reg52.h>           // special function register declarations
                            // for the intended 8051 derivative

sbit LED = P1^0;            // Defining LED pin

void Delay(void);           // Function prototype declaration

void main (void)
{
    while(1)                // infinite loop
    {
        LED = 0;            // LED ON
        Delay();
        LED = 1;            // LED OFF
        Delay();
    }
}

void Delay(void)
{
    int j;
    int i;
    for(i=0;i<10;i++)
    {
        for(j=0;j<10000;j++)
        {
        }
    }

}


Video : https://youtu.be/gbn-Owuf7dk

Friday, 19 May 2017

Ranging and gesture detection sensor

Description 

The VL53L0X is a new generation Time-of-Flight (ToF) laser-ranging module housed in the smallest package on the market today, providing accurate distance measurement whatever the target reflectances unlike conventional technologies. It can measure absolute distances up to 2m, setting a new benchmark in ranging performance levels, opening the door to various new applications.
The VL53L0X integrates a leading-edge SPAD array (Single Photon Avalanche Diodes) and embeds ST’s second generation FlightSenseTM patented technology.
The VL53L0X’s 940nm VCSEL emitter (Vertical Cavity Surface-Emitting Laser), is totally invisible to the human eye, coupled with internal physical infrared filters, it enables longer ranging distance, higher immunity to ambient light and better robustness to cover-glass optical cross-talk.

Applications

1 User detection for Personal Computers/ Laptops/Tablets and IoT (Energy saving).
2  Robotics (obstacle detection).
3 White goods (hand detection in automatic faucets, soap dispensers etc...)
4 1D gesture recognition.
5 Laser assisted Auto-Focus. Enhances and speeds-up camera AF system performance,      especially in difficult scenes (low light levels, low contrast) or fast moving video mode.


Main Code :


#include <Wire.h>
#include <VL53L0X.h>
VL53L0X sensor;
// Uncomment this line to use long range mode. This
// increases the sensitivity of the sensor and extends its
// potential range, but increases the likelihood of getting
// an inaccurate reading because of reflections from objects
// other than the intended target. It works best in dark
// conditions.
//#define LONG_RANGE
// Uncomment ONE of these two lines to get
// - higher speed at the cost of lower accuracy OR
// - higher accuracy at the cost of lower speed
//#define HIGH_SPEED
//#define HIGH_ACCURACY
void setup()
{
  Serial.begin(9600);
  Wire.begin();
  sensor.init();
  sensor.setTimeout(500);
#if defined LONG_RANGE
  // lower the return signal rate limit (default is 0.25 MCPS)
  sensor.setSignalRateLimit(0.1);
  // increase laser pulse periods (defaults are 14 and 10 PCLKs)
  sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodPreRange, 18);
  sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodFinalRange, 14);
#endif
#if defined HIGH_SPEED
  // reduce timing budget to 20 ms (default is about 33 ms)
  sensor.setMeasurementTimingBudget(20000);
#elif defined HIGH_ACCURACY
  // increase timing budget to 200 ms
  sensor.setMeasurementTimingBudget(200000);
#endif
}
void loop()
{
  Serial.print(sensor.readRangeSingleMillimeters());
  if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }
  Serial.println();
}


// Get more details :https://github.com/pololu/vl53l0x-arduino

Thursday, 18 May 2017

SI7050 Temperature Sensor

Description

The Si705x Digital Temperature Sensors offer industry-leading low power
consumption and high accuracy across the entire operating voltage and
temperature range. These monolithic CMOS ICs feature a band-gap
temperature sensor element, an analog-to-digital converter with up to 14-
bit resolution, signal processing, calibration data, and an I2C interface.
The patented use of novel signal processing and analog design enables
the sensors to maintain their accuracy over a wide temperature and
voltage range, while consuming very little current.
The temperature sensors are factory-calibrated and the calibration data is
stored in the on-chip non-volatile memory. This ensures that the sensors
are fully interchangeable, with no recalibration or software changes
required.

Applications

HVAC/R
Thermostats
White goods
Computer equipment
Portable consumer devices
Asset tracking
Cold chain storage
Battery protection
Industrial controls
Medical equipment

Pin Assignments:





Application Circuits:





Application Code :



#include <stdio.h>
#include <stdlib.h>
#include <linux/i2c-dev.h>
#include <sys/ioctl.h>
#include <fcntl.h>
void main()
{
// Create I2C bus
int file;
char *bus = "/dev/i2c-1";
if ((file = open(bus, O_RDWR)) < 0)
{
printf("Failed to open the bus. \n");
exit(1);
}
// Get I2C device, SI7050 I2C address is 0x40(64)
ioctl(file, I2C_SLAVE, 0x40);
// Send temperature measurement command, NO HOLD MASTER(0xF3)
char config[1] = {0xF3};
write(file, config, 1);
sleep(1);
// Read 2 bytes of temperature data
// temp msb, temp lsb
char data[2]={0};
if(read(file, data, 2) != 2)
{
printf("Error : Input/Output error \n");
}
else
{
// Convert the data
float cTemp = (data[0] * 256 + data[1]);
cTemp = (((cTemp * 175.72) / 65536) - 46.85);
float fTemp = cTemp * 1.8 + 32;
// Output data to screen
printf("Temperature in Celsius : %.2f\n", cTemp);
printf("Temperature in Fahrenheit : %.2f\n", fTemp);
}
}


  

ESP8266 Multiple Timer

ESP8266 Maximum upto 7 OS_Timer Source code : #include <Arduino.h> extern "C" { #include "user_interface.h...