12f675_fuse_about_to_blow! - Page 11


Closed Thread
Page 11 of 24 FirstFirst ... 78910111213141521 ... LastLast
Results 401 to 440 of 929
  1. #401
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Not a stupid question at all
    Cheers mackrackit, I'm feeling better already I hope you are too!

    So probably good practice to set VAR_IN_QUESTION = 0 just in case.

    Hopefully I'll have moved the program on tomorrow, fingers x'd.

    Right, time for me bed.

    See you tomorrow.

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    Hint
    COUNT is for pulses in a time period.

    Maybe
    if switch goes high
    then
    var = var + 1
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Hi mackrackit,

    Question: How long does it take LEDave to wire a push_button_switch to a PIC16F684?

    Answer: About 48hrs

    I think the program below should work ok:

    Code:
    Total var word
    clear
    
    MAIN:
    if PORTA.5 = 0  then  count_up:
    IF PORTA.5 = 1  THEN      MAIN: 
        
    Count_up:
    let Total = Total + 1 
    pauseus 25   
    LCDOUT $FE,1
    LCDOUT $FE,$C0,DEC Total
    PAUSE 500    
    GOTO MAIN:
    LEDave current status: Eyes going, mind boarderline!

    Dvae

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by LEDave View Post

    I think the program below should work ok:

    Code:
    Total var word
    clear
    
    MAIN:
    if PORTA.5 = 0  then  count_up:
    IF PORTA.5 = 1  THEN      MAIN: 
        
    Count_up:
    let Total = Total + 1 
    pauseus 25   
    LCDOUT $FE,1
    LCDOUT $FE,$C0,DEC Total
    PAUSE 500    
    GOTO MAIN:
    It looks good.
    LEDave current status: Eyes going, mind boarderline!

    Dvae
    Hey, that means you have passed the initiation and are a full codder now.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    So the next thing it to WRITE 'Total' to EEPROM address, then READ that value and put it back into 'Total'.

    The theory is that when the PIC power supply is turned off then restarted last 'Total' reappears on the LCD.

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    Yup, that is the mission
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    From the manual:

    Code:
     WRITE Address,Value
    So looking at the 16F684.PDF it says:

    The PIC16F684 has 256 bytes of data EEPROM
    with an address range from 0h to FFh.
    So would:
    Code:
    WRITE 0h,Total
    work? Not quite as simple as that he says! For one thing these are EEPROM BYTES and 'Total' is a WORD two BYTES for a starter.

    Dvae

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


    Did you find this post helpful? Yes | No

    Default

    You do not need to use HEX numbers for the address, PBP takes care of that.

    http://www.melabs.com/resources/samples.htm
    Might find the above .... interesting
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Mmm. Well I kind of think I know what I have to do, it's break the VAR WORD Total up into two BYTES, allocate them each a memory space B1 & B1+1 (from the prog below) WRITE the BYTES to the memory locations then READ them back.

    Code:
            INCLUDE "modedefs.bas"          ' Include serial modes
    
    SO      VAR		PORTC.6					' Define serial output pin
    
    B1      VAR     BYTE					' Address variable
    W2      VAR     WORD					' Data variable
    
    
    mainloop:   
    
    		For B1 = 0 To 12 step 2			' Step 2 because each word requires 2 bytes of memory
            	W2 = B1 + 1000          	' Add 1000 to address
            	Write B1, W2.HIGHBYTE		' Write high byte of word
            	Write B1+1, W2.LOWBYTE		' Write low byte of word to next address
    		Next B1
    
    		For B1 = 0 To 12 step 2			' Step 2 to get word size data
            	Read B1, W2.HIGHBYTE		' Read high byte
            	Read B1+1, W2.LOWBYTE		' Read low byte
            	SerOut SO,T2400,[#W2," ",10,13]	' Display the word data
    		Next B1
    		
            SerOut SO,T2400,[10,13,10,13] 	' Skip 2 Lines
    
            GoTo mainloop                       ' Forever
    My reading of the program above is that B1 = 's ( 0,2,4,6,8,10,12) + 1000 this is then written and read from memory location B1 & B1+1 into WORD W2 am I close?

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by LEDave View Post
    My reading of the program above is that B1 = 's ( 0,2,4,6,8,10,12) + 1000 this is then written and read from memory location B1 & B1+1 into WORD W2 am I close?
    Sounds like you understand it. Have you tried it yet?
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Sounds like you understand it. Have you tried it yet?
    I'm on it.......

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


    Did you find this post helpful? Yes | No

    Default

    I modified it to run on my LCD and it counts from 1000 to 1012 by adding two, then does it all over again.

    So the first loop is WRITING the count to memory and the second is READING and displaying from memory to the LCD. B1 being the high BITS of the BYTE that make up W2 and B1+1 the low bits of W2, is that right?

    So to complete our 'mission' should I try and do the same and use a loop or assign BYTES to a WORD (if that makes sense).

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by LEDave View Post
    I modified it to run on my LCD and it counts from 1000 to 1012 by adding two, then does it all over again.

    So the first loop is WRITING the count to memory and the second is READING and displaying from memory to the LCD. B1 being the high BITS of the BYTE that make up W2 and B1+1 the low bits of W2, is that right?
    Yup!
    So to complete our 'mission' should I try and do the same and use a loop or assign BYTES to a WORD (if that makes sense).

    Dave
    ????

    You have the WORD size var holding the value of how many times the switch was pressed. Use the high byte low byte thing from above for writing every time the switch is pressed. Only need to read the EEPROM when the chip starts.

    Something like that
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Something like that
    I'll give it a go, not a 100% sure on this one but I'll give it go.

    This is brilliant stuff though, cheers mackrackit.

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    Mission clarification

    Power UP
    Read EEPROM
    Transfer value from EPROM to VAR

    Press Button
    VAR adds one to it's self
    Display VAR on LCD
    Write VAR to EEPROM
    Wait for another Button press

    This message will self destruct in.....
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default



    I'm on it boss 'NCIS'.....!

    Dave

  17. #417
    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 not been able able to look at the project this weekend due to a family issue.

    Will be back 'on mission' tomorrow all being well.

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    Yup, family comes first. In the end that is all we got.

    Hope things turn out well.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Yup, family comes first. In the end that is all we got.
    Never a truer word....

    Hope things turn out well.
    Thank you and they have I'm very relieved to say.

    Back on the case tomorrow after a good nights sleep.

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    Hi mackrackit,

    Things pretty much back to normal here (panic over)

    So here's the first part of the brief, I think it covers these components:

    Power UP: Read EEPROM: Transfer value from EPROM to VAR: Press Button:
    VAR adds one to it's self: Display VAR on LCD
    I didn't want to try and do any more just in case I'm wildly off track on this, what do you think? I've left out all the DEFINES for clarity.

    Code:
    Total var word        ' Data variable
    B1      VAR     BYTE  'Stored DATA address
    clear                 'Re_set volatile memory to zero (Not EEPROM?)
    
    MAIN:
    gosub Power_up        'On Power_up GOTO READ EEPROM subroutine
    Start:
    if PORTA.5 = 0  then  count_up: 'If button pressed start counting
    IF PORTA.5 = 1  THEN     Start: 'If button not pressed loop until it is
        
    Count_up:                 'Button has been pressed
    let Total = Total + 1     'Add one to value of Total taken from EEPROM   
    LCDOUT $FE,1              'Clear LCD
    LCDOUT $FE,$C0,DEC Total  'Display Total on LCD
    PAUSE 500
    GOTO Start: 
    
    Power_up:                 'Power_up subroutine
    Read B1, Total.HIGHBYTE	  ' Read high byte
    Read B1+1, Total.LOWBYTe  ' Read low byte  
    LET Total = Total         'Set Total to value set in EEPROM Memory
    return
    Dave
    Last edited by LEDave; - 4th May 2010 at 17:42.

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


    Did you find this post helpful? Yes | No

    Default

    Glad to hear things are back to normal.

    A quick look and it looks OK, might want to add a WRITE to EEPROM routine though...
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Glad to hear things are back to normal.
    Cheers mackrackit, it was a real worry there for a while.....

    might want to add a WRITE to EEPROM routine though...
    I'm be on it tonight.

    Dave

  23. #423
    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 added the WRITE to EEPROM routine. Also @power_up the LCD was blank, so I
    added an LCDOUT statement to the Power_up Subroutine which now displays the last stored
    EEPROM value.

    The whole thing works a treat I can see the merits of being able to write data to a non volatile memory, really,really useful. Thanks for stearing me through this one (as ever) very clever.


    Code:
    Total var word        ' Data variable
    B1      VAR     BYTE  'Stored DATA address
    clear                 'Re_set volatile memory to zero (Not EEPROM?)
    
    MAIN:
    gosub Power_up        'On Power_up GOTO READ EEPROM subroutine
    
    Start:
    if PORTA.5 = 0  then  count_up: 'If button pressed start counting
    IF PORTA.5 = 1  THEN     Start: 'If button not pressed loop until it is
        
    Count_up:                 'Button has been pressed
    let Total = Total + 1     'Add one to value of Total taken from EEPROM
       
    LCDOUT $FE,1              'Clear LCD
    pause 150
    LCDOUT $FE,$C0,DEC Total  'Display Total on LCD
    Write B1, Total.HIGHBYTE  ' Write high byte of Total word to EEPROM
    Write B1+1, Total.LOWBYTE ' Write low byte of Total word to next address
    goto start:
     
    Power_up:                 'Power_up subroutine
    Read B1, Total.HIGHBYTE	  ' Read high byte
    Read B1+1, Total.LOWBYTe  ' Read low byte  
    LET Total = Total         'Set Total to value set in EEPROM Memory
    LCDOUT $FE,1              'Clear LCD
    pause 150                 'Give LCD a chance to Power_up
    LCDOUT $FE,$C0,DEC Total  'At Power_up display Total on LCD from EEPROM
                              'Memory which has been stored since Power_down
    return
    Just going to pop around my bench to turn the power back on........Yep still working

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    COOL!!!!

    Do you want another mission?
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Do you want another mission?
    You bet, I wanted you to sign me off on the last Mission first though

    It's one thing me thinking I've done something right, it's another being told I have.

    Dave
    Last edited by LEDave; - 4th May 2010 at 21:48.

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


    Did you find this post helpful? Yes | No

    Default

    So far you have been letting PBP take care of the EEPROM address "B1".
    Now we want to control where in the EEPROM data is written to as we will be storing and retrieving multiple pieces of data.

    Using the same basic scenario as before, part counting on a conveyor.
    This time the machine and personnel have been upgraded to run 24/7. The only time the machine will be shut down is for maintenance, scheduled or un-scheduled.

    Management still wants to know the total parts ran, and the maintenance department wants to know how many parts are being ran between shut downs, how many shut downs there were and because they are lazy they also want the machine to average the amount of parts ran between each down.

    Who says computers and automation cuts jobs? We went from running one shift to three and added coder to the mix along with all of the supply/demand personnel to handle the increased production.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Ok.....Mmm...,

    Now we want to control where in the EEPROM data is written to as we will be storing and retrieving multiple pieces of data.
    Well for this I'm thinking (although I could be wrong here):

    Code:
    WRITE 5,B0 ' Send value in B0 to EEPROM location 5
    So we need:

    1/ Total parts run

    2/ Total parts run before M/C stops for maintenance

    3/ How many times M/C shuts down (scheduled + un_scheduled)

    4/ The average amount of parts run between each shut down (scheduled + un_scheduled)

    I think I've read that right?

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by LEDave View Post
    Code:
    WRITE 5,B0 ' Send value in B0 to EEPROM location 5
    Yup
    1/ Total parts run

    2/ Total parts run before M/C stops for maintenance For each run, need multiple address here too.

    3/ How many times M/C shuts down (scheduled + un_scheduled)

    4/ The average amount of parts run between each shut down (scheduled + un_scheduled)
    Remember two address locations for WORD size variables.
    Hopefully the machine will run long enough to need a WORD VARs for parts run between shut downs, and if all goes well the machine will not shut down often so a BYTE size VAR should work for "times shut down".
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    I'm on it, tricky in parts but I'm on it

    How many EEPROM locations are there on a PIC16F684?

    As in:

    Code:
    EEPROM location 5
    Dave

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


    Did you find this post helpful? Yes | No

    Default

    I think the 684 only has 256, if I remember correctly.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Is that sequential 0-255?

    Srub that, it's got to be I'm thinking.

    See you tomorrow.

    Dave
    Last edited by LEDave; - 5th May 2010 at 00:52.

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


    Did you find this post helpful? Yes | No

    Default

    Hi mackrackit,

    I'm busy working on the latest 'mission'. I'll stick at it and only ask a question when I'm stuck and have given it a good go to figure it out myself.

    I do have one quick question though:

    Can you add or subtract EEPROM memory location values (numbers written to an EEPROM address)? Or do you just give the stored WORD's a name and then subtract the two, something like: Parts_Run = Total - First_Parts_run (if this make sense).

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    While the value is in the EEPROM you can not go anything with it. You have to read the value into a variable, do something with it and write it back into the EEPROM.

    I think that is what you are asking...
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    I think that is what you are asking...
    Spot on.

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    I can almost hear mackrackit tapping his fingers on the table............!

    Working really hard on this, I know what I want to do, I just need a breakthrough. At the moment I'm going around in circles.

    I'll see what I can come up with tonight.


    Tap, tap, tap...Stop it mackrackit...lol.

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


    Did you find this post helpful? Yes | No

    Default

    Going around in circles?
    You mean stuck in a loop

    tap tap tap
    that is funny
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    You mean stuck in a loop


    Yep,exactly that

    If I can't crack it by tomorrow night I'm going to have to ask for a pointer. I was going to ask for one tonight but I think I'm in the right ball park for a small break through (he typed deludedly but hopefully).

    Dave
    Last edited by LEDave; - 6th May 2010 at 22:24.

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


    Did you find this post helpful? Yes | No

    Default

    Mmmm,
    You mean stuck in a loop
    Cryptic I know but are you 'hinting' that the way to do part two of the mission, namely:

    Total parts run before M/C stops for maintenance For each run
    Is to have the Total count (part one of mission) actually run inside a WORD size loop and Total parts run is actually the loop count itself? So that whenever the loop stops (ie, MC stops) that value is then written to EEPROM as Total parts run?

    The thinking would then be that Total count just carries on and parts run ie the loop count resets to zero and then starts again on power up.

    Dave
    Last edited by LEDave; - 7th May 2010 at 17:38.

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


    Did you find this post helpful? Yes | No

    Default

    The thinking would then be that Total count just carries on and parts run ie the loop count resets to zero and then starts again on power up.
    And writes to a different EEPROM location each time. So if you have five start ups you will have five EEPROM locations (10 actually, 2 per WORD), plus the pair of locations for the TOTAL.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    And writes to a different EEPROM location each time.
    More to think about there then.All part of the learning process.

    Learning how to program these PIC's is like learning a foreign language, doing a crossword puzzle and a Rubick's cube (all at the same time)...

    It'll come with time and practice though (I hope...!)

    Dave

Members who have read this thread : 1

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