12f675_fuse_about_to_blow!


Closed Thread
Results 1 to 40 of 929

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Yes.

    I do like text editors with syntax highlighting but even windows notepad will work. If I remember correctly that is what Melanie uses, just plain 'ol notepad.
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    If I remember correctly that is what Melanie uses, just plain 'ol notepad.
    Goes to show then...........

    Dave

    Ah, almost forgot, the Badger re-appeared last night I'm very pleased to say.

  3. #3
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Below is a part of a simple little program I've been experimenting with to generate a 'random' pause but of known maximum and minimum time period(average maximum wait about 12secs for the LED to flash as the program stands).

    The pause occurs randomly but because there are a maximum of 65535 'lenghts' if you will of a given time (be it clock cycles etc (I'm not sure how RANDOM works) it should be possible to my mind to work out how long the longest and shortest pause times will be when they occur (1 or 65535 lenghts) I think.

    So my question is this: How long does it take the PIC processor to calculate 1 lenght? At the moment the maximum and minimum pause times occur at 12secs max 1sec min.

    I hope this makes sense

    Code:
    X VAR WORD
    
    main:
    RANDOM x
    
    PAUSE X /4
    
    HIGH PORTA.2 
    PAUSE 1000
    low PORTA.2
    GOTO MAIN:
    Dave
    Last edited by LEDave; - 8th July 2010 at 00:22.

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


    Did you find this post helpful? Yes | No

    Default

    Can you setup a LCD or have the value of x sent to a terminal? I would think you should have at times a longer pause than 12 seconds??

    You may want to look at this also.
    http://www.picbasic.co.uk/forum/showthread.php?t=9350
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Hi mackrackit,

    I've been working really hard on this. I've taken your idea of:

    Can you setup a LCD or have the value of x sent to a terminal?
    And done this:

    What I've done is change the original code to measure the time the LED is on rather than measure the time the program was 'PAUSED' because to my mind you can only use 'PULSIN' on a active pin. I've then tried to output that 'PULSIN' number using 'SEROUT2' to the Serial communicator.

    It nearly works I think, what it does is output a series of zeros, instead of the time in micro_secs. I suspect I've made an error here:

    Code:
    SEROUT2 PORTC.3, 16780, [DEC Z, 10 ,13] 'The measured RANDOM time sent to S/Communicator
    I think it could be the Decimal value of Z that's causing the problem (I hope) being as it should be measuring in blocks of Micro_secs.

    Here's the program, I feel I'm close, but am I?. If you could look the program over and give me a pointer that would be really appreciated. The chip is a 16F684.


    Code:
    ANSEL   = %00000000    'Disable analog select so ports work as digital i/o.
    CMCON0  = %00000111    'Disable analog comparators.
    TRISA   = %00000000    'Set PORTA as OUTPUT.
    PORTA   = %00000000    'Set PORTA pins all low.
    TRISC   = %00000000    'Set PORTC as OUTPUT.
    PORTC   = %00000000    'Set PORTC pins all low.
    
    DEFINE OSC 4
    
    
    X VAR WORD  'Number between 1 & 65535
    Y var WORD  'Scaled down value of X 
    Z VAR BYTE  'The PAUSED value of Y in 10us Increments
    
    main:        
    RANDOM X            'Random number between 1 & 65535
    LET Y = (x /14)     'Scaled down value of X
    HIGH PORTA.2        'LED PORTA.2 lights up
    PAUSE Y             'LED on for time period of RAN_X_OVER_14
    PULSIN PORTA.2,1,Z  'The paused RANDOM time period stored in VAR Z
    SEROUT2 PORTC.3, 16780, [DEC Z, 10 ,13] 'The measured RANDOM time sent to S/Communicator
                                        'in 10us incremets
    low PORTA.2          'LED off
    GOTO MAIN:           'Do it all again
    Dave
    Last edited by LEDave; - 8th July 2010 at 21:47.

  6. #6
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Ah, have I got 'PULSIN' in the right place in the program? Might it be better in front of HIGH PORTA.2 ?

    Nope, still outputting zero's.

    The manual says of zero's:

    If the pulse edge never happens or the width of the pulse is too great to measure, Var is set to zero
    Now I'm thinking the pulse must happen because the LED lights and with a 'RANDOM' delay but could it be to big to measure?

    How big is too big to measure for a pulse?

    Dave
    Last edited by LEDave; - 8th July 2010 at 23:20.

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


    Did you find this post helpful? Yes | No

    Default

    As far as I know PULSIN is for reading a pulse on a pin from the outside not a pulse from the inside.

    It has been a long day so maybe I am missing something... What exactly are you wanting to do?
    Dave
    Always wear safety glasses while programming.

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