Do i have to use max232??


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    May 2005
    Posts
    49

    Exclamation Do i have to use max232??

    When i am trying to send data pic to another pic do i have to use MAX232?
    coz i am trying these codes and not working....

    '''''''''''''''''''MASTER
    include "modedefs.bas"
    define CHAR_PACING 100
    DEFINE LCD_DREG PORTD
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTD
    DEFINE LCD_RSBIT 0
    DEFINE LCD_EREG PORTD
    DEFINE LCD_EBIT 1
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50
    adcon1=7
    t1 var word
    t1=0
    basla:
    t1=0
    lcdout $fe,1
    lcdout "counter"
    loop:
    if portb.0=0 then goto birinci
    goto loop
    birinci:
    serout porte.0,5,[1,13]
    serin porte.1,5,30,gel1,#t1
    gel1:
    lcdout $fe,1
    lcdout "counter",
    lcdout $fe,$c0
    lcdout "count:",#t1
    pause 2000
    goto basla
    end


    ''''''''''''''''SLAVE
    include "modedefs.bas"
    define CHAR_PACING 100
    CMCON = 7
    TRISA =%11111111
    b0 var byte
    b0=0
    COUNTER var word
    COUNTER = 0
    b1 var byte
    b1 =0
    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 0
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 3
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50
    sil:
    COUNTER=0
    lcdout $FE, 1
    lcdout "COUNTER"
    lcdout $fe,$c0
    lcdout "COUNT:"#COUNTER
    loop:
    serin portb.1,5,10,kontrol,B0
    if b0=1 then goto ok
    goto kontrol
    goto loop
    kontrol:
    button porta.4 ,0,255,255,b1,1,goster
    goto loop
    goster:
    COUNTER = COUNTER + 1
    lcdout $FE, 1
    lcdout "COUNTER"
    lcdout $fe,$c0
    lcdout "COUNT:"#COUNTER
    goto loop
    ok:
    pause 20
    serout portb.2,5,[#COUNTER,13]
    lcdout $FE, 1
    lcdout "COUNTER"
    lcdout $fe,$c0
    lcdout "COUNT SEND"
    pause 1000
    GOTO sil
    END


    SLAVE = 16F628 have a button on porta.4
    MASTER=16F877 have a button on portb.0
    Asking is not a shame but not learning is a SHAME!!!

  2. #2
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Sub Zero,

    SZ>>When i am trying to send data pic to another pic do i have to use MAX232?<<

    No, you do not... your signal does not need to be inverted or anything like that.

    Take a look at the following:

    http://www.picbasic.co.uk/forum/showthread.php?t=579


    Remember, take one step at a time... Can you verify your output with a scope? Can you verify data is being sent? Nothing like attempting to send data on a port that is not capable... like Porta.3 which is a input for some chips. <g>

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  3. #3
    Join Date
    May 2005
    Posts
    49


    Did you find this post helpful? Yes | No

    Question I did all of them but...

    I did all of them but not working.
    1. Make sure your Pins that you are using are I/O pins.
    2. Make sure your chip is running (MCLR not on Reset)
    3. Make sure there is no noise between the two pins. You may need a Resistor to Ground for this.
    4. Make sure you are using the simplest of the SerOut commands. No "Additives" yet!... Got to get the basics going first.
    5. Use the same Baud Rates, and use a SLOW Baud rate.
    6. Its best to use the same Clock speed at first, until communications has been established.

    2.do u mean i will not connect a resistor to mclr?(on both pics?)
    3.do u mean i must connect TX and RX to ground with a resistor like 1 K?
    Last edited by SuB-ZeRo; - 26th July 2005 at 00:25.
    Asking is not a shame but not learning is a SHAME!!!

  4. #4
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Have a look at PBP Manual Sections 5.68 & 5.70

    Code:
    serin porte.1,5,30,gel1,#t1
    gel1:
    Doesn't make much sense
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



  5. #5
    Join Date
    May 2005
    Posts
    49


    Did you find this post helpful? Yes | No

    Unhappy Ok i chage the command but it becomes worse

    i change the commands like u re suggestion
    like this
    serout porte.0,5,[1,13]
    serin porte.1,5,t1
    but this time nothing works
    Asking is not a shame but not learning is a SHAME!!!

  6. #6
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    I'm sorry Sub,

    I did not suggest to change it to what you have changed it to,

    I suggested to have a look at the Manual !
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



  7. #7
    Join Date
    May 2005
    Posts
    49


    Did you find this post helpful? Yes | No

    Thumbs down Please Look At This!!!

    I really don't undestand in proteus simulation program it say's it is working i set up the circuit in the real world and it is not working i looked every connection and there is no mistake it must work 16F628 and 16F877 are working 4 mhz i remove the mclr resistors and i put resistors to the serin and serout pins that has been connected to the ground i use little commands. I do everything that u write or another friend write or PBP manuel or another book writen in Turkey.I am losting my hope
    PLEASE LOOK AT THE PICTURES.
    ''''''''''''''''''16F628 PROGRAM CODES
    include "modedefs.bas"
    define CHAR_PACING 100
    CMCON = 7
    TRISA =%11111111
    b0 var byte
    b0=0
    COUNTER var word
    COUNTER = 0
    b1 var byte
    b1 =0
    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 0
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 3
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50
    sil:
    COUNTER=0
    lcdout $FE, 1
    lcdout "COUNTER=" , #COUNTER
    lcdout $fe,$c0
    lcdout #COUNTER

    loop:
    serin portb.1,5,10,kontrol,B0
    if b0=1 then goto ok
    goto kontrol
    goto loop

    kontrol:
    button porta.4 ,0,0,0,b1,1,goster
    goto loop

    goster:
    COUNTER = COUNTER + 1
    lcdout $FE, 1
    lcdout "COUNTER=",#COUNTER
    goto loop

    ok:
    pause 20
    serout portb.2,5,[#COUNTER,13]
    lcdout $FE, 1
    lcdout "COUNTER=" , #COUNTER
    lcdout $fe,$c0
    lcdout "SENT!!!"
    pause 1000
    GOTO sil

    end

    '''''''''''''''''''''''16F877 PROGRAM CODES
    include "modedefs.bas"
    define CHAR_PACING 100
    DEFINE LCD_DREG PORTD
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTD
    DEFINE LCD_RSBIT 0
    DEFINE LCD_EREG PORTD
    DEFINE LCD_EBIT 1
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50
    adcon1=7

    t1 var word
    t1=0

    top var word
    top=0

    basla:

    t1=0
    top=0

    lcdout $fe,1
    lcdout "CHOSE"
    loop:
    if portb.0=0 then goto birinci
    goto loop

    birinci:
    serout porte.0,5,[1,13]
    serin porte.1,5,30,gel1,#t1
    gel1:
    top=t1*10
    lcdout $fe,1
    lcdout "COUNTER=",#t1
    lcdout $fe,$c0
    lcdout #top
    pause 2000
    goto basla
    end
    Attached Images Attached Images   
    Last edited by SuB-ZeRo; - 26th July 2005 at 01:54.
    Asking is not a shame but not learning is a SHAME!!!

  8. #8
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    quick test, remove all your timeout label, delay and such and redo the test.
    if it's working, increase them.

    case not... i'll prefer to use the internal USART.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  9. #9
    MaurI's Avatar
    MaurI Guest


    Did you find this post helpful? Yes | No

    Default

    The problem might be much simpler than you think!
    1)Are those PICs on separate PCBs?
    2)Do they have separate power supplies?

    My Idea is if the answers are yes and no then you should join the grounds together. You must join the pics with the signal wire and a ground wire.

    When I was younger and just started with electronics that was my problem, I connected the ground and everything started to work!!

  10. #10
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello SubZero,

    I would start as Steve says...Remove all.

    I would do the following... In somewhat this order.

    1. The slave (receiving chip).

    (WITHOUT USING SERIN)

    1. Blink a light on each of the pins that will control your LCD. (Portb).

    You can do this by the following psuedo code:

    TRISB=%00000000 ' assigning all Portb as output.
    Loop:
    port b=255
    pause 100
    portb=0
    pause 200
    goto Loop

    this verifies that your Slave chip is working correctly on the output, and it gives you confidence that your LCD will be driven by all pins of Port B. It is not a GUARANTEE, but a big vote of confidence.

    2. Attach LCD and (WITHOUT USING SERIN) Print "Hello Word" on the LCD.

    This gives you the confidence that the Slave IS working, and that the LCD IS working...


    If either of the above 2 things I have said cannot be done... you had better drop everything and MAKE the above two things happen!...Either that, you are wasting your time.


    Master Chip.

    Same as above.. You had better BLINK the LED's on the pins you are using to send... If you use PortA.0, you had better be able to BLINK a LED on PORTA.0!!!! If you can't blink a LED on PortA.0, then don't go ANY FURTHER!!!! Why is it not blinking??? Is it because you didn't turn off the comparitors? Assign it to Digital? Use the proper TRISA of %00000001 ?

    IF the pin you are going to use, blinks a LED, lets go to the next step

    Use the simplist of ALL SEROUT commands.... instead of going though the next steps, that link I gave you will take you through using the SEROUT and scoping it.

    ==================

    Now, with master chip working... lets reprogram the Slave with a SERIN command... no thrills.... just like the link....

    =====================

    You should be able to get communication between the chips...from here on, you add LITTLE by LITTLE, and fall back upon something that WORKS.

    Try adding a timeout label and loop it back...make sure it works...

    ============================

    Remember, you are experiementing, and sometimes its better to take a small nibble off that loaf of bread, than biting off more than you can chew or swallow.

    Many times I have reverted to the Nibble technic...In programming, I sometimes look through 200,000 lines of code...Much if it I can ignore...But when that paticular "error" or "failure" occures, I must sometimes look through each line of code, and sometimes each variable of each line!

    Dwayne

    print hello to the LCD.
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

Similar Threads

  1. PIC18F4680 to PC via MAX232 (RS232 serial) no output
    By opticsteam1 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th April 2008, 21:39
  2. PIC and MAX232 in/out
    By The Master in forum Serial
    Replies: 10
    Last Post: - 29th March 2008, 21:41
  3. RS232, max232
    By kutsi in forum General
    Replies: 12
    Last Post: - 30th May 2007, 07:39
  4. MAX232 and DB9 connecter
    By Tomas in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 25th March 2006, 17:02
  5. MAX232 Level Converter
    By HarryK in forum General
    Replies: 2
    Last Post: - 8th March 2005, 09:25

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