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

    I got the bright idea that would figure this one out.
    http://www.picbasic.co.uk/forum/showthread.php?t=12948
    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

    Mmm,

    I'm might be able to help you, in about 15 years....!

  3. #3
    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 got something that 'works'

    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
    
    NUM1 VAR BYTE
    
    NUM2 VAR BYTE 
    
    TOTAL VAR BYTE
    
    Timeout con 10000
     
    MAIN:
    PAUSE 250
    
    SERIN2 PORTC.5, 16780,Timeout,Data_Not_Sent,[DEC NUM1, DEC2 NUM2]  
    PAUSE 6000
    HIGH PORTA.5
    PAUSE 1000
    LOW PORTA.5
    
    LET TOTAL = NUM1 + NUM2
    PAUSE 250
    
    SEROUT2 PORTC.3, 16780, [DEC TOTAL, 10] 
    pause 250
    
    DATA_Not_sent:
    High PORTA.1
    PAUSE 75
    LOW PORTA.1
    GOTO MAIN
    If I just load the program into the 16F684 and leave it running, every 10 secs PORTA.1 LED blinks as per the Timeout setting. I've given it a 10 secs delay because it takes about 4 secs to input two numbers into my clunky old keyboard.

    You might be wondering why there's a six second delay after the NUM's are inputted, it's so I can visually see via the LED PORTA.5 that it has arrived (if that makes sense).

    What do you think.

    Dave
    Last edited by LEDave; - 16th April 2010 at 13:45.

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


    Did you find this post helpful? Yes | No

    Default

    That's great Dave, you're making a lot of progress!

    What happens if you input 200 and 300 for num1 and num2 ? Why?

    Next challenge, if mackrackit don't mind:
    Make it so you actually input the complete equation, not only the two numbers. In other words 200+300 or 20-30 or 5*12 or....

    /Henrik.

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


    Did you find this post helpful? Yes | No

    Default

    Looking good Dave!!!

    Now you have Henrik's challenge.
    Sounds like a good next step to me.

    Henrik, I do not mind at all, the more teachers the better.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    That's great Dave, you're making a lot of progress!
    Thanks to mackrackit and yourself I am When you think that in February I couldn't turn an LED on or even create a HEX file....!

    Right then:

    What happens if you input 200 and 300 for num1 and num2 ? Why?
    Well the answer / output would be 230. Reason 200 is fine (BYTE = 255) the 300 which due to a mistake by me I set as D2 (DECIMAL2) in the program only takes the first two digits 30 so 200+30=230. How does that sound?

    Make it so you actually input the complete equation, not only the two numbers. In other words 200+300 or 20-30 or 5*12 or....
    Well the for first part 200+300 I'd have to set TOTAL VARIABLE BYTE to TOTAL VARIABLE WORD for the number 300 (that's assuming you can add a BYTE to a WORD.....Mmm, something makes me think this isn't going to be that straight forward......!
    Last edited by LEDave; - 16th April 2010 at 16:59.

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


    Did you find this post helpful? Yes | No

    Default

    Hi Dave,

    You are correct, in your case it would be 230. (I missed that DEC2 you had in there).

    What I was really going for was the fact that you have all three variables, Num1, Num2 and Total all declared as Bytes. So 200 in Num1, that's fine. But 300 in Num2 won't work as it will overflow and will actually result in the value 44 in Num2 the Total would be 244. Same thing if you'd do 200+200, Num1 is fine and so is Num2 but 400 won't fit in Total... You seem to have that under control though!

    For the next exercise, why not make the PIC ask three questions like:

    Num1: (You input whatever)
    Operator: (You input +, - / or *)
    Num2: (You input whatever)

    And then present the result. That should make it a little easier to sort out - I think.

    /Henrik.

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


    Did you find this post helpful? Yes | No

    Default

    Hi Henrik

    For the next exercise, why not make the PIC ask three questions like:Num1: (You input whatever) Operator: (You input +, - / or *) Num2: (You input whatever)
    Just to clarify: When I turn the Serial Communicator on, the PIC will send a request to the Communicator for NUM1, when I send that number, the PIC then asks the Comunicator for an 'operator' + - */ when the operator arrives the PIC then asks for NUM2 and then present the result.

    That should make it a little easier to sort out - I think.


    I'll give it a go.

    Dave

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