|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#16
|
|||
|
|||
|
Re: SONAR Sensor Software Driver
Quote:
|
|
#17
|
|||||
|
|||||
|
Re: SONAR Sensor Software Driver
Quote:
SPEAKING OF MOUNTING IT ON FOAM: be careful how you mount it to the foam. Just putting a block of foam behind the unit and screwing it down through the foam doesn't work: the screws transmit the vibration from the frame directly to the sonar unit. You must mount the unit to the foam, then mount the foam to the robot's frame. This gives isolation. |
|
#18
|
|||||
|
|||||
|
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 |
|
#19
|
||||
|
||||
|
Re: SONAR Sensor Software Driver
This may just be on one of those days again but how do you hook up the vex sonar sensor to the EDU robot.
|
|
#20
|
|||||
|
|||||
|
Re: SONAR Sensor Software Driver
Quote:
Other than that you hook it up to the same digital output and interrupt input as used on the Vex. |
|
#21
|
|||
|
|||
|
Re: SONAR Sensor Software Driver
I was compiling SONAR_0.3 using MPLAB C18 and it was not successful.
Followings are the errors detected from the codes in sonar.c. At function initialize_sonar() 1) SONAR_OUTPUT_CONFIG = OUTPUT -->symbol 'TRISJbits' has not been defined -->struct or union object designator expected -->lvalue required 2) SONAR_OUTPUT = 0 -->symbol 'LATJbits' has not been defined -->struct or union object designator expected -->lvalue required At function ping_sonar () 3) SONAR_OUTPUT = 1 -->symbol 'LATJbits' has not been defined -->struct or union object designator expected -->lvalue required 4) SONAR_OUTPUT = 0 -->symbol 'LATJbits' has not been defined -->struct or union object designator expected -->lvalue required I thought maybe the problem lies with the definition in sonar.h for both SONAR_OUTPUT_CONFIG and SONAR_OUTPUT (see following 2 lines) # define SONAR_OUTPUT rc_dig_out16 # define SONAR_OUTPUT_CONFIG digital_io_16 It seems to me that the define statements is referring to the hardware part or maybe the MPLAB C18 compiler is unable to read it? Would anyone reading this can share which compiler they use and how to go about solving this problem? pls help. Thank you. ![]() |
|
#22
|
|||
|
|||
|
Re: SONAR Sensor Software Driver
I have managed to solve the previous post questions.
At present, I have modify the software code for my project application. I am using a PIC18F452 microcontroller for the ping sensor. Everything works fine until programming the USART code. The hyper terminal characters does not change when the distance of the object changes. Can you help me? I have a very close deadline to meet. Follow is the code i added prior to Mike's codes: #include <p18f452.h> // version 1.1 #include <usart.h> #include "sonar.h" /* Set configuration bits * - set HS oscillator * - disable watchdog timer * - disable low voltage programming */ #pragma romdata CONFIG _CONFIG_DECL(_CONFIG1H_DEFAULT & _OSC_HS_1H, _CONFIG2L_DEFAULT, _CONFIG2H_DEFAULT & _WDT_OFF_2H, _CONFIG3H_DEFAULT, _CONFIG4L_DEFAULT & _LVP_OFF_4L, _CONFIG5L_DEFAULT, _CONFIG5H_DEFAULT, _CONFIG6L_DEFAULT, _CONFIG6H_DEFAULT, _CONFIG7L_DEFAULT, _CONFIG7H_DEFAULT); #pragma romdata int i; int distance; void main(void) { int i=0; Initialize_Sonar(); Ping_Sonar(); Hardware_Interrupt_Sonar(); Timer_Interrupt_Sonar(); Get_Sonar_Distance(); OpenUSART (USART_TX_INT_OFF & USART_RX_INT_ON & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_HIGH, 129); // open USART with baud of 9600 while(i<10) { putrsUSART("A"); putrsUSART(distance); putrsUSART("B"); i++; } } |
|
#23
|
||||
|
||||
|
Re: SONAR Sensor Software Driver
Im not sure if im right about this but try this...
I put the whole thing in an endless loop.. Code:
#include <p18f452.h> // version 1.1
#include <usart.h>
#include "sonar.h"
/* Set configuration bits
* - set HS oscillator
* - disable watchdog timer
* - disable low voltage programming
*/
#pragma romdata CONFIG
_CONFIG_DECL(_CONFIG1H_DEFAULT & _OSC_HS_1H,
_CONFIG2L_DEFAULT,
_CONFIG2H_DEFAULT & _WDT_OFF_2H,
_CONFIG3H_DEFAULT,
_CONFIG4L_DEFAULT & _LVP_OFF_4L,
_CONFIG5L_DEFAULT,
_CONFIG5H_DEFAULT,
_CONFIG6L_DEFAULT,
_CONFIG6H_DEFAULT,
_CONFIG7L_DEFAULT,
_CONFIG7H_DEFAULT);
#pragma romdata
int distance;
void main(void)
{
Initialize_Sonar();
while (1) // Endless loop
{
Ping_Sonar();
Hardware_Interrupt_Sonar();
Timer_Interrupt_Sonar();
distance = Get_Sonar_Distance(); // Get distance and update variable
OpenUSART (USART_TX_INT_OFF &
USART_RX_INT_ON &
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_HIGH, 129); // open USART with baud of 9600
putrsUSART("A");
putrsUSART(distance);
putrsUSART("B");
}
}
Good Luck |
|
#24
|
|||||
|
|||||
|
Re: SONAR Sensor Software Driver
I think you may have overlooked this section in the readme:
Quote:
I'm not familiar with your application but give this a shot. Note that I added comments about adding a time delay. It may take up to 50mS for the sonar to find an object. ] Code:
#include <p18f452.h> // version 1.1
#include <usart.h>
#include "sonar.h"
/* Set configuration bits
* - set HS oscillator
* - disable watchdog timer
* - disable low voltage programming
*/
#pragma romdata CONFIG
_CONFIG_DECL(_CONFIG1H_DEFAULT & _OSC_HS_1H,\
_CONFIG2L_DEFAULT,\
_CONFIG2H_DEFAULT & _WDT_OFF_2H,\
_CONFIG3H_DEFAULT,\
_CONFIG4L_DEFAULT & _LVP_OFF_4L,\
_CONFIG5L_DEFAULT,\
_CONFIG5H_DEFAULT,\
_CONFIG6L_DEFAULT,\
_CONFIG6H_DEFAULT,\
_CONFIG7L_DEFAULT,\
_CONFIG7H_DEFAULT);
#pragma romdata
int i;
int distance;
void main(void)
{
int i=0;
Initialize_Sonar();
OpenUSART (USART_TX_INT_OFF &
USART_RX_INT_ON &
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_HIGH, 129); // open USART with baud of 9600
Ping_Sonar();
/* You might want to consider adding a time delay here */
while(i<10)
{
distance = Get_Sonar_Distance();
Ping_Sonar();
putrsUSART("A");
putrsUSART(distance);
putrsUSART("B");
i++;
/* You might want to consider adding a time delay here */
}
}
|
|
#25
|
|||
|
|||
|
Re: SONAR Sensor Software Driver
I've been trying to get this working today on the FRC Robot Controller. I've never programmed interrupts before though, so I'm at a stand-still as to what to do. I think I have the initialization for the pin driven interrupt done correctly, but I'm at a complete loss for how to get the timer working. Any help would be appreciated.
|
|
#26
|
|||||
|
|||||
|
Re: SONAR Sensor Software Driver
I'm assuming you're using MPlab and not EasyC to program your robot. Where did you get your version of the default code? Also does the particular version you are using have a name? For instance, "2007 Default Code from IFIrobotics.com" or "Camera code version 2.0 from kevin.org". A link so I can download the default code would be helpful as well.
|
|
#27
|
|||
|
|||
|
Re: SONAR Sensor Software Driver
Yes, I'm using MPlab to program. I got my default code from kevin.org, it is his camera code version 2.1.
Thanks for your help! |
|
#28
|
|||||
|
|||||
|
Re: SONAR Sensor Software Driver
Quote:
Code:
else if (PIR2bits.TMR3IF && PIE2bits.TMR3IE) // timer 3 interrupt?
{
PIR2bits.TMR3IF = 0;
Timer_Interrupt_Sonar(); // Call SONAR Timer Interrupt Handler
}
else if (INTCON3bits.INT2IF && INTCON3bits.INT2IE) // external interrupt 1?
{
INTCON3bits.INT2IF = 0;
Hardware_Interrupt_Sonar(); // Call SONAR hardware interrupt handler
}
|
|
#29
|
|||
|
|||
|
Re: SONAR Sensor Software Driver
oooh I think it may be that when I added your code to InterruptHandlerLow() I didn't reset the interrupt flag within the two "else if" statements. I'll add that tonight and see if it works. Thanks!
|
|
#30
|
|||
|
|||
|
Re: SONAR Sensor Software Driver
Hey guys,
Version 0.3 of this software DOES NOT work with Kevin Watson's PWM driver. I'm guessing its a dependancy on Timer 3. So, dont use it, or fix it. --Tom |
![]() |
| 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 |