1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Two MicroControllers

Discussion in 'Microcontrollers' started by Eng.Remon, May 28, 2007.

  1. Papabravo

    Papabravo Well-Known Member

    Joined:
    Mar 9, 2006
    Messages:
    2,889
    Likes:
    25
    Location:
    Michigan, USA (GMT-5)
    Almost every 8051 has at least one onboard UART or Serial Port. If you need more there is the very capable MAX3100 family of SPI UARTs, or you can build one in software. I agree with Nigel, by the way, that you dont need to use interrupts for everything especially keypads. I also agree that multiple processors are not indicated for this straightforward application. You do not appear to have the slightest justification for using more than one processor.
     
  2. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    I think the idea is that he needs to have the sensors a distance from the actual controller/monitor. I am not sure what the justification for the 3rd is. Perhaps it is just to show that they know how to make 3 processors communicate.

    But I think that RS232 is a poor choice. A RS485 network would be better then a point to point link in that additional processors/sensor could be added anywhere. I do not think these guys are up to it.
     
  3. Eng.Remon

    Eng.Remon New Member

    Joined:
    Dec 13, 2006
    Messages:
    50
    Likes:
    0
    Location:
    Eg.
    Papabravo how could connect the keybad witout interrupts ? how u gona know when a button is hit?!.
    exactly 3vo & the 3rd uc is for the dtmf and hang up circuits which deal wid them.
    sorry 3vo i dont understand that:
    A RS485 network would be better then a point to point link in that additional processors/sensor could be added anywhere. I do not think these guys are up to it.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,213
    Likes:
    640
    Location:
    Derbyshire, UK

    You poll the keypad periodically, it's a VERY commonly used technique.
     
  6. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    Nigel has written a series of tutorials for the PICs that include one on polling keyboards. Take a look at it. See link in his signature.

    RS232 serial links two devices together.

    A RS485 network allows many devices to talk to each other over the same pair of wires, but only one device can send at a time. That way you would never need more then 1 uart on any processor and you could have many processors.

    I said that I did not think you were up to it becasue you are still learning about RS232. When is your project due ?
     
  7. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,213
    Likes:
    640
    Location:
    Derbyshire, UK
    I would tend to concur!, if it's a graduation project and you don't know the simple basics it's not looking good!.
     
  8. Eng.Remon

    Eng.Remon New Member

    Joined:
    Dec 13, 2006
    Messages:
    50
    Likes:
    0
    Location:
    Eg.
    next month
     
  9. Eng.Remon

    Eng.Remon New Member

    Joined:
    Dec 13, 2006
    Messages:
    50
    Likes:
    0
    Location:
    Eg.
    is polling the keybad would work! i think if it is wid interrupt would be better, like the pc keyboard!!
     
  10. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,213
    Likes:
    640
    Location:
    Derbyshire, UK
    I've no idea if a PC keyboard is polled or uses interrupts?, I would imagine it might be polled? - the processor isn't doing anything else. This is the processor in the keyboard itself!, the PS2 connection to the PC may well use an interrupt?, but if it's a USB keyboard it definately doesn't! - USB doesn't have interrupt capability.
     
  11. Eng.Remon

    Eng.Remon New Member

    Joined:
    Dec 13, 2006
    Messages:
    50
    Likes:
    0
    Location:
    Eg.
    ummm but it is 4*4 keybad also this uc is making output of the lcd and also monitor other uc so beter for it to be on int. isnt it?
     
  12. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,213
    Likes:
    640
    Location:
    Derbyshire, UK
    Doesn't make much difference really?, the LCD is of no concern, it's only an output, and is only driven occasionally, if you're using a hardware UART you've got plenty of time to check that, and even with a software UART it's not a problem, you've still got more than enough time, and just check the keypad periodically.

    If you go back to VERY old PIC's, only 12 bit, and no interrupt capability, there's an application note at MicroChip that shows how to make a digital clock using one. It multiplexes 7 segment LED's for the display, scans the keyboard (note that both the display and keyboard share I/O pins as well!), and keeps accurate time running. All this with polling, not an interrupt in sight! (or possible).

    Interrupts certainly have their uses, and often are essential, but no where near as often as you might think.

    Do you have fully working interrupt driven keypad routines?, if you do there's no point in changing them!.
     
  13. Eng.Remon

    Eng.Remon New Member

    Joined:
    Dec 13, 2006
    Messages:
    50
    Likes:
    0
    Location:
    Eg.
    i m not using pic i m using atmel 80c51, also i dont know any info about it :S,
    what do u mean about the interrupt!?
    Do you have fully working interrupt driven keypad routines?, if you do there's no point in changing them!.
     
  14. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,213
    Likes:
    640
    Location:
    Derbyshire, UK
    I know, I was only using the old PIC example to show what you can do without interrupts.

    I mean have you got that part all written and working?.
     
  15. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    Lets try it from another direction.

    What tools do you have to work with?

    What work have you done so far hadware and software ?
     
  16. Eng.Remon

    Eng.Remon New Member

    Joined:
    Dec 13, 2006
    Messages:
    50
    Likes:
    0
    Location:
    Eg.
    ummm ok i did all the part of sensors with uc1.
    i did the keybad with int and lcd with uc2
    i m on my way to finish the dtmf generator and receiver with hang up on the uc3 . what i didnt do is connected and make the protocols between each. thats what i have problems in .
    so in other meaning i did each one seperatly . but not connected with whole the project
     
  17. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    Is it safe to say that the goal is to finish the project as quick as possible and still have it look good to the person who grades it.

    Go with RS232 because it will handle the distance you require and it is most easily understood.

    U2 is the difficult part because it needs to UARTS. The link between it and U1 gets the most traffic so use the hardware UART for that. The link between U2 and U3 is used only when a phone call is to be made. Since no one will be calling in U3 should never have to start a conversation with U2. Should be safe to used a software (bit bang) Uart for this link.

    U1 and U3 only require one UART which they have.

    Read up on the 80c51 UART and see if you can find and drivers online or in app notes that you can use. Do the U2-U1 connection first because it uses only hardware UARTS. You can go polled or with interrupts whatever you can find.

    Next find a bit-bang routine for the 80c51. Go with polled here. You only have to pay attention to U3 if you are expecting a responce from it.

    Now write your protocol.
    You have been taling about encoding the data between U2-U1 in eight bits. You can do that, but since the traffic is light you could use a human readable one.

    For example if U1 wanted to tell U2 the temerature was 23
    From U1 to U2:
    T23
    From U2 to U1:
    AT23

    When U1 sees the msg sent back with an A prepended it knows that U2 has the message. Keep it simple. I would not get much more complicated then this as it is not needed.

    The above suggestion uses about 10 times the bytes to send but it is closed loop and you can read it without decoding a binary mapping. There is overhead in converting numbers to and from ASCII strings.
     
  18. Eng.Remon

    Eng.Remon New Member

    Joined:
    Dec 13, 2006
    Messages:
    50
    Likes:
    0
    Location:
    Eg.
    ok first i ll read about RS232 , but can u tell me what is bit-bang routine!?
     
  19. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,213
    Likes:
    640
    Location:
    Derbyshire, UK
    'Bit-banging' is a software UART - although you're not using a PIC, you might try reading my PIC RS232 tutorial, which explains it.
     
  20. Eng.Remon

    Eng.Remon New Member

    Joined:
    Dec 13, 2006
    Messages:
    50
    Likes:
    0
    Location:
    Eg.
    k is it tutorial7?
     
  21. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,213
    Likes:
    640
    Location:
    Derbyshire, UK
    Yes, that's correct.
     

Share This Page