PIC - receive data while pulsing pin from low to high and from high to low


Results 1 to 11 of 11

Threaded View

  1. #1
    Join Date
    Apr 2014
    Posts
    4

    Default PIC - receive data while pulsing pin from low to high and from high to low

    Hello

    The problem I present here is a little weard because I could not find any documentation for anybody else needing this.

    My device must measure spectrography data while pulsing a high power light source. So the code looks like this:

    start
    - high PORTA.0 pin to start laser
    - read measurements & output to PORTC
    - pause x
    - low PORTA.0 pin to turn off laser
    - read measurements & output to PORTD
    - pause x
    - goto start.

    or some PBP sample code:

    define OSC 20
    result var byte
    pause_time var word : pause_time = 3000 ; (3.000 pulses per second)
    period_ms var byte
    period_us var byte

    main:
    high porta.0
    gosub ADC_read
    portc = result
    gosub pause_for_period_of_time
    low porta.0
    gosub adc_read
    portD = result
    gosub pause_for_period_of_time
    goto main

    adc_read:
    ; read stuff from some high speed soviet golden capsule military aircraft chip connected to 8 bit PORTB
    ; high portE to enable chip, read the portB, low portE to disable the chip
    return

    pause_for_period_of_time:
    period_ms = pause_time.byte1
    period_us = pause_time.byte0

    ; pause the program so I can totaly get the frequency I specified at beginning (3.000Hz or 4.231Hz or something between 1Hz and 10Hz with three digits after decimal point)

    pause [asylum/madhouse formula without floating point unit]

    return


    The problem is I must somehow redefine "pulsout" function so I can take measurements immediately after the pin is high, and again to take measurements after the pin is low. Or somehow find a formula to determine the period formula from the given frequency by using digital logic, as this pic does not have a FPU. Or to get in contact with Jedi Master of Assembler.

    My XTAL frequency is 20MHz to be able to work with microseconds.

    the program works, I can gather data but I did something like this:
    pause for sine fraction of period in ms
    for i=0 to 256 : pause "i" times the period in US : next i.
    This is garbage but at least I have a variable pulse and I can do measurements between pin going from low to high and from high to low.

    Any ideas will be welcomed.
    Last edited by skaarj; - 13th April 2014 at 18:47.

Similar Threads

  1. suggestions on reading a pulsing vehicle speed sensor?
    By droptail in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 23rd June 2010, 17:27
  2. How to receive stream of bytes using PIC USART
    By unifoxz in forum mel PIC BASIC Pro
    Replies: 34
    Last Post: - 20th June 2009, 10:38
  3. Receive serial data
    By ruijc in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 7th August 2008, 22:52
  4. send and receive data using pic 16f84a
    By PoTeToJB in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th February 2006, 20:12
  5. send and receive data using pic 16f84a
    By PoTeToJB in forum Serial
    Replies: 1
    Last Post: - 25th February 2006, 14:47

Members who have read this thread : 0

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