pulse simulation


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    Join Date
    May 2006
    Posts
    27

    Default pulse simulation

    hello
    i want simulate a cycle rpm sensor for automotive.
    http://www.geea.org/IMG/swf/capteur_vitesse_6.swf

    the frequency must be able.
    i ve test this code (!!! it s not the same cycle of the picture)
    ' _!-!_!-!__!--!_!-!_!-!

    ' pic16F877

    ' Variable
    W0 var word
    W1 var word
    i var byte
    up var PORTB.4
    dn var PORTB.5
    w0=0
    i=0
    'DN Define frequency down button
    'UP Define frequency up button
    PO con 3 ' Define pulse output pin

    low PO ' Initialize output polarity
    inc:
    If (up = 1) Or (W0 = 10000) Then decr ' Increment freq on button
    W0 = W0 + 10

    decr:
    If (dn = 1) Or (W0 = 0)Then pulse ' Decrement freq on button
    W0 = W0 - 10

    pulse:
    for i =1 to 38
    Pulsout 3,W0 ' Generate pulse
    Pause W0/100 ' Intra-pulse delay
    next i
    Pulsout 3,W0
    W1=W0*2
    Pause W1/100
    Pulsout 3,W1

    Goto inc ' Forever

    this code is ok but not optimized with button
    how do? use pulsout or pwm?

    thank
    Attached Images Attached Images   

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Lightbulb Darrel instant interrupts ... of course !!!

    Hi, Nicolas

    Use DT interrupts !!! ... it's not so difficult to use.

    http://www.picbasic.co.uk/forum/showthread.php?t=3251

    or a little trick I discovered :

    insert " DEFINE INTHAND _INC" at the top of the program ... This places a "GOTO _INC" at location 00004 of the ASM program.

    Now trim the interrupt register ( INTCON) to allow an " interrupt on PortB Change "

    Place a correct preset value for W0 ... 0 is not a good value !!! ( in "decr:" nor !!! )

    Place a "GOTO PULSE " before "inc"

    Think to re-enable interrupts, placing " INTCON.7 = 1" just past "pulse" label

    last, change "GOTO inc" to "GOTO pulse"

    That should go at first...

    Next step will be to use BUTTON instead of IF-THEN ... just to use the Auto-repeat feature ...


    One more step ...

    Have a look to Motorola ( yessss ... Freescale !!! ) "TPUPN xx" Application Notes ...

    really Great !!!

    http://www.bgsoflex.com/megasquirt.html


    Alain
    Last edited by Acetronics2; - 13th August 2006 at 15:23.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    May 2006
    Posts
    27


    Did you find this post helpful? Yes | No

    Default pulse simulation

    how place a "GOTO _INC" in microcode studio.
    interrupt register ( INTCON) to allow an " interrupt on PortB : INTCON=00001000 , it s ok?
    thank

  4. #4
    Join Date
    May 2006
    Posts
    27


    Did you find this post helpful? Yes | No

    Default pulse simulation

    if i use
    ASM
    GOTO_INC
    ENDASM
    it 's ok?

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default Noooooooooo....

    and how to place it in location 4 ????

    D.E.F.I.N.E. !!!!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    May 2006
    Posts
    27


    Did you find this post helpful? Yes | No

    Unhappy pulse simulation

    sorry bur i dont understand how use interrupt on a port.
    i m bad

Similar Threads

  1. 2 Beam Optical Pulse Generator
    By WOZZY-2010 in forum Schematics
    Replies: 8
    Last Post: - 6th April 2010, 04:03
  2. Pulse Capture and byte building
    By boroko in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st July 2009, 01:59
  3. Single digit 7 Seg LED clock - PIC16F88
    By thirsty in forum Code Examples
    Replies: 4
    Last Post: - 17th July 2009, 08:42
  4. Replies: 3
    Last Post: - 13th September 2008, 17:40
  5. Pulse Frequency Multiplication
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st August 2005, 10:39

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