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.

interfacing pic16f877 with srf04

Status
Not open for further replies.

qatar.engineer

Junior Member level 1
Joined
Nov 9, 2006
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,452
srf04 pic16f877

Hi
i want to write aprogramm in assembly to get distance from the srf04 and object but i do not know
 

interfacing srf04 using pic

qatar.engineer said:
Hi
i want to write aprogramm in assembly to get distance from the srf04 and object but i do not know


It is requisite main to make it in asembler your project? you can use a high-level language to make it like PicBasic, Mikrobasic or Pic C, so that the things are but easy
 
ok but i have mplab programm and if i will use another one i must order it and wait for it to arrive and it will take long time so if you can give me a site for learining assmbly or what you use and think it is easy
 

specifies your project?

so that it has an idea

Added after 40 minutes:

it verifies this

**broken link removed**
 
Last edited by a moderator:

hi
i want to make a project in which PIC 16F877 controls the 4 vibration motor's vibration with the help of ultrasonic range finder SRF04 , the program should be design in such a way that the vibration becomes high wen any object come closer to the SRF04 , means vibration should be inversely proportional to the distance between the object and SRF04 (the program should be made on MPLAB) because i want to use MPLAB, hope any one can help
please help me out

---------- Post added at 20:25 ---------- Previous post was at 20:15 ----------

i want a program written on MPLAB
i want to make a project in which PIC 16F877 controls the
4 vibration motor's vibration with the help of
4 ultrasonic range finder SRF04
the program should be design in such a way that the vibration becomes high wen any object come closer to the SRF04
means vibration should be inversely proportional to the distance between the object and SRF04 ,
please help me out
 
Last edited:

source code is made for a project which uses ultrasonic range finders SRF04 that sense any obstacle come in front of them and vibrates vibration motors but constant vibration,i want to make the duty cycle of motors according to the distance between the obstacle and sensor that vibration becomes inversely proportional to the distance between the sensor & obstacle also i have a question that this source code is made for PIC16F877 which is controlling 4 sensors ,4 vibration motors so i want to ask where there all 4 sensor,motor pairs works separately or they work by 1 at time , here is the source code

#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);
}
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top