Ultrasonic sensor, serial communication.


Results 1 to 3 of 3

Threaded View

  1. #1

    Default Ultrasonic sensor, serial communication.

    Hi Folks,
    I need a little help with this task. I want to read data from Ultrasonic distance meter which put out every 100ms serial data.
    The protocol is here:
    Name:  Protocol.jpg
Views: 294
Size:  148.0 KB
    The captured data looks like:
    Name:  Data_Packet.jpg
Views: 354
Size:  58.9 KB
    My program trying to capture this data looks like:
    Code:
    #CONFIG
      __config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_ON & _FCMEN_ON
      __config _CONFIG2, _WRT_OFF & _PLLEN_ON & _STVREN_ON & _BORV_19 & _LVP_OFF
    #ENDCONFIG
    
    ;MCU PIC 12F1840
    
    DEFINE OSC 4        ; Use internal clock 4MHz 
    OSCCON  = %01101010 ; 4 MHz internal
    OSCTUNE	= %00000000	; Internal osc tunning
    
    TRISA = %100000     ; RA.5 input rest output
    ANSELA = %00000  
    OPTION_REG.7=1      ; disable internal pull-ups
    APFCON = %10001100 
    
    string var byte[16]
    
    ' Set receive register to receiver enabled
    DEFINE HSER_RCSTA 90h 
    ' Set transmit register to transmitter enabled
    DEFINE HSER_TXSTA 24h                             
    DEFINE HSER_BAUD 9600 
    
    clear
    
    start:
    
    hSerin 100,start,[wait ($ff),str string\16]
    
    pause 100
           
    HSEROUT [hex string,13,10]
    
    pause 500
    
    goto start
    obviously it doesn't work because my poor programming skills.
    I searched the forum to find something to point me how to capture these data but no success.
    Can someone point me how to do that?
    Thanks,
    Louis
    Last edited by louislouis; - 26th September 2020 at 16:44.

Similar Threads

  1. Need help setting up my ultrasonic distance sensor
    By Megahertz in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 26th June 2010, 14:06
  2. Ultrasonic distance sensor with PIC16F84A
    By MrRoboto in forum mel PIC BASIC
    Replies: 3
    Last Post: - 29th June 2009, 09:01
  3. Water Level Detection using Ultrasonic Sensor
    By Balachandar in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th November 2007, 04:59
  4. sensor ultrasonic 8051&PIC
    By hd_uni_pro in forum Schematics
    Replies: 1
    Last Post: - 13th September 2006, 12:58
  5. ultrasonic sensor
    By PoTeToJB in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 9th May 2006, 20:26

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts