12f675_fuse_about_to_blow!


Closed Thread
Results 1 to 40 of 929

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Breaking News.........

    The LCD's have just arrived

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    Hi Henrik,

    How does this look? I went for the 'select case' in the end, I had to think for a while (nothing new there) but got there in the end.

    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
    
    OP VAR BYTE
    
    NUM2 VAR BYTE 
    
    TOTAL VAR BYTE
    
    
     
    MAIN:
    PAUSE 7000
    SEROUT2 PORTC.3, 16780, ["Please send NUM1", 10, 13] 
    PAUSE 500
    HIGH PORTA.5          'Shows data sent
    PAUSE 1000
    LOW PORTA.5
    
    PAUSE 250
    SERIN2 PORTC.5, 16780, [DEC NUM1]'MODE 16780 = 2400 BAUD INVERTED
    PAUSE 500
    HIGH PORTA.5          'Shows data arrived
    PAUSE 1000
    LOW PORTA.5
    
    PAUSE 250
    SEROUT2 PORTC.3, 16780, ["Please send Operator + - * /", 10, 13]  
    PAUSE 500
    HIGH PORTA.5          'Shows data sent
    PAUSE 1000
    LOW PORTA.5
    
    PAUSE 250
    SERIN2 PORTC.5, 16780, [OP] 'MODE 16780 = 2400 BAUD INVERTED
    PAUSE 500
    HIGH PORTA.5          'Shows data arrived
    PAUSE 1000
    LOW PORTA.5
    
    PAUSE 250
    SEROUT2 PORTC.3, 16780, ["Please send NUM2", 10, 13] 
    PAUSE 500
    HIGH PORTA.5          'Shows data sent
    PAUSE 1000
    LOW PORTA.5
    
    PAUSE 250
    SERIN2 PORTC.5, 16780, [DEC NUM2]'MODE 16780 = 2400 BAUD INVERTED
    PAUSE 500
    HIGH PORTA.5          'Shows data arrived
    PAUSE 1000
    LOW PORTA.5
    
    Select case OP
    CASE "+"
    TOTAL = NUM1 + NUM2
    CASE "-"
    TOTAL = NUM1 - NUM2
    CASE "*"
    TOTAL = NUM1 * NUM2
    CASE "/" 
    TOTAL = NUM1 / NUM2
    END SELECT
    
    pause 250
    SEROUT2 PORTC.3, 16780, [DEC TOTAL, 10,13]
    PAUSE 250 
    GOTO MAIN
    I did another version using IF-THEN as you showed me.

    Code:
    PAUSE 250
    IF OP = "+" Then
    Total =  Num1 + Num2
    
    PAUSE 250
    IF OP = "+" Then
    Total =  Num1 + Num2
    ENDIF
    
    PAUSE 250
    IF OP = "-" Then
      Total =  Num1 - Num2
    ENDIF
    
    PAUSE 250
    IF OP = "*" Then
      Total =  Num1 * Num2
    ENDIF
    
    PAUSE 250
    IF OP = "/" Then
      Total =  Num1 / Num2
    ENDIF
    Last edited by LEDave; - 17th April 2010 at 19:43.

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


    Did you find this post helpful? Yes | No

    Default

    Well that was easy....
    We need to think of something harder
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Hi mackrackit

    Well that was easy....
    Only because you and Henrik are such good teachers....!

    We need to think of something harder
    Ok, but be gentle with me.

    How about this:

    Yup, Write code and set the hardware up so whatever you send to the PIC® echos bach to the PC
    From an earlier brief.

    Dave

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,627


    Did you find this post helpful? Yes | No

    Default

    Looking good Dave! As you see the Select Case can provide a much cleaner look than the IF THEN in some cases. What you also can do is have a CASE ELSE where you "capture" invalid input (anything BUT + - / *).

    You have a lot of Pauses in there that doesn't need to be there if there's no specific reason for it.

    Now, since you have the LCD, why not make the messages appear on it instead of the PC-screen? You can still receive the "commands" thru the PC, to begin with.

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


    Did you find this post helpful? Yes | No

    Default

    Hi Henrik,

    Now, since you have the LCD, why not make the messages appear on it instead of the PC-screen? You can still receive the "commands" thru the PC, to begin with.


    That would be brilliant, I'm ready when you are!

    I've uploaded the PDF for the LCD.

    Quick point, on my PICkit1, I'm using two 22k resistors on the DB9 data cable (pin2&3) do I still use these for the LCD?

    Dave
    Attached Images Attached Images

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


    Did you find this post helpful? Yes | No

    Default

    Hey Dave,
    I will but back in....

    Check out the LCD section of the manual and compare to the LCD data sheet for the pin outs. Make needed adjustments and....
    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