|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||||
|
|||||
|
SONAR Sensor Software Driver
For anyone interested in using a SONAR sensor I have completed a software driver for it. If anyone has any questions feel free to post in this thread.
Once I develop a personal website I will post the software there. Until that time it can be found by using the link in this thread. SONAR_0.1.zip The introduction from the readme: Code:
Introduction: This source code in sonar.c and sonar.h are a driver for several consumer available sonar ultrasonic range finder sensors. Tested to work with this software is the Parallax Inc. PING)) Ultrasonic Rangefinder and the Vex Robotics Ultrasonic Range Finder. This software was written for the Innovation First Inc. Mini Robot Controller. Unmodified this software utilizes Interrupt 1 and Timer 3. Other controllers may be used including Innovation First Inc.'s full size robot controller as well as other PIC microcontrollers with modifications. The documentation refers to the controlling microcontroller simply as the controller. This software works by triggering the sonar sensor causing it to send an acoustic ping. Once the ping hits an object it will reflect back towards the sensor. The sonar sensor represents the distance to the object with a pulse width equal to the time it took for the ping to hit the object and return back. This software measures the pulse width and converts the time to a distance in inches. |
|
#2
|
|||||
|
|||||
|
Re: SONAR Sensor Software Driver
Thanks for posting the driver code. I had to finnagle the timer interrupt routine a tad to get it to work on the full-size FRC, but otherwise it has made my job much easier!
Thanks! ![]() |
|
#3
|
|||
|
|||
|
Re: SONAR Sensor Software Driver
Yeah, thanks alot Mike. It works perfectly.
This saved me hours of coding, and I'm sure it will do the same for many others. |
|
#4
|
|||
|
|||
|
Re: SONAR Sensor Software Driver
Why is this code so complicated? I really don't see why you need all of this. I don't know anything about programming the range finder, but it seems to me that you should just be able to send the range finder a 0 or a 1 to trigger it and then measure with a timer the time it takes for the pulse to come back. Why is there all this complicated stuff? Is it really needed? I'm not criticizing, I just want to know for my own sake.
|
|
#5
|
|||||
|
|||||
|
Re: SONAR Sensor Software Driver
Quote:
|
|
#6
|
|||||
|
|||||
|
Re: SONAR Sensor Software Driver
Quote:
![]() |
|
#7
|
|||||
|
|||||
|
Re: SONAR Sensor Software Driver
I have an updated version of the SONAR software driver that supports the 2006 Robot Controller. Get it here: SONAR_0.3.zip
|
|
#8
|
|||||
|
|||||
|
Re: SONAR Sensor Software Driver
Quote:
I've been scanning the code to understand it a little. And I found something strange: at one point sonar_status is set to SONAR_REST, but there is no case statement looking for SONAR_REST. In fact, SONAR_REST appears nowhere else in the code except in the .h file where it is created. Is SONAR_REST a remnant from a previous version? Won't the code get lost if sonar_status is set to SONAR_REST? -Norm |
|
#9
|
|||||
|
|||||
|
Re: SONAR Sensor Software Driver
Quote:
I'm glad you like the software. Please let us know how your testing turns out. |
|
#10
|
|||||
|
|||||
|
Re: SONAR Sensor Software Driver
Quote:
In your README it says Quote:
But step 3 puzzles me. Quote:
Here is my modified InterruptHandlerLow (). The mods are in color. Code:
#pragma code
#pragma interruptlow InterruptHandlerLow save=PROD /* You may want to save additional symbols. */
void InterruptHandlerLow ()
{
unsigned char int_byte;
if (INTCON3bits.INT2IF && INTCON3bits.INT2IE) /* The INT2 pin is RB2/DIG I/O 1. */
{
Hardware_Interrupt_Sonar(); ////// <--- added to support sonar
INTCON3bits.INT2IF = 0;
}
else if (INTCON3bits.INT3IF && INTCON3bits.INT3IE) /* The INT3 pin is RB3/DIG I/O 2. */
{
INTCON3bits.INT3IF = 0;
}
else if (INTCONbits.RBIF && INTCONbits.RBIE) /* DIG I/O 3-6 (RB4, RB5, RB6, or RB7) changed. */
{
int_byte = PORTB; /* You must read or write to PORTB */
INTCONbits.RBIF = 0; /* and clear the interrupt flag */
} /* to clear the interrupt condition. */
// the following added to support sonar:
//
else if ( PIR2bits.TMR3IF && PIE2bits.TMR3IE )
{
Timer_Interrupt_Sonar();
}
else
{
CheckUartInts(); /* For Dynamic Debug Tool or buffered printf features. */
}
}
|
|
#11
|
|||
|
|||
|
Re: SONAR Sensor Software Driver
Instead of a new thread I'll post here. There is a new sonar ranging sensor on the market. New sonar The interesting points as I see it are - Nice price, narrower cone of detection, and 3 ways to interface. RS232, analog voltage and the normal pulse timing. Too late for this year but may be a worthy addition to next years sensor selection.
|
|
#12
|
|||||
|
|||||
|
Re: SONAR Sensor Software Driver
Quote:
In my defense: Gdeaver's post didn't show up on a search. Anyway: The code to measure the pulse is very cool, but that new sensor also gives an analog voltage at 10 mV/inch - just a simple analog input and you're done... Don |
|
#13
|
|||||
|
|||||
|
Re: SONAR Sensor Software Driver
Quote:
![]() |
|
#14
|
|||
|
|||
|
Re: SONAR Sensor Software Driver
How do I connect the PING))) sensor made for Parallex robots to the VEX Micro Controller and program the sensor in EasyC 2.0?
|
|
#15
|
|||||
|
|||||
|
Re: SONAR Sensor Software Driver
Quote:
NOTE: ERROR IN VEX SONAR DATA SHEET! The data sheet that comes with the VEX sonar kit has an error. It says, Quote:
Quote:
One way to tell that it's hooked up right and the software is pinging it is to hold the device up to your ear and listen to it. When I got it working I could hear a faint "tictictictic..." coming from the device. I did not hear that before I switched the wires. Thanks again. Now I have to write new autonomous code that I can't test on the robot until we get to the next regional. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Toshiba Cardbus Problem? | jpsaul7usa | Chit-Chat | 12 | 01-01-2006 02:37 |
| Introducing the Driver Strategy Database's Online Database | impulse3D | Rules/Strategy | 17 | 17-03-2005 03:04 |
| Updated: Serial Port Driver Code | Kevin Watson | Programming | 4 | 05-02-2005 18:39 |
| New Serial Port Driver | Kevin Watson | Programming | 16 | 09-01-2005 01:56 |
| Middle School Drivers | ram | General Forum | 40 | 26-02-2003 17:01 |