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

    Hi mackrackit,

    How does this look? It works but is it what you were after?

    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
    
    i var byte
     
    MAIN:
    PAUSE 250
    
    SERIN2 PORTC.5, 16780,[WAIT ("N1="), DEC NUM1]  'MODE 16780 = 2400 BAUD INVERTED
    PAUSE 2000
    HIGH PORTA.5
    PAUSE 2000
    LOW PORTA.5
    SERIN2 PORTC.5, 16780,[WAIT ("N2="), DEC NUM2]
    
    HIGH PORTA.5
    LET TOTAL = NUM1 + NUM2
    PAUSE 2000
    low PORTA.5
    pause 250
    SEROUT2 PORTC.3, 16780, [DEC TOTAL, 10, 13] 'OUTPUT IN DEC 'TOTAL' 10=L_FEED 13=C_RETURN
    pause 2000
    GOTO MAIN
    Dave

  2. #2
    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
    How does this look? It works but is it what you were after?
    COOL!!!
    I was not really after anything exactly, just trying to give you enough information to figure it out and you did!!!

    Now try sending sending 123 with out N1= or N2=.
    Code:
    SERIN2 PORTC.5, 16780,[DEC NUM1, DEC NUM2]
    Then try
    Code:
    SERIN2 PORTC.5, 16780,[DEC2 NUM1, DEC NUM2]
    Then try
    Code:
    SERIN2 PORTC.5, 16780,[DEC NUM1, DEC2 NUM2]
    Then try
    Something else....
    You will also want to look at the TIME OUT option of SERIN2.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Code:
     [WAIT ("N1=")
    This took me ages to figure out But hey, got there in the end

    I've also had a little play with DEC, DEC1.... late last night.

    From what I've found, I think I'm right in saying 'DEC' is good up to 255 NUM1 VAR BYTE, send 256 and it returns a '0'.

    'DEC1' is good 0 - 9 if you sent '23' then you'd only get a '2'

    'DEC4' If you'd sent '99' you'd get '0099', '255' would give '0255' & 256 would return '0000'........ETC.

    I'll have a look at the combinations you've posted this evening.

    I know progress is slow but we're making progress

    See you later.

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    This took me ages to figure out But hey, got there in the end
    You are doing great. It does take some time to learn how to think this way.

    DEC does determin the "size" but not as you think.
    DEC is for how many digits to grab.
    If 123 is sent and the receiving end is DEC2 the info gathered will be 12. The first two decimal places.

    Looks like you are getting VARIABLE size confused with this.

    The manual talks about this...
    BIT = 0 to 1
    BYTE = 0 to 255
    WORD = 0 to 65535

    In Binary a BIT will represent one place (_)
    BYTE will represent eight places (_ _ _ _ _ _ _ _)
    WORD will represent sixteen places (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _)

    8 BITs in a BYTE
    2 BYTEs in a WORD
    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 run those number variations / combinations, what a difference:

    Code:
    SERIN2 PORTC.5, 16780,[DEC NUM1, DEC NUM2]
    This one grabbed 123 then added 123 to give 246.

    Code:
    [DEC2 NUM1, DEC NUM2]
    This one grabbed the 1 and the 2 to give twelve, then added the 3 to give 15.

    Code:
    [DEC NUM1, DEC2 NUM2]
    This grabbed 123 + 12 to give 135

    Like you said earlier:

    One of the things you need to consider is, how is the data coming into the MCU?
    I can see this is very important, you've got to be comparing apples with apples, or else you're in real trouble, or at least be aware of how the numbers will be affected, your term 'grabbed' was right on the money.

    Looks like you are getting VARIABLE size confused with this.
    Guilty, I do tend to look at things one dimentionally before moving around and taking another view of things. It's that old lack of knowledge thing again

    Ah just remembered, in the PICBASIC PRO book, the DB9 cable dia has a 22k series resistor on PIN3, do I need to add one or am I ok you think? (I can't smell any smoke)

    Where to next......?

    Dave
    Last edited by LEDave; - 14th April 2010 at 21:06.

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


    Did you find this post helpful? Yes | No

    Default

    Probably a good idea to use the resistor, on both pins 2 and 3.

    Next... Some flow control.
    What happens if you do not send data? _____________
    There is a TIME OUT/ LABEL thing that goes with SERIN2 just for that.

    Write a sub routine to indicate that data has not been received. Make it short, could be missing data while in the sub routine.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Mmm, interesting.....!

    More reading / GQQGLING for me.

    Quick question, we set the mode to 16780 (2400 baud inverted). Does this in tern automatically set the FlowPin to the correct enabled state? 'This enabled state is determined by the polarity of the data specified by mode' (from the manual).

    Also what's a reasonable 'Timeout' period in milliseconds for this?

    I'll pick up a couple of resistors in the morning.

    See you tomorrow.

    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