Hello everyone
I'm actually a new member here as i wish i can get the help i need, and also try to help others.
I'm doing my final year project which is an assistance aid that helps blind people avoid obstacles while walking.
in this topic i want to seek help while im doing my software part.
at the FIRST part...What im going to do is that i want to control a vibration motor (rotation in 1 direction only) depending on the output of ultrasonic sensor which is Maxbotix EZ1 (datasheet : http://www.maxbotix.com/uploads/LV-MaxSonar-EZ1-Datasheet.pdf )
this sensor got digital output (PWM), and an input of 5V with a detection distance that can reach to 6m. in this project im going to use the PWM output.
the process will be:
- if there is a far obstacle the vibration motor should rotate slowly.
- if there is a medium distance obstacle the vibration motor should rotate at normal speed.
- if there is a near obstacle the vibration motor should rotate fast.
Im going to use PIC16F876A microcontroller which has an internal ADC and other sufficient features.
there is no display LCD or buzzers...no..just as simple as that (thats for FIRST part) and as im pretty weak in programming , i'll need your full help.
at start i want to control the ultrasonic sensor...i've found a source code in the Maxbotix supplier (Cytron) forums, the code does control the ultrasonic, but for different output purposes which can be adjusted easily.
for this code, the user used PIC16F877 (which has an internal OSC)
at first, i tried compiling the code just for checking but the following errors occurred:
can't open include file #include <pic.h>
can't open include file #include <stdlib.h>
can't open include file #include <string.h>
can't open include file #include <stdio.h>
can't open include file #include "delay.h"
can't open include file #include "delay.c"
the compiler that im using is MikroC PRO (& MikroC)....i think there are some missing files if im not mistaken, i tried simply to delete those lines but of course 10s of errors occured.
any idea what should i do to compile this code successfully ?
i need some attention for this topic please as this is my final year project.
thank you
I'm actually a new member here as i wish i can get the help i need, and also try to help others.
I'm doing my final year project which is an assistance aid that helps blind people avoid obstacles while walking.
in this topic i want to seek help while im doing my software part.
at the FIRST part...What im going to do is that i want to control a vibration motor (rotation in 1 direction only) depending on the output of ultrasonic sensor which is Maxbotix EZ1 (datasheet : http://www.maxbotix.com/uploads/LV-MaxSonar-EZ1-Datasheet.pdf )
this sensor got digital output (PWM), and an input of 5V with a detection distance that can reach to 6m. in this project im going to use the PWM output.
the process will be:
- if there is a far obstacle the vibration motor should rotate slowly.
- if there is a medium distance obstacle the vibration motor should rotate at normal speed.
- if there is a near obstacle the vibration motor should rotate fast.
Im going to use PIC16F876A microcontroller which has an internal ADC and other sufficient features.
there is no display LCD or buzzers...no..just as simple as that (thats for FIRST part) and as im pretty weak in programming , i'll need your full help.
at start i want to control the ultrasonic sensor...i've found a source code in the Maxbotix supplier (Cytron) forums, the code does control the ultrasonic, but for different output purposes which can be adjusted easily.
Rich (BB code):
//============================================================================
// Include
//============================================================================
#include <pic.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "delay.h"
#include "delay.c"
//============================================================================
// Configuration
//============================================================================
__CONFIG ( 0x3F32 );
//============================================================================
// Function Prototype
//============================================================================
void ultrasonic(void); // Find range based on input
void init(void);
void rangecal(void);
//============================================================================
// global variable
unsigned int To=0;
unsigned int TH=0;
unsigned int value;
unsigned int distance;
unsigned int data=0;
//============================================================================
// interrupt prototype
//============================================================================================================
static void interrupt isr(void)
{
if(TMR0IF) // TMR0 is overflow
{
TMR0IF=0; // clear flag bit
To+=0x100; // count number of TMR0 overflow ( make it to 16bit TMR)
}
}
//============================================================================
// Main Function
//============================================================================
void main(void)
{
init();
ultrasonic();
}
// Initailization
// Description : Initialize the microcontroller
//============================================================================================================
void init()
{
// Tris configuration (input or output)
TRISA = 0b00000000; //set PORTA as output
TRISB = 0b00000100; //set RB2 pin as input, other as output
TRISC = 0b00000000; //set PORTA as output
RB4=1; //5V to sensor
DelayMs(250); //sensor module power up time
// TMR 0 configuation
T0CS=0;
PSA=0;
PS2=1; // prescale 1:256
PS1=1; //
PS0=1; //
TMR0IE=1; // TMR0 Interrupt
TMR0=0;
GIE = 1; //global interrupt
}
//================================================================================
// FUNCTIONS
//================================================================================
//**************************************************
//Calculate the range from the sensor depending on PWM signal input
void ultrasonic(void)
{
while(1)
{
if(RB2==0) //if RB2 is high
{
TMR0=0; // clear all counter involved, start new count for period of RB2 high
To=0;
}
else
{
TH=TMR0+To; // RB2 is 0 mean is falling from 1 save TH, RB2 high period
value=TH; //value of tmr0+to
distance=value*1.75616; // calculate inch value per inch = 147us with 20Mhz internal clock.
rangecal();
}
}
}
void rangecal(void)
{
if(distance>100)
{
PORTC=0B00000001;
}
else if(distance>80)
{
PORTC=0B00000010;
}
else if(distance>60)
{
PORTC=0B00000100;
}
else if(distance>40)
{
PORTC=0B00001000;
}
else if(distance>20)
{
PORTC=0B00010000;
}
}
at first, i tried compiling the code just for checking but the following errors occurred:
can't open include file #include <pic.h>
can't open include file #include <stdlib.h>
can't open include file #include <string.h>
can't open include file #include <stdio.h>
can't open include file #include "delay.h"
can't open include file #include "delay.c"
the compiler that im using is MikroC PRO (& MikroC)....i think there are some missing files if im not mistaken, i tried simply to delete those lines but of course 10s of errors occured.
any idea what should i do to compile this code successfully ?
i need some attention for this topic please as this is my final year project.
thank you