|
|
View previous topic :: View next topic |
Author |
Message |
Trefor Guest
|
Polaroid Ultrasonic Sensor |
Posted: Mon Mar 10, 2003 4:28 am |
|
|
Has anybody come accross any CCS C code for driving the Polaroid ultrasonic 6500 ranging board? Any help with this will be much appreciated.
Trefor
___________________________
This message was ported from CCS's old forum
Original Post ID: 12485 |
|
|
Paladdin Guest
|
Re: Polaroid Ultrasonic Sensor |
Posted: Mon Mar 10, 2003 5:02 am |
|
|
:=Has anybody come accross any CCS C code for driving the Polaroid ultrasonic 6500 ranging board? Any help with this will be much appreciated.
:=Trefor
Sure, but it was long ago... Programming style is rude, although enough to catch the point. Use it at your own risk :)
echo_time array returns up to four consecutive echo responses from the receiver, for multitarget measurements.
Good luck!
Paladdin
<pre>
/*************************************************************************/
/* RANGING.C */
/*************************************************************************/
#include <16C63A.H>
#define ECHO PIN_C2
#define INIT PIN_A1
#define BLNK PIN_A0
#define START_MSG '#'
#define END_MSG '*'
#define MY_ID 'A'
#use fast_io(A)
#use delay(clock=4000000)
#use rs232(baud=1200,xmit=PIN_C6,rcv=PIN_C7,brgh1ok)
void check_range(void) ;
void isr_rda(void) ;
void isr_ccp1(void) ;
void csum_gen(char *s) ;
short flag = FALSE ;
long echo_time[4] ;
byte echo_counter ;
byte data_in[3] ;
#int_rda
void isr_rda(void)
{
data_in[2] = data_in[1] ; //Buffer 'rotativo'
data_in[1] = data_in[0] ;
data_in[0] = getc() ;
if(data_in[2] == START_MSG) //Si es para mi, reacciona
if(data_in[0] == END_MSG)
if(data_in[1] == MY_ID)
flag = TRUE ;
}
#int_ccp1
void isr_ccp1(void)
{
echo_time[echo_counter++] = CCP_1 ;
if(echo_counter > 4)
echo_counter = 3 ;
output_high(BLNK) ;
delay_us(440) ;
output_low(BLNK) ;
}
void check_range(void)
{
byte c = 0 ;
echo_counter = 0 ;
do
{
set_timer1(0) ;
output_high(INIT) ;
delay_ms(199) ;
output_low(INIT) ;
delay_ms(100) ;
} while((c++ < 5) && (echo_time[1] == 0)) ;
printf("#\%lu,\%lu,\%lu,\%lu,\%i*\r\n", echo_time[0],echo_time[1],
echo_time[2],echo_time[3], c) ;
for(c = 0; c < 4; c++)
echo_time[c] = 0 ;
}
void main(void)
{
byte c ;
set_tris_a(0x00) ;
for(c = 0; c < 4; c++)
echo_time[c] = 0 ; // Variable init
data_in[0] = '\0' ;
setup_ccp1(CCP_CAPTURE_RE) ; // Configure CCP1 to capture rise
setup_timer_1(T1_INTERNAL) ; // Start timer 1
enable_interrupts(INT_RDA) ;
enable_interrupts(INT_CCP1) ;
enable_interrupts(GLOBAL) ;
output_low(INIT) ; //Assure correct power-up
output_low(BLNK) ;
delay_ms(100) ;
while(TRUE)
if(flag)
{
flag = FALSE ;
check_range() ;
}
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 12488 |
|
|
Chromeboy Guest
|
Re: Polaroid Ultrasonic Sensor |
Posted: Tue Nov 04, 2003 8:56 am |
|
|
Trefor wrote: | Has anybody come accross any CCS C code for driving the Polaroid ultrasonic 6500 ranging board? Any help with this will be much appreciated.
Trefor
___________________________
This message was ported from CCS's old forum
Original Post ID: 12485 |
Hi Trefor, I'm working with Polaroid modules too.
My email is fairchild@hotmail.com, so if you want to contact me to tell you everything I know. |
|
|
Chromeboy Guest
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|