Can't get Parallax PING))) to work.
GroovyChili
Posts: 1
Hi, I'm a beginner in electronics, and I have recently hit a problem.
I bought the PING))) ultrasonic sensor, and I can't get it to work.
I have googled around the web and tried many different things, but nothing works. I'm using a PIC16F628 with the PING))) connected to pin nr. 4, and an LED connected to pin nr. 0.
I'm just trying to get the LED to lit up when it's getting a response from the PING))) and I think I've connected everything the right way, from the hardware's point of view, because when I replace the PING))) I/O pin (nr. 4 in my case) with another power source, the LED at pin nr. 0 lits up.
And the Activity LED on the sensor just lits up one tiny tiny moment, barely noticeable, when I'm powering on the circuit for the first time.
Is there any of you who have any experience with the PING))), and can help me?
Here's my code;
I bought the PING))) ultrasonic sensor, and I can't get it to work.
I have googled around the web and tried many different things, but nothing works. I'm using a PIC16F628 with the PING))) connected to pin nr. 4, and an LED connected to pin nr. 0.
I'm just trying to get the LED to lit up when it's getting a response from the PING))) and I think I've connected everything the right way, from the hardware's point of view, because when I replace the PING))) I/O pin (nr. 4 in my case) with another power source, the LED at pin nr. 0 lits up.
And the Activity LED on the sensor just lits up one tiny tiny moment, barely noticeable, when I'm powering on the circuit for the first time.
Is there any of you who have any experience with the PING))), and can help me?
Here's my code;
;--------Initialize assembler LIST P=PIC16F628 ; Telling the assembler what kind of microcontroller we are using #include "P16f628.inc" ; Converting words to hex. values __config 0x3f18 ; Settings, such as watchdog, internal timers, etc. All turned off ;---------Macros bank0 macro bcf STATUS,RP1 bcf STATUS,RP0 ; BANK0 (Data Memory) endm bank1 macro bcf STATUS,RP1 bsf STATUS,RP0 ; BANK1 (Data Memory) endm bank2 macro bsf STATUS,RP1 bcf STATUS,RP0 ; BANK2 (Data Memory) endm bank3 macro bsf STATUS,RP1 bsf STATUS,RP0 ; BANK3 (Data Memory) endm ;---------Registers cblock 0x20 ; Nothing for now... endc ;---------Program memory org 0x00 ; The beginning of the program goto Start org 0x04 ; Interrupt Service Routine ; Nothing for now.... ;############## ;----------Main Start ; Starting by setting all pins as outputs bank1 movlw b'00000000' ; Pin 5 needs to be an input pin movwf TRISA ; Set the inputs and outputs of port A movlw b'00000000' ; All outputs movwf TRISB ; Set the inputs and outputs of port B bank0 goto SendSIG PingOut ; Make pin nr. 4 an output pin for sending trigger signal bank1 movlw b'00000000' movwf TRISA bank0 return PingIn ; Make pin nr. 4 an input pin for retriving an echo signal bank1 movlw b'00010000' movwf TRISA bank0 return SendSIG call PingOut bsf PORTA,4 ; Trigger signal, 5uS long call Delay5uS bcf PORTA,4 goto ScanningSIG ; Trigger signal, now sent. Start listning for echo signal ScanningSIG call PingIn ScanningLoop btfsc PORTA,4 ; Check I/O pin bsf PORTA,0 ; Light LED goto ScanningLoop ;-----Delays--------------------------------------- Delay5uS ; A delay lasting for 5 micro seconds, including the "call" goto $+1 return ;-----End------------------------------------------ Finish end ; End of program
Comments
banksel PORTA
for instance.
You are setting PORTA to all outputs with
movlw b'00000000'
movwf TRISA
There are lots of problems with the code, as it's written. You'd be better off with a 16F88 as it has in-circuit debugging.