Microcontroller › PIC › i want to change that programe written on MPLAB c language for PIC16F877(blind person navigation system)
- This topic has 3 replies, 1 voice, and was last updated 12 years, 1 month ago by
ZOBI.
-
AuthorPosts
-
April 30, 2011 at 2:03 pm #896
ZOBI
ParticipantThis source code is made for blind person helping project using 4 ultrasonic range finder SRF04,4 vibration motors and single PIC16F877 microcontroller
when any obstacle come in front of SRF04 they sends signal to controler and controller vibrates motor
but this source code is made in such a way that constant vibration is produce and i want to make the duty cycle of motors with respect to the distance ,means the closer the person goes to any obstacle the greater the vibration in motor,in that manner blind person could understand that he or she is closer to any obstacle
here is the source code and circuit diagram at the end
please can any buddy change that and make it according to the above method which i hav mentioned
#include <16F877.h> //standard includes
#include <stdio.h>
#use delay(clock=20000000) // 20 MHz clock
#define TOP_THRESHOLD 120 //define a threshold to determine near vs far, ie,
object or no object, for the top sensor
#define MID_THRESHOLD 140 //define a threshold to determine near vs far, ie,
object or no object, for the middle sensors
#define BOT_THRESHOLD 160 //define a threshold to determine near vs far, ie,
object or no object, for the bottom sensor
#define TIME_DELAY 30 //define a delay to wait while counting in order to
undersample
int time; //initliaze a variable to act as a counter
//code to deliver trigger pulse to sensors
void trigger() {
output_high(PIN_B2);
delay_us(12);
output_low(PIN_B2);
}
void main() {
while(true) {
//PIN_A1
time=0; //(re)set time to 0
trigger();
while(!input(PIN_A1)); //wait while the output of this sensor is low
//then when it goes high, count how many cycles it is high for
while(input(PIN_A1)) {
delay_us(TIME_DELAY);
time++;
}
//check time and take appropriate action, that is, vibrate or not
if (time<=TOP_THRESHOLD) {
output_high(PIN_C1);
}
else {
output_low(PIN_C1);
}
//repeat for the other 3 sensors:
//PIN_A2
time=0;
trigger();
while(!input(PIN_A2));
while(input(PIN_A2)) {
delay_us(TIME_DELAY);
time++;
}
if (time<=MID_THRESHOLD) {
output_high(PIN_C2);
}
else {
output_low(PIN_C2);
}
//PIN_A3
time=0;
trigger();
while(!input(PIN_A3));
while(input(PIN_A3)) {
delay_us(TIME_DELAY);
time++;
}
if (time<=MID_THRESHOLD) {
output_high(PIN_C3);
}
else {
output_low(PIN_C3);
}
//PIN_A4
time=0;
trigger();
while(!input(PIN_A4));
while(input(PIN_A4)) {
delay_us(TIME_DELAY);
time++;
}
if (time<=BOT_THRESHOLD) {
output_high(PIN_D0);
}
else {
output_low(PIN_D0);
}
delay_ms(3);
}
}May 2, 2011 at 1:58 pm #6073ZOBI
ParticipantMay 2, 2011 at 1:59 pm #6074ZOBI
Participanthey yar
where is every buddy plz help me out its a simple code
if any buddy can not make that source code which i hav asked on c language then make it on assembly but reply me
May 5, 2011 at 6:44 am #6083ZOBI
Participanti will change the circuit if its required but 1st i need some one to help me to change the source code which i have mentioned
can u change it? i dont know the cammands which will be used to make it according to my thought
-
AuthorPosts
- You must be logged in to reply to this topic.