serial communication time


Closed Thread
Results 1 to 28 of 28

Hybrid View

  1. #1
    Join Date
    Jan 2008
    Location
    Selm, Germany
    Posts
    116

    Question serial communication time

    Hi Guys & Girls!

    my serial data transfer between two pics 16F628A works for starters. BUT: in my program theres at high engine speeds only 0.4 ms or less to send the data from one pic to another.
    The action my receiving PIC makes is triggered by an external interrupt that means after that theres hardly time to get the data. On the other hand it doesn´t matter if it misses the data for a few cycles because at high engine speeds the data update could wait . I think it is sufficient to transmit that data every 0.1 sec.

    Yes: baud rate 9600, 4 Mhz crystal, data: one word. Input Frequency 3 Hz - 600 Hz

    Does this work?

    on Interrupt goto ISR

    main:
    serin2 blah blah

    isr:
    pulsout 7, 50, 1

    something like that




    I will show the program when i´m back home

    AH: one BIG Problem too:
    when using a 2-channel oscilloscope it shows a Delay between input signal and output signal
    of about 0.5 ms more than expected. this makes the whole action too slow!!!
    Maximum accepted delay between input trigger and output pulseout could be 0.1 ms.

    is the only way to handle those timecritical events by assembler? please say no....

    Mugel

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Mugelpower View Post
    only 0.4 ms or less to send the data from one pic
    I think it is sufficient to transmit that data every 0.1 sec.
    9600 baud = 9600 bits per second
    1 second / 9600 = .1046 ms per bit
    1 byte = 8 bits + start bit + stop bit = 10.5 bits
    10.5 x .1046 = 1.0983ms per single data byte = 910.498 bytes per second MAX

    The math doesn't work...

  3. #3
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Default

    Mugel,

    It is not clear to me what you are trying to do. If you use the Hardware USART, you can send and receive in the "background" and keep your programs doing what they need to do.

    Further, are you using RS232? Why Pulsout shown in the ISR?

    More details = more help
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  4. #4
    Join Date
    Jan 2008
    Location
    Selm, Germany
    Posts
    116


    Did you find this post helpful? Yes | No

    Default USART please but how to use ?

    oha,
    1 ms for Data transfer is way too much. And recieving data (no sending!) in the background seems the only thing to do
    '************************************************* *******************************************
    ' 16F628A 10 Mhz crystal 15pf capacitors
    ' damn program should blink an LED every time a pulse goes into RB.0
    ' later a value should be serial loaded and set a delay before the blink pulse
    '************************************************* *******************************************

    '
    ' DEFINITIONS


    DEFINE OSC 10
    CMCON=%00000111
    inputData var word ' variable to receive data into
    pulseWidthVar var word



    ' START OF MAIN PROGRAM
    '
    CMCON = 7 ' RA0-RA3 are digital I/O
    TRISA = 0 ' PORT A is output
    TRISB = 1 ' RB0 is Input others output


    on interrupt goto ISr

    INTCON.1 = 0 ; Clear External Interrupt Flag
    INTCON.4 = 1 ; Enable External Interrupt



    main:
    Portb.7 = 0

    serin2 portB.0,16468, [inputData] 'for the future to load a value
    pulseWidthVar = inputData

    goto main

    disable

    ISR:

    portb.7 = 1 'blink LED 0.02 sec one time when RB.0 goes high
    pauseus 500
    portb.7 = 0
    INTCON.1 = 0 ; Clear External Interrupt Flag
    RESUME 'resume main program
    Enable 'Enable interrupts

    END ' End of program

    In my picbasic pro book from Dogan Ibrahim it says " USART is very complicated"
    and that did not encourage me.
    Because I use only 16F628A , maybe with 10Mhz that should do.

    How could I use the Usart . I think those 16F628A have one....

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Then throw that book away

    HSERIN is one, method. Reading the USART register is another one, using it's interrupt is a third one.

    Now you have to determine which process is much important. If you really have a need for speed for your interrupt, you may need to switch to Darrel's Instant-Interrupt. Not enough? ... use ASM interrupts.

    @10MHz, you could use a 57600 baud communication without too much problem.

    Not sure of your whole requirement... but i would use USART interrupt for that... i'll read it again.. just to make sure i didn't miss the main idea.
    Last edited by mister_e; - 30th January 2008 at 21:19.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Jan 2008
    Location
    Selm, Germany
    Posts
    116


    Did you find this post helpful? Yes | No

    Default Baud rate/Usart speed

    Hi Mister_E,

    you helped me a lot last time I remember. OK. Principle is an Ignition that gets an input signal (raising edge on Portb.7) , starts an interrupt and after a "Delay" it sends a 0.5 ms High to an Output. After that it recieves serial the actual variable "Delay" which is a byte and is ready for the next interrupt.
    This all in about 1.5 ms at maximum speed.
    I have a second PIC that measures pulse width and calulates "Delay" so I save Time and code for the time critical Interrupt.

    But the Delay caused by the PBP program including the serial communication is about 1ms thats way too much.

Similar Threads

  1. Replies: 5
    Last Post: - 20th March 2006, 01:34
  2. Bootloader,MCSP and Serial communication
    By surfer0815 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd March 2006, 10:52
  3. Serial Communication using 12F629
    By charudatt in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th March 2005, 04:24
  4. Serial communication PIC to PIC help.
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th January 2005, 15:45
  5. Replies: 8
    Last Post: - 11th November 2004, 20:08

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