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.

[SOLVED] Help with mikroC program of US 100 ultrasonic sensor please?

Status
Not open for further replies.

cheerio

Newbie level 6
Newbie level 6
Joined
Nov 18, 2012
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,373
Yellow all! I am asking for help regarding an unfinished project. My partner and I would like to use US- 100 ultrasonic sensor and PIC16f84a to trigger an alarm which would just be a buzzer. Sadly, though we can't seem to figure out the programming using the mikroC. All help is very, very much appreciated. Thanks and Godbless to all :smile:
 

Where exactly are you stuck?

Have you gone through the hardware manual? Here it is: http://www.e-gizmo.com/KIT/images/ultrasonicsonar/ultrasonic sonar module 1r0.pdf

Here is part of the required information:

9799351200_1353508592.png


Hope this helps.
Tahmid.
 
Thanks. This is very much appreciated!
actually we're really stuck on the programming part. Big time. :-:)-)
 

Where exactly are you stuck? What are you having difficulties in while programming? Is there something that is unclear to you?
 

To be honest, it is not clear to us what the function of the PIC16f84a is. . :-(
Pardon me for the late replies.
 
Last edited:

If you have an algorithm for your project post it and I will try to code in mikroC Pro.
 

actually, i dont know how the sensor works. so, i might have the wrong algorithm. but here it goes...

supply voltage to VCC of sensor (using microcontroller) > transmitter on > receiver on > if obstacle is in range receiver sends signal to microcontroller > microcontroller tells buzzer to buzz

Thanks! :)
 

What the...?? that's no algorithm, not even a little bit. Cheerio, you have no programming knowledge/experience, right? Then I assume you're *not* pretending someone to do the whole job but someone to put a pen in your hand and give you some paper... right?

Here's some help for starting...
whatever the ultrasonic sensor is the big steps are not really the ones you described. By fast examining your problem steps should be: send pulse to the sonar > start checking for the echo return > when echo arrives start buzzing > when echo ends stop buzzing. It should not be such a difficult task... You can use the RB0 pin as external interrupt and connect it to the echo pin of the ultrasonic sensor. When interrupt on RB0 is triggered you know there is echo so you start counting. When there's no more echo you check the count (probably you'd need some calculations) and you've got the distance of the object.

If you confirm my suppositions then you'll probably get helped better. Otherwise, people will keep asking which are your difficulties in programming assuming you have at least some programming knowledge.

p.s.
The ultrasonic sensor you're using is this one?
http://www.e-gizmo.com/KIT/images/ultrasonicsonar/ultrasonic sonar module 1r0.pdf
 
Last edited:
What the...?? that's no algorithm, not even a little bit. Cheerio, you have no programming knowledge/experience, right? Then I assume you're *not* pretending someone to do the whole job but someone to put a pen in your hand and give you some paper... right?

Here's some help for starting...
whatever the ultrasonic sensor is the big steps are not really the ones you described. By fast examining your problem steps should be: send pulse to the sonar > start checking for the echo return > when echo arrives start buzzing > when echo ends stop buzzing. It should not be such a difficult task... You can use the RB0 pin as external interrupt and connect it to the echo pin of the ultrasonic sensor. When interrupt on RB0 is triggered you know there is echo so you start counting. When there's no more echo you check the count (probably you'd need some calculations) and you've got the distance of the object.

If you confirm my suppositions then you'll probably get helped better. Otherwise, people will keep asking which are your difficulties in programming assuming you have at least some programming knowledge.

p.s.
The ultrasonic sensor you're using is this one?
http://www.e-gizmo.com/KIT/images/ultrasonicsonar/ultrasonic sonar module 1r0.pdf

thank you so much mister.

i admit that my programming background to make this project is not that good and i think the steps you said were very accurate to what this project should be. so, thanks again!
 

OK, so we know what's the situation at this time.
Now, I've never worked with any of those devices, I'd make some code for you but I'm sure it's almost useless if I don't have the device for testing.
Although, in the link I gave you at the bottom of the PDF there's an example code for gizDuino (a Lite version of Arduino). You might want to give it a look and also, people here who already worked with arduino and similar MCUs will be able to help you better with that code.
 
actually, i cant afford to buy gizduino right now. i know it's already the economically friendly version of the arduino but still im kinda short of penny. life's hard, you know. so, i kind of decided to use pic16f84a.

i badly need all help i can get. any codes for this project in any programming language is a great help. thanks a lot guys.
 
Last edited:

What is the condition for alarming the buzzer?

Use the external interrupt feature. You can find it on page 31 of the 16F84A datasheet.
5232359100_1353735683.png


Set external interrupt on rising edge. Send a pulse to trigger the sensor. The pulse width should be ≧ 5µs. Upon interrupt start counting. Then, set external interrupt on falling edge. Upon interrupt stop counting. Now, from the count you need to calculate the time.

actually, i cant afford to buy gizduino right now. i know it's already the economically friendly version of the arduino but still im kinda short of penny. life's hard, you know. so, i kind of decided to use pic16f84a.

There are many PICs cheaper than PIC16F84A. You could use one of them as well.

From your previous posts, I think you will turn the buzzer on as long as the obstacle is within the sensor's range (2cm to 350cm). You don't need to actually calculate the range. Or do you?

If you tell your exact requirement I can help you with the code.
 
From your previous posts, I think you will turn the buzzer on as long as the obstacle is within the sensor's range (2cm to 350cm). You don't need to actually calculate the range. Or do you?

Yes exactly, I don't need to measure the distance between the obstacle and the sensor. All I wanted is for the buzzer to turn on while the obstacle is in range of the sensor. Wow, Im actually learning from you guys. Thanks so much.

By the way, what do you mean exact requirement?
 

That's part of what I meant: if you need measurement or not. The other thing I need to know is, how frequently are you going to check if obstacle is within sensor's range. Or will it be done continuously?

I'm guessing that if the obstacle is beyond the sensor's range, there will be no echo (signal back) from the sensor.
 

The other thing I need to know is, how frequently are you going to check if obstacle is within sensor's range. Or will it be done continuously?

I wanted it to be continuously checking if there's an obstacle as long as the power supply is on.
 

First, let's not take any range calculation.

Just detection.

So, you could use something like this:

Code:
sbit TRIGGER at RB2_bit;
sbit BUZZER at RB7_bit;
void main() {
     PORTA = 0;
     TRISA = 0;
     PORTB = 0;
     TRISB = 1; //RB0 input for EXTERNAL INTERRUPT
     INTF_bit = 0;
     OPTION_REG = 0xC0; //RBPU disabled, rising edge interrupt
     while (1){
           TRIGGER = 1;
           delay_us(6);
           TRIGGER = 0;
           delay_ms(100);
           if (INTF_bit == 1){
              BUZZER = 1;
              INTF_bit = 0;
           }
           else{
                BUZZER = 0;
           }
     }
}

You could even set external interrupt for falling edge to detect the "end" of the echo instead of the "beginning".

That should be clear enough. Now you can tweak it as necessary.

Hope this helps.
Tahmid.
 
thank you so much for the help :)
really really appreciate it!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top