serial communication time


Closed Thread
Results 1 to 28 of 28

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Mugelpower View Post
    my LCD is only for controlling the principal of transmission.
    Loses something in the translation here

    1. : getting Input, storing freq in VAR "CNT" and sending out with Debug
    What INPUT?

    2. : taking the VAR "CNT" with Debugin, calculating a Delay and sending out a 1ms Pulse after RB0 gets High + Delay time.
    What does CNT represent? What is the delay for? Where does RB0 get a high pulse from?

    The delay has to include the PICs intern calculation delay.
    Which at times can be a variable delay due to the way math is done with PBP.

    thats why I need transmission speed
    Transmission speed? RPM of the input shaft? output shaft? MPH? KPH? GPM?

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


    Did you find this post helpful? Yes | No

    Wink Input Delay and my other new friends

    Hi Skimask,

    I try to answer with a minimum of translation losses....(Reminds me of principal Skinner, hehe)

    1. Input is a 50% Duty cylce with 1/2 frequency of the magnetic/Hall pickup from the distributor because the Duty cycle varies sometimes with the frequency. So I took a 4027 to cut it in Half and got a nice constant 50/50 square signal. Makes 6Hz up to 300Hz. Thats my 1/2 frequency range. Threfore I have to multiply my VAR CNT by 2 to get the real freq, If I want to.Now I can handle this Input(my Variable CNT) mathematically like i want or need.
    The easy thing is: we need this Input Variable only changed every 0.1 sec. thats fast enough.When the engine runs with constant speed for example for 1 minute we dont even need to change the Input variable because theres no difference.Thats the task of my first pic including sendig (by DEBUG)this Variable or the calculatet Delay (variable name and task is the same here) to PIC #2.

    2. PIC #2 reacts when the RB0 pin shows a change fromlow to high. thats the same Input signal from our Distributor but the original frequency . The signal has to be changed into a square signal by a comparator or Schmitt-trigger.But here we need the precise starting point. After that a delay (Stored in the Var DELAY and calculated before depending on the input VAR CNT ) is startet ("ON Interrupt "or an asminterrupt handler needed here )
    to get the right time for the Ignition action. This could be in the simplest way 10° befor OT at low speeds and 40° at high engine speeds (rotations per minute, Input signal fromthe distributor stored in VAR CNT). As you can see, even if you want a constant ignition action say 20° before OT the time of the delay after the delay starting signal (50° before OT = constant) the delay is reciprocal to the engine speed and reciprocal to VAR CNT.

    3. Ignition action is a simple Output signal from the pin we choose (here PORTB.7) of 1ms high. This is send to the ignition coil driver wich switches 10Amps and 12Volts.The End of the 1ms is The Ignition timing point.

    4.Due to PICs internal and software delays we need a correction factor for the VAR DELAY depending on Engine speed. Once we got this I´m happy. maybe in a list with just 10 points from low engine speeds to high speeds. Cranking is another thing because theres no constant cranking speed so the VAR DELAY has to be calculated for every cranking speed.
    From 1000/min up we need only 10 different pre-ignition values, maybe 1000-1500,1500-2000 and so on. BUT: VAR DELAY would be different for a constant ignition timing for 1000/min or 1500/min.

    If I can make anything more clear I will do so.

    Transmission speed: The calculated VAR DELAY has to be sent from PIC1 to PIC2 (The ignition action PIC) .
    BUT I put in a PIC#3 thats just for control purposes to check the VAR DELAY thats sent.
    At the time theres no calculation OF The VAR DELAY and I´m sending just the "rough data VAR CNT". Calulation code is implemented after the transmission works.

    Now: How will I send a WORD Variable fromPIC to PIC at Engine speeds of 8000/min? just 0.2 ms left. Or its done in the background with the famous USART registers which I try to use with DEBUG .......

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Mugelpower View Post
    Hi Skimask,
    1. ..........Now I can handle this Input(my Variable CNT) mathematically like i want or need.
    Multiplying by two is the same as a LEFT SHIFT, which only takes a single clock cycle on a byte, about 3-4 cycles on a word

    4.Due to PICs internal and software delays we need a correction factor for the VAR DELAY depending on Engine speed. Once we got this I´m happy. maybe in a list with just 10 points from low engine speeds to high speeds. Cranking is another thing because theres no constant cranking speed so the VAR DELAY has to be calculated for every cranking speed.
    From 1000/min up we need only 10 different pre-ignition values, maybe 1000-1500,1500-2000 and so on. BUT: VAR DELAY would be different for a constant ignition timing for 1000/min or 1500/min.
    Learn how to use the hardware timers and you won't have a problem with the PICs internal software delays. Let the timers run on their own and interrupt the main program to trigger whatever you need triggered.

    Now: How will I send a WORD Variable fromPIC to PIC at Engine speeds of 8000/min? just 0.2 ms left. Or its done in the background with the famous USART registers which I try to use with DEBUG .......
    DEBUG doesn't use the internal USART, it too is a software bit-banged command.
    8000 RPM = 133.3 RPS...
    A word = 16 bits, 2 bytes = 8 bits x 2 + start/stop bits = 20 bits for each word.
    134 (133.3 rounded up) x 20 bits = 2,680 baud, use 9600 baud so it's a standard baud rate.
    Each word takes 2.083 ms, 134 times per second, 278ms used by the serial port per second at maximum RPM, leaves you with 722 ms to play with total in between words, 5.38ms on average between each word sent.
    But, cut each of those numbers by 1/4 for an 8 cyl engine, still leaves you with 1.34ms between each ignition event.

    Completely software driven is NOT the way to go with this. You NEED to learn how to use the hardware timers/interrupts, etc. to get this done with blowing holes in pistons.

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


    Did you find this post helpful? Yes | No

    Default Hardware Timers

    Thanks Skimask,

    thats exactly what I was afraid of. OK it took one year to get me this far maybe I can make the whole thing go in another 6 months.....

    I know Darrel Taylor got some interesting asm routines for interrupts. That may be a starting point.

    AAAARRRGGGGHHH!

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Mugelpower View Post
    Thanks Skimask,
    thats exactly what I was afraid of. OK it took one year to get me this far maybe I can make the whole thing go in another 6 months.....
    I know Darrel Taylor got some interesting asm routines for interrupts. That may be a starting point.
    AAAARRRGGGGHHH!
    Afraid of!!!???!!!???
    Don't be afraid... As long as you don't have whatever it is connected to a fuel burning 'thing' of some sort, what's the worst that could possibly happen?

    The learning curve is steep, but once you're over the intial hump, everything else falls into place...for the most part

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