Help with Pic Delay Pulse code please


Closed Thread
Results 1 to 37 of 37

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by g7jiq View Post
    Hi Chris

    Is there any updates yet, Have you got it working??

    Cheers...
    Sorry Jeff , I have been wating for you to tell me what is wrong with it (as in what it does or does not do correctly.)

    I am very busy for a few days so you may better off doing some debugging of yoiur own in the meantime. If you have enough spare pins you can attach an led to each pin and activate the leds as the program reaches each section.....when the leds stop lighting is where the problem lies.
    If you're short of pins, possibly you are, I usually write a small flashing led sequence and change the number of flashes for each part of the program and that way I always know where the program reached, but if you're going to debug with picbasic you could easily just use the 'debug' command and send serial data out to your PC to tell you where the program stopped.

  2. #2
    Join Date
    Oct 2007
    Posts
    35


    Did you find this post helpful? Yes | No

    Default

    Hi Chris,

    It doesn't do anything, (by the way the names dave)

    I have re programed the pic, (it programs fine with no errors)
    I have tried in my circuit and also bread boarded it.
    Here's what I get when powered up,

    The pins of the i/c are as follows:-

    GP0.0 high no change
    GP0.1 low no change
    GP0.2 high no change
    GPO.3 high no change
    GPO.4 high no change
    GPO.5 high/low trigger (i/p toggle)

    Cheers
    Dave..

  3. #3
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    One step at a time...

    Compile this and ensure your LED blinks on GPIO.1... ensure your LED has a suitable series Resistor...

    Code:
    	'
    	'	PIC Defines
    	'	-----------
    	@ DEVICE pic12F675, INTRC_OSC_NOCLKOUT
    		' System Clock Options (Internal)	
    	@ DEVICE pic12F675, WDT_ON
    		' Watchdog Timer
    	@ DEVICE pic12F675, PWRT_ON
    		' Power-On Timer
    	@ DEVICE pic12F675, MCLR_OFF
    		' Master Clear Options (Internal)
    	@ DEVICE pic12F675, BOD_ON
    		' Brown-Out Detect
    	@ DEVICE pic12F675, CPD_OFF
    		' Data Memory Code Protect
    	@ DEVICE pic12F675, PROTECT_OFF
    		' Program Code Protection
    
    	'
    	' Define Hardware
    	' ---------------
    	InputTrigger var GPIO.5 	' Input normally HIGH, goes LOW to Trigger
    	InputReset var GPIO.2		' Input normally HIGH, goes LOW to RESET
    	OutputLine var GPIO.0 		' Normally HIGH, goes LOW when triggered
    	LED var GPIO.1
    
    	'
    	' Define Variables
    	' ----------------
    	DelayTick var Byte 		' 100mS Tick Counter
    	MyFlags var byte
    
    	'
    	'	Initialise Hardware
    	'	-------------------
    	TRISIO=%00100100		' Preset I/O
    	CMCON=%00000111	  		' Disable Comparators
    	ANSEL=%00000000 		' Disable ADC
    	DelayTick=100			' Reset Counter
    	MyFlags=0
    	High OutputLine			' Everything Reset
    
    	'
    	'	Main Program Loop
    	'	-----------------
    Loop:
    	Pause 500
    	Toggle LED
    	Goto Loop
    	
    	End

  4. #4
    Join Date
    Oct 2007
    Posts
    35


    Did you find this post helpful? Yes | No

    Default

    Hi Melanie

    Thanks for your reply,

    Yes my led blinks ok.

    Cheers
    Dave...

  5. #5
    Join Date
    Oct 2007
    Posts
    35


    Did you find this post helpful? Yes | No

    Default

    Hi Melanie

    Just an addon to the above test, which worked fine,,,

    Last year you very kindly drafted me a piece of code for a project that has been working flawlessly,

    I am having problems adding an led command to it, if I add an low led command to it, it locks up when its triggered.

    Any ideas,

    Cheers
    Dave..

    'G7JIQ MICRO LINK REPEATER
    'PIC 12F675
    'Internal RC clock
    '
    ' PIC Defines
    ' -----------
    @ DEVICE pic12F675, INTRC_OSC_NOCLKOUT
    ' System Clock Options (Internal)
    @ DEVICE pic12F675, WDT_ON
    ' Watchdog Timer
    @ DEVICE pic12F675, PWRT_ON
    ' Power-On Timer
    @ DEVICE pic12F675, MCLR_OFF
    ' Master Clear Options (Internal)
    @ DEVICE pic12F675, BOD_ON
    ' Brown-Out Detect
    @ DEVICE pic12F675, CPD_OFF
    ' Data Memory Code Protect
    @ DEVICE pic12F675, PROTECT_OFF
    ' Program Code Protection

    '
    ' Define Hardware
    ' ---------------
    InputTrigger var GPIO.5 ' Input normally HIGH, goes LOW to Trigger
    InputReset var GPIO.2 ' Input normally HIGH, goes LOW to RESET
    OutputLine var GPIO.0 ' Normally HIGH, goes LOW when triggered
    Led var GPIO.1
    '
    ' Define Variables
    ' ----------------
    DelayTick var Byte ' 100mS Tick Counter

    '
    ' Initialise PIC
    ' --------------
    Reset:
    TRISIO=%00100100 ' Preset I/O
    CMCON=%00000111 ' Disable Comparators
    ANSEL=%00000000 ' Disable ADC
    DelayTick=0 ' Reset Counter
    high OutputLine ' Everything RESET
    pause 2000

    ' Main Program Loop
    ' -----------------
    Loop:
    '
    ' Test for RESET
    ' --------------
    While InputReset=0 ' Just wait here if RESET
    DelayTick=0 ' Reset Counter
    high OutputLine ' Reset Output
    Wend
    '
    ' Test for Trigger
    ' ----------------
    If InputTrigger=0 then ' Test for Trigger
    low OutputLine ' Enable Output
    DelayTick=1 ' Arm Counter
    'Goto Loop
    endif
    '
    ' Timeout Counter
    ' ---------------
    If DelayTick>0 then
    DelayTick=DelayTick+1 ' Count Time
    Pause 60 ' Waste 100mS
    If DelayTick>50 then goto Reset
    ' 50 = 5 sec
    ' 100 = 10 sec
    ' origanly set at 201 Reset at 20 Seconds
    endif
    Goto Loop

    '
    End

Similar Threads

  1. 16F628A - Stops if release power switch.
    By dene12 in forum General
    Replies: 16
    Last Post: - 14th February 2009, 07:57
  2. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  3. Help writing pic program with i/p o/p hold delay
    By g7jiq in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 27th May 2008, 21:58
  4. Pic driven digital audio delay
    By skimask in forum Off Topic
    Replies: 12
    Last Post: - 19th April 2007, 20:42
  5. Memory Space of the PIC16F84...
    By Tear in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 1st July 2005, 19:55

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