Automatic Room Light

I have been thinking about problem with the Automatic Room Light, which comes on when someone enters into room. And the light should stay light until the person stays in the room. There are many ways to implement this. You are using the pir sensor. I think if you use straight away you will be making a motion detection system which turn on the light as it detects the rise in temperature in its surrounding.

If you want to work with the PIR sensor then it is good for turning on things in the hallway. Where we need light for some time when it detects a moment.

But when you use it in a room (considering living room). Here we start to see a problem that as the people settle down there is a decrease in motion and it can continue like this for a long time.

You can increase the delay if you are using it in a busy lounge for example office lounge. Which can dim the light when the motion is decreased.

But for a living room or a house. You can only use it to start things up. And once they are started you can use other solution to check for the surrounding.

There are number of ways you can use this.

  1. Use the camera with a tracking algorithm to detect the presence of humans.
    {this should detect the outline which is relatively easier than detecting face detection}
  2. Use the rfid tags like we see in hotel room. Place the rfid in a designated area for the power to stay on and is the rfid is removed then the power cuts off.
  3. Use the pressure sensitive device which can detect the change in pressure of the couch.
  4. There is one more option I can think of

Make/buy a thermal imaging device use this to detect the change in temperature of the environment. You can use this thing alone without using the pir sensor. This will work In places where you have a relatively cooler environment like in air-conditioned labs/rooms. But this system is ineffective as the surrounding environment gets closer to the human body temp.

If employed in a hospital environment a passive heart beat monitor will be very helpful.

Wifi signal strength indication using esp8266

This is a fun project. Rather a very simple project. I am using the RSSI level checking of the esp8266 chip to monitor the signal strength of the surrounding wi-fi signals.

There are very few applications that i can think using this.

  1. You can check where the wi-fi signal is strong in a public place and stand near it to enjoy your free wi-fi more comfortably.
  2. location finding using the signal strength. Well as you go near the object the signal will become stronger and hence location finding device.
  3. You can also use some pretty special algorithm and some positioning mathematics to triangulate the relative position of a particular station.

Code:

AT+CWLAP

This is this simple one line of the code that you need to send to the esp8266 and the esp8266 will transmit the message from where you can use string manipulation to gather the information needed.

 

FFT Analysis of 200Khz Square wave

DSO screenshot of 200khz rectangular wave
DSO screenshot of 200khz rectangular wave

Generated 200khz square wave with 50% duty cycle on atmega32.
Code is written in assemble language.

// Created: 9/7/2018 8:24:31 AM
// Author : abhay
.INCLUDE "M32ADEF.INC"
//.MACRO INITSTACK
LDI R16,HIGH(RAMEND)
OUT SPH,R16
LDI R16,LOW(RAMEND)
OUT SPL,R16
//.ENDMACRO
// INITSTACK
LDI R16,0X02
SBI DDRB,1
SBI DDRB,3
LDI R17,0
OUT PORTB,R17
BEGIN: RCALL DELAY
EOR R17,R16
OUT PORTB,R17
// OUT OCR0,128
RJMP BEGIN
DELAY:
LDI R22,200
OUT OCR0,R22
LDI R20,0XF2
OUT TCNT0,R20
LDI R20,0X01
OUT TCCR0,R20
AGAIN:
IN R20,TIFR
SBRS R20,TOV0
RJMP AGAIN
LDI R20,0X00
OUT TCCR0,R20
LDI R20,(1<<TOV0)
OUT TIFR,R20
RET

DSO screenshot of 200khz rectangular wave
DSO screenshot of 200khz rectangular wave
FFT of pulse showing main lobe and one side lobe.

In this fft, it can be clearly seen that the 200khz pulse is represented by a high but we can also see the harmonic of the pulse.

Here are some more fft

Buzzer interfacing with atmega32

ASM Code for buzzer testing
; Created: 9/7/2018 8:24:31 AM
; Author : abhay
;
.INCLUDE "M32ADEF.INC"

.ORG 0
LDI R16,HIGH(RAMEND)
OUT SPH,R16
LDI R16,LOW(RAMEND)
OUT SPL,R16
BACK:
LDI R16,0X01
OUT PORTD,R16
CALL DELAY
LDI R16,0X00
;COM R16
NOP
OUT PORTD,R16
CALL DELAY
call dfor
RJMP BACK
.ORG 0x300
DELAY:
;timing delay
LDI R29,1
L4: LDI R20,10
L1: LDI R21,100
L2: LDI R22,32
L3:
NOP
NOP
DEC R22
BRNE L3
DEC R21
BRNE L2
DEC R20
BRNE L1
DEC R29
BRNE L4
RET
dfor:
;for loop
ldi r30,10
loop: ldi r31,0
call delay
dec r30
brne loop
ret

Calculation for loop timings
crystal frequency = 16Mhz = 16,000,000 Hz
calculate time period of one clock cycle
1/16MHz = 62.5 nano second

clock cycle
NOP – no operation = 1 cycle
DEC – decrement = 1 cycle
BRNE – branch if not equal (basically a for a loop with down counting) = 1/2 cycle

this will be around 5 cycles

for example a delay of 1s
1second = 10^9 nano seconds = 1000,000,000
1000,000,000/(62.5 x 5)=3200,000
3200,00/32=100,000
100,000/100=1000
1000/200=5
5/5=1

so load the register with value
a=32
b=100
c=200
d=5

PAL Composite video timing

India moved to DVB T2 in 2015. I always wanted to make a system which can project images on to the biggest screen i can get my hands on. So here are details.

PAL = Phase Alternate Line

total of 625 lines

Field one + Field two  = 625 lines

each field line consist of

[ vertical sync ] [ horizontal sync + active video ]x n

each scan line if of 64 micro second. (strict constraints don’t play with margins)

each 64 micrsecond line starts with

[Horizontal Sync = 4.7 us] [ color burst = 8us] [active data] [4 us of black level] = 64 us

This scan is done from the composite line of sony playstation 2. So i am taking this as a reference.

help is taken from here

Additional notes here

ESP8266 voltage spikes on power rail

I used esp8266 for broadcasting message to my website. But to operate this chip smoothly one needs to redesign its power supply.

There are voltage spikes of around 320 mV

esp8266 voltage spikes on power rail
esp8266 voltage spikes on power rail

at normal operation the chip uses around 70 mA or current. and when broadcasting something over WiFi current  can rise to about 170mA( according to its datasheet).

This all is not the problem. Because everything works.

Problem is the voltage drop accross the lm317t.

Input voltage = 12v

output voltage = 3.3v

voltage difference = 12v – 3.3v = 8.7v

load current = 105 ma

power dissipating = 8.7V x 0.105A = 0.9135W

That’s a lot of power which is being thermal dissipated.

I used a very tiny heat sink. Also the heat sink is attached by a drop of fevicol instead of thermal paste (cheap solution)

My Suggestion:
use a 5V input at lm317t

volatge difference = 5v – 3.3v = 1.7v

power dissipation = 1.7 x 0.105 = 0.178 W

 

Internet of thing Digital Thermometer DS18B20

I purchased this ic a long time ago. Never had any chance of using it. But now the this small itsy bitsy integrated circuit is sending data on the internet.

You can check the link at http://abhaykant.com/mtb

It is connected on a custom gateway device.

The ds18b20 can take power in two ways. The circuit that i made is using the parasite power.


This time i used clear nail pail paint over the copper trace.

ds182b20 interface schematic
ds182b20 interface schematic

printed circuit board is designed in KiCad open source EDA tool.

 

UPDATE : 14 September 2018

Using nail paint as a substitute for PCB lacquer is a cheap solution. It should be avoided when making a rugged PCB. If their is a lot a mechanical vibrations and stress, then the nail paint will chip away leading to oxidation.

7805 based power supply with Voltage and current protection

7805 linear voltage regulator is an inexpensive solution. But the ic doesnt include any form of protection. So, the voltage and current protection should be externally added.

There is high chance of reversing the polarity if you dont keep which wire is what. I did the same mistake and blown the aluminium electrolytic capacitors with 7805 ic.

Below is the revised circuit from 5V voltage regulator using 7805 | Complete Process.

schematic of 7805 based power supply with Voltage and current protection
schematic of 7805 based power supply with Voltage and current protection