Take a look at this page,
http://www.parallax.com/dl/docs/prod...tance28015.pdf
Regards
Mark
Take a look at this page,
http://www.parallax.com/dl/docs/prod...tance28015.pdf
Regards
Mark
You need to set the mode and distance threshold by sending the correct command serially to the sensor. You want 9600 baud, no parity, one stop bit. The SEROUT section of the PBP manual will tell you how to do this, and the PDF you provided in your OP will tell you what commands you need to send.
The best way to get help here is to try it, and if what you try doesn't work, post the code here and i'm sure lots of help will be forthcoming.
Last edited by Kamikaze47; - 20th June 2010 at 07:32.
"I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams
Here goes my code for 16F676. Used this IC because I can program it in PICKIT2 & also I have jumpered my sensor around it.
1) How do you calculate the SUM? any example pleaseCode:Include "modedefs.bas" DEFINE NO_CLRWDT 1 DEFINE OSC 4 ' OSCCON defaults to 4MHz on reset DEFINE OSCCAL_1K 1 @ __Config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _BODEN & _CP & _CPD PAUSE 50 Tx Var PortA.1 Rx Var PortA.0 power var PortC.1 TRISA = %000001 TRISC = %000001 CMCON = 7 ANSEL = 0 OPTION_REG = %10000111 ' RAPU = off, PS 1:256 to TMR0 PORTA=0 PORTC=0 ' setup iZCD to interrupt on change INTCON = 0 ; PortC.0 = PWM Receive ; ; ; ; ; PortC.1 = Power_On ; ; ; ; PortA.0 = Receive Pin ; ; ; ; PortA.1 = Transmit Pin ; ; ; ; PortA.2=Trigger Pin main: High power pause 100 Serout Tx, N9600, ["0x44+0x00+160+ ???"] ; To set lower threshold distance to appx 3 meters. What should be the SUM & how do you calculate it? Serout Tx, N9600, ["0x44+0x01+250+ ???"] ; To set upper threshold distance to appx 5 meters Serout Tx, N9600, ["0x44+0x02+0xaa+ ???"] ; To set operation mode to autonomous mode if PortA.2=0 then High PortC.2 ; led 1 else high PortC.5 ; led 2 endif goto main end
Once I get to the next point, I will update here if I get stuck. Thanks
try something like this (taking your 1st serout line as an example):
Serout Tx, N9600, [$44,$00,$A0,$E4]
$A0 is just 160 in hex.
To work out the sum: $44+$00+$A0=$E4
If the sum is bigger than $FF then you take just the lower byte. e.g. if the sum came to $01A2, then you just use $A2.
"I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams
Hi, I tried this:
And also this:Code:main1: High power Pause 100 Serout Tx, N9600, ["0x44+0x00+0xA0+0xE4"] ;To set lower threshold distance to appx 3 meters Pause 100 Serout Tx, N9600, ["0x44+0x01+0xD1+0xFE"] ;To set upper threshold distance to appx 5 meters Pause 100 Serout Tx, N9600, ["0x44+0x02+0xaa+0xF0"] ; To set operation mode to autonomous mode main: if PortA.2=1 then high PortC.2 else toggle PortC.5 endif pause 50 goto main end
but no luck - any advise?Code:Serout Tx, N9600, [$44,$00,$A0,$E4] ;To set lower threshold distance to appx 3 meters Pause 100 Serout Tx, N9600, [$44,$01,$D1,$FE] ;To set upper threshold distance to appx 5 meters Pause 100 Serout Tx, N9600, [$44,$02,$aa,$F0] ;To set operation mode to autonomous mode
Hi,
The question is ...
did you use a RS232 chip on YOUR board ??? ( like in the datasheet scheme )
more ...
Could you , please , attach YOUR scheme ???
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Hi, here is my hardware photo, just my sensor jumpered to my PICKIT2 in the following configuration:
; PortC.0 = PWM Receive ; ; ; ; ; PortA.0 = Receive Pin ; ; ; ; PortA.1 = Transmit Pin ; ; ; ; PortA.2=Trigger Pin
PWR_ON is directly connected to 5V on the PICKIT2
Also I am using TTL I/O, I have arranged the jumpers accordingly.
Bookmarks