Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

sensor for gripper PIC16F87-7A (help)

Status
Not open for further replies.

denniscbe

Newbie level 2
Joined
Jun 28, 2010
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,307
hi..i have done a project on force sensing gripper. as per my project motor should stop when the vibrator sensor reaches a particular input value as shown in below program. but it keep on changing direction when the sensor is high.. i have to finish this project with in 10 days.i have uploaded my video in following link....https://www.youtube.com/watch?v=ZZFbJAGhF_M
https://www.youtube.com/watch?v=DaYKsVVIUN4
but as per my project operation should be like this video
https://www.youtube.com/watch?v=gtnNByljPq8&feature=related

please any one help me..

/* 20Mhz crystal */

#include<pic.h>
#include"pic_lcd8.h"
#include"pic_adc.h"

#define pulse3 RC0
#define vib RB0
#define start RB1
#define stop RB2

void delay(unsigned int);
void Adc_Tmr_Init(void);
void adc0(void);
void pulse();

unsigned int count,times,on1,on2,on3;
unsigned char sec,value;
float var1;

void main()
{
TRISC=0X00; ///output
TRISD=0x00; ///op
TRISB=0xff; //o/p
TRISA=0XFF; //o/p
ADCON1=0X00; //8 bit ADC
Lcd8_Init();

Lcd8_Display(0x80," Sense Forcing ",16);
Lcd8_Display(0xc0," Gripper ",16);

delay(65000);
Adc_Tmr_Init();
TMR1ON=1;
while(1)
{

// Vibration Sensor codings
value=Adc8_Cha(1);//value reading for vibration sensor
Lcd8_Decimal3(0xca,value);
// if(value==0 )
// {
// var1=255;pulse();Delay(65000);
//d=1;e=f=0;
// }
if(value>0 && value<=20)
{
var1=30;pulse();Delay(65000);
}
else if(value>20 && value<=40)
{
var1=70;pulse();
Delay(65000);
}
else if(value>40 && value<=60)
{
var1=120;pulse();
Delay(65000);
}
else if(value>60 )
{
var1=255;pulse();
Delay(65000);
}


// Code for start and stop buttons
if(!start)
{
var1=255;pulse();
Delay(65000);
}
else if(!stop)
{
var1=0;pulse();
Delay(65000);
}

pulse();


}
}


void interrupt timer1(void)
{

if(TMR1IF==1)
{

TMR1ON=0;
TMR1IF=0;

count++;
times++;
if(times>=10000){times=0;sec++;}
if(count>310) count=0;
if(count<on1) {pulse3=1;}
else {pulse3=0;}

TMR1L=0x05;
TMR1H=0xff; // fff5 - 10Us (202) ffcd - 50us
T1CON=0x10;
TMR1ON=1;

}
}

void Adc_Tmr_Init()
{
ADCON1=0x06;
TRISA=0xff;
TRISE=0x07;

GIE=1;
PEIE=1;
TMR1IE=1;

TMR1L=0x05;
TMR1H=0xff;
T1CON=0x10;

TMR1ON=0;
}

void delay(unsigned int dd)
{while(dd--);
}

void pulse()
{
on1 =(5+(var1/255)*20);
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top