Please mail me your projects so that i can share them here.

updates continued with new topics.Roboticstutorials is no longer for robotics only now all kind of projects will be posted.People who want to participate here or want to share their projects can mail me.


This place is for absolute begineers who are interested in electronics and robotics .Free projects,tutorials,schematics
are available here .You can paricipate here in my forum and
leave messages and comments .
Google
 
LATEST ENTRY

c program to control speed and direction of DC motor

/*
FILE: PWM.C
DESC: Control speed and direction of a DC motor using PWM
*/
#include stdio.h
#include stdlib.h
#include dos.h /* outportb, inportb defined here */
#include conio.h /* formatted text functions defined here */
void pwm(int, int, int, int);
void main(void) {
int BASEADDR;
int PORTA, PORTB, PORTC;
int CNTRL;
int DutyCycle;
int SpeedOption;
int Enable, Phase; /* Enable on A.0, Phase on A.1 */
clrscr(); /* clear screen */
window(5,5,75,30); /* set up text window */
gotoxy(1,1); cprintf("Enter Base Address (decimal) e.g. 608 =>\n");
gotoxy(42,1); scanf("%d", &BASEADDR);
PORTA = BASEADDR;
PORTB = BASEADDR + 1;
PORTC = BASEADDR + 2;
CNTRL = BASEADDR+3;
outportb(CNTRL, 128); /* configure all ports for output */
outportb(PORTA, 0); /* motor should be off */
gotoxy(1,3); cprintf("Speed Options");
gotoxy(1,4); cprintf("(f)aster");
gotoxy(1,5); cprintf("(s)lower");
gotoxy(1,6); cprintf("(r)everse direction");
gotoxy(1,7); cprintf("(q)uit");
gotoxy(1,9); cprintf("Selection => ");
gotoxy(14,9);
DutyCycle = 0; /* start off at zero velocity */
Enable = 1;
Phase = 0;
do {
while (!kbhit()) {
pwm(PORTA, DutyCycle, Enable, Phase);
}; /* end of while */
SpeedOption = getch();
switch(SpeedOption) {
case 102 : /* 102 ASCII is f */
/* increase speed by 10% DC */
DutyCycle = DutyCycle + 5;
if(DutyCycle > 100) {
DutyCycle = 100;
gotoxy(1,20); cprintf("Can't go faster");
delay(200);
gotoxy(1,20); cprintf(" ");
};
gotoxy(1,13); cprintf("Going faster...\n");
Enable = 1;
pwm(PORTA, DutyCycle, Enable, Phase);
break;
case 115 : /* 115 ASCII is s */
/* decrease speed by 10% DC */
DutyCycle = DutyCycle - 5;
if(DutyCycle < 0) {
DutyCycle = 0;
gotoxy(1,20); cprintf("Can't go slower");
delay(200);
gotoxy(1,20); cprintf(" ");
};
gotoxy(1,13); cprintf("Going slower...\n");
Enable = 1;
pwm(PORTA, DutyCycle, Enable, Phase);
break;
case 114 : /* 114 ASCII is r */
/* reverse direction at present DC */
Enable = 1;
if(Phase == 0) {
Phase = 2;
} else if(Phase ==2) {
Phase = 0;
};
pwm(PORTA, DutyCycle, Enable, Phase);
gotoxy(1,13); cprintf("Reversing.....\n");
break;
case 113 : /* 113 ASCII is q */
gotoxy(1,22); cprintf("Quitting");
outportb(PORTA, 0);
outportb(PORTB, 0);
outportb(PORTC, 0);
exit(0);
break;
}; /* end of switch */
gotoxy(14,9);
} while(1); /* end of do */
}; /* end of main */
void pwm(int PORTA, int DutyCycle, int Enable, int Phase) {
int OnTime, OffTime, TotalTime;
TotalTime = 100; /* 100 msec */
OnTime = (int)(TotalTime * DutyCycle / 100);
OffTime = (int)(TotalTime - OnTime);
outportb(PORTA, Enable+Phase);
delay(OnTime);
Enable = 0;
outportb(PORTA, Enable+Phase);
delay(OffTime);
gotoxy(1,10); cprintf("Duty Cycle is %3d", DutyCycle);
return;
}; /* end of pwm */

Participate in my new msg forum and share projects and Tutorials

MESSAGE BOX -- subscribe below to get updates


Enter your email address:

Delivered by FeedBurner

IF ANYONE WANT TO GET A PERSONAL HELP OR WANT TO BUY A PROGRAM OR ROBOT CAN MAIL ME.
PLEASE POST UR MESSAGES OR REQUESTS IN MESSAGE BOX
OR MAIL ME AT .... abhishekrobotics@gmail.com

Augmented reality onboard the ISS? Tech blogs on ZDnet

Massachusetts high schools vying to update old science labs The Boston Globe Online

Robots vie in fight of racks, ringers Contra Costa Times

Teens build, enter machines in contest San Mateo County Times

New NASA software to ease astronauts' tasks in adverse space conditions Big News Network

More news >>

Powered by Newsfeed Maker