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

Atmega32 Development Board

This development is very basic. It provides the GPIO in the form of header. As i will be using this board for rapid development and learning different coding practices.

I designed this board in KiCad – a open source l tool. From schematics and PCB layout is designed in this software suite.

Here are the schematics and PCB layout.

As i don’t have a laser printer i used the free hand sketching of traces. It is a very long and tedious process. After tracing with permanent marker and letting it dry it for few minutes. I etched this PCB in ferric chloride solution. I use very diluted solution, few grams of ferric chloride in around 200 ml water.

atmega32 dev board schematic
atmega32 dev board schematic
atmega32 dev board pcb layout
atmega32 dev board pcb layout
Drill Holes Marking
Drill Holes Marking
Copper Mask
Copper Mask

Total Etching time is around 40 minutes, After the board has been etched it needs to be cleaned thoroughly. I used utensil cleaning powder for that. And rinsed the board under water. And then let it air dry for few minutes.

Component Placement on PCB
Component Placement on PCB
Component Soldering
Component Soldering
Marking the Components on top layer
Marking the Components on top layer

The development is created. But there are few issues that came while testing the board. When i tested the board the chip does not responds. While checking for shorts or no connection on the PCB. I found that capacitor is not blocking the alternating signal. rather it is showing a short. So i had to change the 22pf capacitor with a new one and the board now works perfectly fine.

 

LDR Based Camera

Schematic of LDR based Camera
3d Rendering of the pcb’s

Scan the LDR reading with the help of atmega32 adc pins. Send the captured data to a computer using ftdi, bluetooth ,wifi or zigbee. Run any free math processing tool and make a image. Increasing the Number of ldr increases the resolution of the image.

Industrial Automation Using Internet of Things

The system will automatically monitor the industrial applications and generate alerts/alarms or take intelligent decisions using concept of IOT. The monitoring and controlling of the industrial automation is done through atmega32 microcontroller. The communication through the internet is done with the help of ESP8266 module. All the sensor data is collected and sent to the web server which processes and analyzes the data and sends a controlling response to the device for control action. The device receives the response and decodes the response message and control the stepper motor. Automation through IoT can help to get rid of the short distance communication.

Project Image
Project Image

Website is designed in php language. Ascii based data base was created. Graph can be generated from the previously stored values using php.