View Single Post
  #23   Spotlight this post!  
Unread 30-09-2006, 00:01
bear24rw's Avatar
bear24rw bear24rw is offline
Team 11 Programming Captain
AKA: Max T
FRC #0011 (MORT)
Team Role: Programmer
 
Join Date: Sep 2005
Rookie Year: 2005
Location: Flanders, NJ
Posts: 385
bear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to behold
Send a message via AIM to bear24rw
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");

   }
}
Try that and see if it works...

Good Luck