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

    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default

    Hi Dave,

    It can't ever be more than 3000ms because the highest value possibly returned by Random is 65535, anything larger won't fit in the WORD variable. We multiply that by 1000 and divide it by 21845 resulting in 3000. So, with these numbers it's simply impossible to get anything "larger" than 3000.

    /Henrik.

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


    Did you find this post helpful? Yes | No

    Default

    Goldberg is best known for a series of popular cartoons he created depicting complex devices that perform simple tasks in indirect, convoluted ways.
    Me and Rube have a lot in common, he draws them and I make them

    It can't ever be more than 3000ms because the highest value possibly returned by Random is 65535, anything larger won't fit in the WORD variable. We multiply that by 1000 and divide it by 21845 resulting in 3000. So, with these numbers it's simply impossible to get anything "larger" than 3000.
    Hi Henrik, I can appreciate that, I thought it was just cool to be able to see the numbers via the Serial Communicator.

    What did you think of the way in which I made the program run using VARS: X,Y and Z?

    Dave

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default

    Hi Dave,
    Nothing wrong at all with the way you did it. However, it seems to me you are "wasting" four bytes of RAM with the use of Y and Z. If you don't need to massage the intermediate results it's perfectly OK to simply use a single WORD variable, like
    Code:
    X VAR WORD
    RANDOM X
    X = X * 1000
    X = DIV32 21845
    SEROUT2 PORTC.3, 16780, [DEC X, 13, 10]
    /Henrik.

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


    Did you find this post helpful? Yes | No

    Default

    Hi Henrik,

    Here's a strange thing (and I'll re-check this later). I originally ran the code as yours above and the output was something like: 2411-341-11-0-0-0-0-0. After only a few cycles it started outputting zero's.

    I may well have made a 'typo' myself here so I'll re-check and re-run later today.

    Dave
    Last edited by LEDave; - 10th July 2010 at 10:41.

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default

    Hi Dave,
    Actually, it looks like you got me on this one... I'll HAVE to start verifying what I write before trying to look like I know what I'm talking about ;-) Don't know what's going on here, I'll have to try a few things out.

    /Henrik.

    EDIT: OK, I'm not sure exactly what's going on but this does seem to work:
    Code:
    RANDOM X
    Y = X * 1000
    Y = DIV32 21845
    Thanks Dave for catching that and letting me know!
    Last edited by HenrikOlsson; - 10th July 2010 at 11:31.

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


    Did you find this post helpful? Yes | No

    Default

    Henrik,
    I think our student has been reading the manual and caught the "dummy" var in the examples given.

    I think our student has also increased in rank!
    Maybe now he is
    NEWBIE.2
    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