Skip to main content

Posts

Showing posts from 2014

PIC Programming: LED blinking using C

Circuit: Program: #include<P18F452.h> #define mybit PORTBbits.RB0 void MSDelay (unsigned int); void main() { TRISBbits.TRISB0=0; while(1){ mybit=1; MSDelay(250); mybit=0; MSDelay(250); } } void MSDelay (unsigned int itime) { unsigned int i;     unsigned char j; for(i=0;i<itime;i++) for(j=0;j<165;j++); }

PIC Programming: stepper motor interface with clockwise and anticlockwise control using C

Circuit: Program: #include<p18f452.h> #pragma config WDT=OFF #define a 100 void delay(unsigned char); void main(){ TRISB=0x00; TRISD=0x00; while(1){ if(PORTDbits.RD0==0){ PORTB = 0b00000001; delay(a); PORTB = 0b00000100; delay(a); PORTB = 0b00000010; delay(a); PORTB = 0b00001000; delay(a); } else{ PORTB = 0b00001000; delay(a); PORTB = 0b00000010; delay(a); PORTB = 0b00000100; delay(a); PORTB = 0b00000001; delay(a); } } } void delay(unsigned char time){ unsigned char i,j; for(i=0;i<165;i++) for(j=0;j<time;j++); }

PIC Programming: 00-99 7 Segment Counter using C

Circuit: Program: #include<p18f452.h> #pragma config WDT = OFF void delay(unsigned int); void main() { unsigned char led1[]={0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x3F}; unsigned char led2[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F}; unsigned char a,b; TRISB=0x00; TRISD=0x00; PORTB=0b10111111; PORTD=0b10111111; while(1){ for(a=0;a<=9;a++) { PORTB=led2[a]; delay(200); for(b=0;b<=9;b++) { delay(200); PORTD=led1[b]; } } } } void delay (unsigned int time){ unsigned char i,j; for(i=0;i<165;i++) for(j=0;j<time;j++); }

PIC Programming: 7 segment display interface using assembly

Circuit: Program: #include P18F452.INC R1 EQU 0X07 R2 EQU 0X08 ORG 0 CLRF TRISB L3 MOVLW 0X3F MOVWF PORTB CALL QDELAY MOVLW 0X06 MOVWF PORTB CALL QDELAY MOVLW 0X5B MOVWF PORTB CALL QDELAY MOVLW 0X4F MOVWF PORTB CALL QDELAY MOVLW 0X66 MOVWF PORTB CALL QDELAY MOVLW 0X6D MOVWF PORTB CALL QDELAY MOVLW 0X7D MOVWF PORTB CALL QDELAY MOVLW 0X07 MOVWF PORTB CALL QDELAY MOVLW 0X7F MOVWF PORTB CALL QDELAY MOVLW 0X6F MOVWF PORTB CALL QDELAY GOTO L3 QDELAY MOVLW D'200' MOVWF R1 D1 MOVLW D'250' MOVWF R2 D2 NOP NOP DECF R2,F BNZ D2 DECF R1,F BNZ D1 RETURN END

PIC programming: Interfacing DC Motor using LN293D with C programming

Circuit: Program: #include<p18f452.h> #pragma config WDT=OFF void main(){ TRISB=0x00; while(1){ PORTB=0x01; } }

PIC Programming: bipolar stepper motor interface using C

CIRCUIT: Program: #include<p18f452.h> #pragma config WDT=OFF #define a 50 void delay(unsigned char); void main(){ TRISB=0x00; while(1){ PORTB = 0b00000001; delay(a); PORTB = 0b00000100; delay(a); PORTB = 0b00000010; delay(a); PORTB = 0b00001000; delay(a); } } void delay(unsigned char time){ unsigned char i,j; for(i=0;i<165;i++) for(j=0;j<time;j++); }

PIC Programming: 7 segment display interface using C

CIRCUIT: PROGRAM: #include<p18f452.h> #pragma config WDT = OFF void delay(unsigned int); void main() { unsigned char led[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F}; unsigned char a; TRISB=0x00; while(1){ for(a=0;a<=9;a++) { PORTB=led[a]; delay(250); } } } void delay (unsigned int time){ unsigned char i,j; for(i=0;i<165;i++) for(j=0;j<time;j++); }

PIC Programming: making a port bits toggle using assembly

CIRCUIT: Program: #INCLUDE p18f452.INC ORG 0 CLRF TRISD  L1 SETF PORTD CALL DELAY CLRF PORTD CALL DELAY GOTO L1 DELAY MOVLW 0xff MOVWF 0x10 L2 DECF 0x10,F BNZ L2 RETURN END

PIC Programming: 7 Segment Dispaly using assembly

Program: #include P18F452.INC R1 EQU 0X07 R2 EQU 0X08 ORG 0 CLRF TRISB L3 MOVLW 0X3F MOVWF PORTB CALL QDELAY MOVLW 0X06 MOVWF PORTB CALL QDELAY MOVLW 0X5B MOVWF PORTB CALL QDELAY MOVLW 0X4F MOVWF PORTB CALL QDELAY MOVLW 0X66 MOVWF PORTB CALL QDELAY MOVLW 0X6D MOVWF PORTB CALL QDELAY MOVLW 0X7D MOVWF PORTB CALL QDELAY MOVLW 0X07 MOVWF PORTB CALL QDELAY MOVLW 0X7F MOVWF PORTB CALL QDELAY MOVLW 0X6F MOVWF PORTB CALL QDELAY GOTO L3 QDELAY MOVLW D'200' MOVWF R1 D1 MOVLW D'250' MOVWF R2 D2 NOP NOP DECF R2,F BNZ D2 DECF R1,F BNZ D1 RETURN END

PIC 18F452 Programming: LED blinking using assembly

Here is the basic program you need to start off with when you learn to use a microcontroller. We are using the microchip family PIC microcontroller. Which stands for Peripheral Interface Controller, PIC 18F452 is a 40 pin 8-bit microcontroller with 32 KBytes flash, 1536 Bytes of RAM and 256 Bytes EEPROM. It also boasts 4 timers, and three external interrupt pins. Coming to our first program, We will be using MPLAB for Building this project. Create a new project and select MPASM Suite for compiling. After writing the program, Dont forget to add the linker file and the source file in the source window. The linker file for the PIC 18F452 can be found in the  C:\Program Files\Microchip\MPASM Suite\LKR. search for 18f452. In this program, the Bit RB0, toggles continuously with some delay. Connect an LED to The RB0 Pin, i.e Pin 33.connect a 330E resistor in series with the LED. PROGRAM #INCLUDE p18f452.INC; CONFIG WDT=OFF; disabling the watchdog timer ORG 0; Specifing the st

Hot air balloon / sky lantern / glow lantern

HOT AIR BALLOON These small hot air balloons are referred to as sky lanterns or glow lanterns   The balloons are simple and rely on the principles of increasing the air temperature inside the envelope making it lighter than the surrounding (ambient) air. The balloon floats because of the buoyant force exerted on it. This force is the same force that acts on objects when they are in water and is described by Archimedes' principle. The balloons are made of lightweight, flame retardant paper and use a small fire source made of paraffin wax to provide hot air. USES: Can be used as decorations and a source of entertainment during special occasions such as birthdays, weddings, parties, farewells, etc. As a model to teach children basics of flight The balloons can also be modified in order to carry out atmospheric analysis for pressure, humidity, composition, etc. Here is a small  video  clip of the hot air balloon rising..

Interfacing 16x2 LCD with AVR Atmega 8

In this post I will walk you through on how to write a program onto your AVR microcontroller to display your name on a 16x2 or 16x1 LCD. You do not require a lot of components or soldering. for simplicity, I used a female to female connector to connect the lcd to the microcontroller. I have soldered a header pin for the LCD module. First let us understand the LCD pin configuration.It has 16 pins. and works on parallel communication.one must also remember that LCD's are slow compared to the microcontrollers we use. hence we have to use a lot of delay(in order of ms not minutes :-P). among the 16 pins, there are three important pins, namely R/S,E,R/W which are addressed as Register Select, Enable,Read or Write respectively.To make it simple, in this post let us connect R/W to ground. which brings the lcd in write mode. so now we have 2 control pins namely RS and E and 8 data pins from D0-D7 to send parallel data. we also have two pins for power supply and two for LED backl

How I built a RC Hovercraft

Last weekend one of my friend came to me and told me about an HOVERCRAFT event, and I thought I will give it a try as I had never in my life built a RC Hovercraft. So we thought we will learn something while building and we started with just a top-view diagram my junior made it on a drawing sheet. We got two extremely power full brush less DC motor. We did not buy the motor for the hovercraft. we bought two motors to build a twin engine aircraft and thought we can use it for this purpose also. The motors were too power full, hence we had to maintain the power to 50% and max 60%. We encountered several problems like the air cussion was not proper. we had to come up with the perfect design by trial and error. first we used flex banners for air cussion. unfortunately the flex was a bit heavy for the aircraft. later we faced another problem once the hovercraft started to hover, it started to rotate because of the rotational force. then the new problem was the rudder we made was small. we

Grid solver robot

A grid solving robot is an autonomous robot which is nothing but more brains to a line follower. the grid solver can be programmed to go to specific coordinates like in the videos below. Both the videos have different grids and different coordinates. The first video, has one inch black tape extension at the outer edges. where as in the second video, there are no extensions as in the first video. This makes a lot of difference. since I had only two sensors. If  you had more sensors, say 8-10 then it is easier for you to program it to get to the edges or corners. both the videos were taken at different institutions. I secured first place in both with this robot. and there is another event tomorrow. Anyway back to the topic, if you are planning to build one try to add more sensors. more the merrier. I am not going in detail about the construction of the robot. if you are interested to build one like mine, leave a comment and i will post the full procedure. I used an arduin

Line follower robot

                     It is an intelligent robot which can follow a black line on white background. It is a simple yet interesting project. The robot has two Sensor which senses the black line and follows the black line. with Just few components, this marvellous line following robot will be ready to follow. The one I have built is based on arduino. you can build with just any microcontroller. I salvaged the parts from old robot and built this one. Check my Grid solver robot  that is based on the line follower. same hardware, but the program is changed. I used a sensor which gives High or low depending whether its on black or white path. it gives HIGH '1' when on white line or place. and gives LOW '0' when on black path. I uses 2x4V battery, that makes it 8 V. I connected only 4 V to the motor driver for few reasons.namely, 1. The motor is 6v 2. It is a 300 rpm motor and supplying 8 V will increase the rpm 3. Increase In rpm would result in the robot to overshoot

VHDL

VHDL stands for V ery high speed integrated circuit H ardware D escriptive L anguage. VHDL is a hardware descriptive language used to describe the behavior and structure of a digital system. Entity specifies the input and output of a particular device. Primary constants: Entity declaration. architecture body configuration declaration package declaration package body Rules: It is case insensitive. ex: a and A mean the same. half_adder and Half_ADDER are same. File name should always start with a alphabet '_' and other special characters can be used in file names The declaration include name,type of input and output. Entity declaration: Lets take an example, of half adder. sum is given by a xor b. and carry is given by a*b. entity declaration starts with the keyword entity. port is a keyword to specify input and output. input and output is represented as in bit or out bit. here bit is used to specify that it is one bit of informatio

Difference between combinational logic circuits and sequential logic circuits

Combinational logic circuits Sequential logic circuits          These are the basic building blocks of Logic Gates              These are the basic building blocks of Memory elements           The present output state depends only on the present input.  The present output depends on the                    Present input and also the previous output.               No clock is present Clock is present               Examples: Adders Substractors Multiplexers Encoders           Examples: Flip – Flops Registers Counters

RISC Vs. CISC

RISC : Reduced Instruction Set Computer CISC : Complex Instruction Set Computer RISC Faster execution. single clock cycle execution few power-full instructions highly pipe-lined super scalar architecture hard wired control unit complex operation to software more coding CISC slow execution Rich and varied variety of power-full instruction. variable instruction format micro-programmed control unit external unit for accelerating computation easy to modify instruction set by modifying Micro-programmed control unit decreases software design complexity  less coding

Microprocessors Vs. Microcontrollers

Microprocessor is like a human brain. It can process information. whereas, Microconroller is like a human body which has brain, heart, lungs...etc. It goes without saying that microprocessors require external peripherals to function. Microprocessors Microprocessors are used for general purpose. i.e PC. which is flexible and meets wide-range of end user requirements. No external Interface ports are present. (I/O ports). There is no in-built memory.(RAM,ROM) I/O ports must be interfaced externally. Microcontrollers Microcontrollers are embedded systems. They perform a specific task over and over again. It is not flexible. They have in-built input and output ports. Memory is present. A finite amount of RAM and ROM is present in the microcontroller itself. Microcontrollers have inbuilt Timers and counters