serial communication time


Closed Thread
Results 1 to 28 of 28

Hybrid View

  1. #1
    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....

  2. #2
    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.

  3. #3
    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.

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


    Did you find this post helpful? Yes | No

    Default Raising edge on Port

    I meant Portb.0 as input of course...

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


    Did you find this post helpful? Yes | No

    Default

    Mugel,

    How is it coming?

    I am still not clear what you are trying to do.

    I also am not clear on what is causing your 1mS latency ... is it the actual send time of the serial data?

    To me, it looks like you could use the USART on both the send program and the receive program and never really have to wait.

    Here is MELABS example program on USARTS

    http://www.melabs.com/resources/samples/pbp/usart.bas

    Once the USART is configured then sending data is as easy as

    TXREG = DATA1 ; where DATA1 is your Byte variable to send, your program continues on and the data is sent in the background

    And receiving DATA is as easy as

    DATA2 = RCREG ; where DATA2 is your Byte variable, your program can be doing other things while the data is coming in. Once the byte has been received in the background, your program can grab the data like this.

    It looks like to me you could do what I think you want to do with the USART and without Interrupts.

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

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


    Did you find this post helpful? Yes | No

    Default Precise Problem definition

    Ok. To make it clear I want This:

    http://www.sportdevices.com/ignition/ignition.htm

    but want to do that myself AND by using Picbasic Pro (Full version 2.5). I donīt want to write Asm because Iīm unable to do so.
    Although I know this could be done with 1 simple PIC Iīm willing to take 2 of them or 3 if necessary for Picbasic Pros sake.

    Those smart Guys that programmed ignitions donīt even give you the ASM code, only Hex.

    Further I need this circuit and software etc. modified for different engines . For that I bought the PBP software.

    I know You Guys could programm something like I need in 5 minutes or less but I need something in simple structure so I can handle the software and necessary changes.

    My actual problem is the fact that my serial pic to pic communication is far to slow AND the com routine seems to delay the interrupt action by about 1ms which is inacceptable.

    Hope this made everything clear.

    thanks for your interest.

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    In my mind...short and simple answers...

    High speed PIC's could handle the work...it's all about the guy behind the keyboard
    High speed anything don't work too well in the automotive environment...it's all about the guy designing the filters.
    9600 baud...not so much...as stated before. You want data transmitted every .4ms . Not going to happen at 9600 baud, I don't care how you program it, unless you want to start dropping bits and sending 3 bits instead of 8. Must go with much higher speed as stated earlier.
    You don't want to learn or write in assembly? Well, that's probably not going to happen either. PBP's built-in 'ON INTERRUPT' is designed in such a way that latency is practically unavoidable in a lot of situations. Using DT's Fast Interrupts isn't that hard, and yes, it does require you to learn a little bit about ASM, not much though.

    In my mind, any serious ignition work is best suited for a different processor, maybe a dsPIC...not that a PIC couldn't handle it...with the right programmer behind the keyboard. Personally, I think you're playing with matches in a gas fume filled room. One ignition event just a bit early, there goes the intake manifold, a whole load of events a bit early, now you've got 8 pistons that could double as doughnuts and con-rods that could do double duty as horseshoes.

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