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. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    Have you though about flow control. When the MC is going to be too busy it sends an XOFF. When free to receive data it sends XON. Could also be done with hardware handshake.

    You only need to do this for the DTMF generation. A keyboard scan can be interrupted without any problem and the LCD should be ok too.
     
    Last edited: May 31, 2007
  2. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,161
    Likes:
    340
    Location:
    Brisbane Australia
    I don't understand why 2 pics are required. You want to read a keypad or two, write to a display and produce a tone. Easily done with a single pic and, if this involves a human typing then you can slow the pic down to 32K.

    Maybe you should describe what you are trying to achieve.

    Mike.
     
  3. Eng.Remon

    Eng.Remon New Member

    Joined:
    Dec 13, 2006
    Messages:
    50
    Likes:
    0
    Location:
    Eg.
    it is 3 atmel 8051 not pic and it s a project :S not in my hand.
    Excuse me 3v0 what do u mean by xon and xoff, as i think if dat would be connect to interrupt , yea i thought about that but there is already some interrupts in the system :S and i cant keep watching a bit and leave all the program .
     
  4. dave

    Dave New Member

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


     
  5. Papabravo

    Papabravo Well-Known Member

    Joined:
    Mar 9, 2006
    Messages:
    2,889
    Likes:
    25
    Location:
    Michigan, USA (GMT-5)

    XON and XOFF are the names of two ASCII Control Characters. They are also known as ^Q or DC1, and ^S or DC3. As 3VO said you use them on a serial port to throttle a fast talker.

    When a transmitting station receives an XOFF, it completes any operations in progress, and stops transmitting. It stays in this state until it receives an XON. Then it picks up right where it left off as if there had never been a long pause.

    See the following link for more information:
    http://en.wikipedia.org/wiki/ASCII
     
  6. Eng.Remon

    Eng.Remon New Member

    Joined:
    Dec 13, 2006
    Messages:
    50
    Likes:
    0
    Location:
    Eg.
    oh ok i guess i need to read about serial port transimission in uc isnt it ?!
     
  7. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    I am going to ignore the XON XOFF question for now in that PapaBravo has sent you in the right direction.

    If you know the following please forgive me. It may be a language thing but lets make sure we are talking about the same thing.

    I do not know your system but I do not see anything other the the UART that requires it to be interrupt driven.

    What are you talking about watching a bit. That would be polling, you check or poll a bit periodically to see if it changed (as in a char has arrived). That is what you do not want to do.

    An interrupt is when some condition (a character arriving) causes the program to stop what it is doing and handle the interrupt (move the char from the UART) then return to what it was doing when interrupted. As long as the code to handle the interrupt is short/fast most other code never knows it was interrupted. The software does not check any bits, this is done by the CPU hardware which causes the interrupt code to be executed at any random spot in you normal code.

    So you write normal code to do the DTMF, Keyboard etc. You write an interrupt routine to move data/chars from the UART to an input buffer. You main program checks the input buffer to see if it has any data.

    If the above is not good enough. The have the main program send a XOFF to the sending processor prior to generating a DTMF tone and then send a XON when done generating the tone. That will cause the sender to not send any data while you are doing DTMF.
     
  8. Eng.Remon

    Eng.Remon New Member

    Joined:
    Dec 13, 2006
    Messages:
    50
    Likes:
    0
    Location:
    Eg.
    ok lets declare the system : all uc Are 80c51 Atmel
    uc1: sensors are connected to it (heat, ir, smoke, pressure) which leads to 6 actions . which usually send to the main controller to take action and make the other uc make a call
    uc2: the main microcontroller which is connected to a keybad and lcd and also should get actions from uc1 and send to uc3 to make a call or whatever.
    uc3:the dtmf uc which make calls or receive calls and also deals with the main controller from the case of setting system on , off or armed (some states)
    So there is data transefer between the 3 uc
    from uc1 to uc2 it is 8 bits,
    from uc3 to uc2 it is 8 bits,
    and reverse is da same uc2 to uc1 or uc3 is 8 bits.
    Also each one would be running on different speed. so they are asynchronous.

    hope that code help alil.
    the problem is the transfer time not how to transfer, coz all what i m afraid from is if the uc1( sensor microcontroller ) got an alarm from the ir so it gets out the action of it. suppose it 10110010 and then it finds over heat so it will gets out 10011000. So i m afraid of override of data. as it would not be synchronous with uc1.

    is what i think is wright?!
    thanks for ur care and help guys
     
  9. Eng.Remon

    Eng.Remon New Member

    Joined:
    Dec 13, 2006
    Messages:
    50
    Likes:
    0
    Location:
    Eg.
    what i thought about is something like a batch between each 2 uc.
    just to hold data untill the one reads it then would be deleted, is dat good !? or what?
     
  10. ikalogic

    ikalogic Member

    Joined:
    Dec 27, 2003
    Messages:
    834
    Likes:
    14
    Location:
    Limoges, France
  11. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    What I said in my last post will work for you but you can add msg level checking to make it better.

    To ensure that a msg/signal gets through you can have the receiver echo back the msg/signal to the sender. If the echo does not come back in a reasonable period of time then then msg/signal is resent.
    This closes the loop... because the sender just keeps banging at the receiver till the msg is acknowledged.

    Non of this is new. It is common place.
     
  12. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,324
    Likes:
    653
    Location:
    Derbyshire, UK
    To be honest it seems a fairly trivial requirement?, you could use interrupts if you wanted?, but polling would be many, many times faster than required - it's really a very slow application - as are most 'real world' applications for micro-controllers. It could all quite easily be done by one micro-controller anyway, no need for using three?.
     
  13. Eng.Remon

    Eng.Remon New Member

    Joined:
    Dec 13, 2006
    Messages:
    50
    Likes:
    0
    Location:
    Eg.
    there is alot of interrupts used with the keybad and the sensors , and it is 8051 so just 2int in each uc ,
    Can u give me more informations with UART or something applied wid!?
    thnx
     
  14. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,324
    Likes:
    653
    Location:
    Derbyshire, UK
    If you're using a lot of interrupts you perhaps should reconsider your design?, interrupts can be VERY useful, but that doesn't mean you need to use them for everything - generally it's a bad idea to do so!. There certainly seems no requirement for using interrupts on the sensors, polling would be simpler, and more than fast enough (probably thousands of times faster than required).
     
  15. Eng.Remon

    Eng.Remon New Member

    Joined:
    Dec 13, 2006
    Messages:
    50
    Likes:
    0
    Location:
    Eg.
    u r right in the sensors but think alil about the main uc it is connected to keypad so i have one int in it . but we back to the idea of asynchronous time mechanism between them .
     
  16. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,324
    Likes:
    653
    Location:
    Derbyshire, UK
    Just a UART, either hardware or software, presumably 8051's have hardware UART's?, if not software ones are easy to write.
     
  17. Eng.Remon

    Eng.Remon New Member

    Joined:
    Dec 13, 2006
    Messages:
    50
    Likes:
    0
    Location:
    Eg.
    sorry, but really i dont know what is uart unless what typed here , so can u be more explain of how i should get it if an ic or how i could program it if it is in the Atmel . !!!
     
  18. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,324
    Likes:
    653
    Location:
    Derbyshire, UK
    UART is short for 'Universal Asyncronous Receiver Transmitter', a serial port, most PIC's have them, and it's easy to create one in software if they don't. Presumably there's pleny of 8051 examples available?, check for UART, serial port, or RS232.
     
  19. Eng.Remon

    Eng.Remon New Member

    Joined:
    Dec 13, 2006
    Messages:
    50
    Likes:
    0
    Location:
    Eg.
    ok thnx, i guess i have some info about RS232, i ll revise it again :)
     
  20. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    How close are the chips together? If they are in close proximity you may be better off with somthing other the RS232. That is unless that has been choosen fo you. If you use RS232 U2 will need to have 2 UARTS. If needed the second one can be done in software aks bit banging.

    This is a school project? I do not understand why you have been asked to do communication without first having studied it.
     
    Last edited: Jun 1, 2007
  21. Eng.Remon

    Eng.Remon New Member

    Joined:
    Dec 13, 2006
    Messages:
    50
    Likes:
    0
    Location:
    Eg.
    lol it is a graduation project, So u make things u know and what u dont should know too. dats it any way this is a security system and the chips are not together or close
     

Share This Page