Old and beyond help ?


Closed Thread
Results 1 to 40 of 47

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Different way of doing your code (may have messed some of it up along the way)
    Also, not sure about the '887 and it's watchdog timer, so added a chunk to your DEVICE statement to turn it off.
    Your code wasn't badly written, just a bit lengthy and could have stood to be shortened up a bit, things combined here and there...
    Code:
    '***********CHRISTMAS STAR PROGRAM FOR OPERATING  *************
    '**********A 16 ARM STAR WITH 8 LEDS ON EACH ARM  *************
    '******ARMS CONNECTED TO PORTS A AND C  AND EACH "RING"  ******
    '***************CONNECTED TO A PIN OF PORT D ******************
    '************AUTHOR DAVID MARKS DEC 2008 ***********************8
    @ DEVICE pic16f887,intrc_osc_noclkout,wdt_off
    ansel=0 : delay var word : fastflash var word : temp var byte
    fastflash = 150
    PORTD=0 : PORTA=0 : PORTC=0 : TRISD=0 : TRISA=0 : TRISC=0
    ring var portd : arma var portc : armb var porta
    loop:
      '********************************************
      'EXPANDING WHITE CIRCLES
      '********************************************
    For delay = 400 to 0 step -25
    	arma = $55 : armb = $55 : gosub ringer
    next delay
    arma = 0 : armb = 0
    '**************************************************
    'EXPANDING RED CIRCLES
    '**************************************************
    For delay = 400 to 0 step -25
    	arma = $aa : armb = $aa : gosub ringer
    next delay
    '************************************************
    'EXPANDING MULTICOLOUR CIRCLES
    '************************************************
    For delay = 400 to 0 step -25
    	arma = $ff : armb = $ff : gosub ringer
    next delay
    '*****************************************************
    'EXPANDING WHITE DISC
    '*****************************************************
    arma=0 : armb=0
    For delay = 400 to 0 step -25
    	arma = $55 : armb = $55 : gosub ringer : ring = 0
    next delay
    '******************************************************
    'flash all white
    '******************************************************
    fOR DELAY = 0 TO 100
    	ring = $ff : pause fastflash : ring = 0 : pause fastflash
    next delay
    '******************************************************
    'EXPANDING RED DISC
    '******************************************************
    arma=0 : armb=0
    For delay = 400 to 0 step -25
    	arma = $aa : armb = $aa : gosub ringer : ring = 0
    NEXT DELAY
    '*********************************************
    'FLASH ALL RED
    '*********************************************
    fOR DELAY = 0 TO 100
    	ring = $ff : pause fastflash : ring = 0 : pause fastflash
    next delay
    '*********************************************
    'EXPANDING MULTICOLOUR DISC
    '*********************************************
    arma=$ff : armb=$ff
    For delay = 400 to 0 step -25
    	gosub ringer : ring = 0
    next delay
    '*******************************************************************
    'flashall
    '*******************************************************************
    arma=$ff : armb=$ff
    For delay = 400 to 0 step -25
    	ring = $ff : pause delay : ring = 0 : Pause delay
    next delay
    For delay = 0 to 100
    	ring = $ff : pause fastflash : ring = 0
    next delay
     '****************************************
     'ROTATE WHITE
     '****************************************
    ring = $ff
    for delay = 400 to 50 step -30 
    	for temp = 0 to 7 step 2
    		arma.0[temp] = 1 : armb.0[temp] = 1
    		pause delay
    		arma.0[temp] = 0 : armb.0[temp] = 0
    	next temp
    next delay
     '*********************************************
     'ROTATE MULTI
     '*********************************************
    ring = $ff
    for delay = 300 to 50 step -10 
    	arma = $83 : armb = $83 : pause delay : arma = 0 : armb = 0
    	pause delay : arma = $06 : armb = $06 : pause delay : arma = 0
    	armb = 0 : arma = $30 : armb = $30 : pause delay : arma = 0
    	armb = 0 : arma = $c0 : armb = $c0 : pause delay : arma = 0 : armb = 0
    	armb = 0
    next delay
    goto loop
    ringer:  for temp = 0 to 7 : ring.0[temp] = 1 : pause delay : ring.0[temp] = 0
    pause delay : next temp : return
    How about that?





    And for all those that have missed it...
    Here's some colons I had to get off my chest
    Code:
    @ DEVICE pic16f887,intrc_osc_noclkout,wdt_off
    ansel=0:delay var word:fastflash var word:temp var byte:fastflash=150:PORTD=0
    porta=0:portc=0:trisd=0:trisa=0:trisc=0:ring var portd:arma var portc
    armb var porta:armb var porta
    loop:  for delay=400 to 0 step -25:arma=$55:armb=$55:gosub ringer:next delay
    arma=0:armb=0:for delay=400 to 0 step -25:arma=$aa:armb=$aa:gosub ringer
    next delay:for delay=400 to 0 step -25:arma=$ff:armb=$ff:gosub ringer
    next delay:arma=0:armb=0:For delay=400 to 0 step -25:arma=$55:armb=$55
    gosub ringer:ring=0:next delay:for delay=0 to 100:ring=$ff:pause fastflash
    ring=0:pause fastflash:next delay:arma=0:armb=0:for delay=400 to 0 step -25
    arma=$aa:armb=$aa:gosub ringer:ring=0:next delay:for delay=0 to 100:ring=$ff
    ring=$ff:pause fastflash:ring=0:pause fastflash:next delay:arma=$ff:armb=$ff
    for delay=400 to 0 step -25:gosub ringer:ring=0:next delay:arma=$ff:armb=$ff
    for delay=400 to 0 step -25:ring=$ff:pause delay:ring=0:pause delay
    next delay:for delay=0 to 100:ring=$ff:pause fastflash:ring=0:next delay
    ring=$ff:for delay=400 to 50 step -30:for temp=0 to 7 step 2:arma.0[temp]=1
    armb.0[temp]=1:pause delay:arma.0[temp]=0:armb.0[temp]=0:next temp:next delay
    ring=$ff:for delay=300 to 50 step -10:arma=$83:armb=$83:pause delay:arma=0
    armb=0:pause delay:arma=6:armb=6:pause delay:arma=0:armb=0:arma=$30:armb=$30
    pause delay:arma=0:armb=0:arma=$c0:armb=$c0:pause delay:arma=0:armb=0:armb=0
    next delay:goto loop
    ringer: for temp=0 to 7:ring.0[temp]=1:pause delay:ring.0[temp]=0:pause delay
    next temp:return
    END
    Last edited by skimask; - 10th December 2008 at 15:51.

  2. #2
    Join Date
    Dec 2007
    Location
    Northants England
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    No go so far I'm afraid tried the new code but there are a number of errors which I haven't checked out yet. Tried switching watchdog timer off and have put lots of capacitance across the 4.8 volt supply to the pickit2. (There are only three octal darlingtonds in circuit and there is no sign that the voltage drops when they are all on. The program runs until the "expanding multicolour disc" section. It then appears to go about seven times round the for next loop (For delay = 400 to 0 step -25) . and then starts again at the beginning of the program i.e. It resets. BTW Like the look of the shortened code although I haven't figured it all out yet !

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    How long does the program run before it resets? I mean exactly how long?
    Put a stopwatch on it...from power on until it resets. Try to be as accurate as possible.

  4. #4
    Join Date
    Dec 2007
    Location
    Northants England
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Three minutes 43 seconds (got slightly further thru the loop that time I think !)

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by DavidFMarks View Post
    Three minutes 43 seconds (got slightly further thru the loop that time I think !)
    Only reason I asked was that it might narrow down whether or not the watchdog timer is actually kicking or not.
    According to the datasheet, the max timeout for the WDT is 268 seconds. You got 3m43s, 223 seconds. Not really that close to 268 seconds, but the LFINTOSC is an uncalibrated clock. It's typical value is 31khz. It could run from 15khz (9m13s) to 45khz (3m4s), so your 223 seconds falls inside that range.

    Try dropping all of the pauses by a factor of 10 and see if it kicks out in the same spot or not.

    Also, looks to me like there are more LEDs on in 'Expanding Multicolor Disc' than the rest.
    What are you using for a power supply?
    Last edited by skimask; - 10th December 2008 at 21:27.

  6. #6
    Join Date
    Dec 2007
    Location
    Northants England
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    I tried reducing the start point of the if then that controls the delay from 400 down to 200 delay. The program now runs for 1 min 55 but gets further into the program. In fact it gets part way thru the "flashall" section. The power to the pickit demo board, the three darlington drivers and the opto couplers which operate the power transistors on the 8 positive lines is derived from a "Picaxe board I had lying around which has a7805 voltage reg and is being supplied from a 12volt 700ma power unit.
    The normal output voltage which is going to the PIC is 4.8 I have written a bit of code which swithches on all three ports (and hence all 128 leds) and the current taken is about 220 mA which drops the voltage to about 4.2

    For what it's worth the darlington outputs and the transistor circuits which light the leds are driven fom a car battery charger with an output of about 13.5 volts. Go on tell me I've done something daft !!! (I'll believe you !!)

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    How do you have MCLR set?

    I use MPASM so you need to change it a bit, but here is my config line for this chip.
    Code:
    @__config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF
    Dave
    Always wear safety glasses while programming.

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by DavidFMarks View Post
    In fact it gets part way thru the "flashall" section.
    Ok, I believe that would rule out the WDT.

    The normal output voltage which is going to the PIC is 4.8 I have written a bit of code which swithches on all three ports (and hence all 128 leds) and the current taken is about 220 mA which drops the voltage to about 4.2
    The brownout reset, if turned on, kicks at 4.0v. Are you measuring voltage at the regulator/source? Or right at the PIC itself? Might have a voltage drop in there somewhere and the brownout is kicking in.

    fom a car battery charger with an output of about 13.5 volts
    Those outputs aren't too clean at all.


    And are your config bits really being set as you want them to actually be set?

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