Embedded Systems Based help

Discussion in 'Embedded Systems and Microcontrollers' started by indianhits, Feb 11, 2010.

  1. indianhits

    Thread Starter Active Member

    Jul 25, 2009
    86
    0
    hello i am currently learning about MC's specially 8051 family by using internet as source.Now i am having some doubts regarding the MC's like what is the meaning of "interrupt"? and what is the use of it? & i want to connect my PC to my MC's circuit using USB(PC) to UART(MC) so will i need any convertor that will convert my PC's USB signal to UART signal.Not for code dumping i want to control my MC using my PC


    correct me if i am wrong as i am new to this

    Thank you!
     
  2. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Interrupts simply interrupt what the MCU was doing to respond to an event (pin change, timer overflow, etc) so it can service the event and then go back to what the MCU was doing before. You can write programs without using them (they are optional) but sometimes it simplifies things.

    If your pc doesen't have a serial port you will need something like this:

    http://cgi.ebay.co.uk/USB-2-0-to-Se...uting_CablesConnectors_RL?hash=item439d396811

    and also a max232 chip or similar to convert the MCU's logic level signal to the correct levels.
     
  3. maxpower097

    Well-Known Member

    Feb 20, 2009
    795
    388
    An interupt basically tells the cpu to stop what its doing and check out what happened. So say you have a timer interupt. When the timer runs out it causes an interupt. The CPU then jumps to the interupt service routine and either does what the routine wants and goes back to normal code, or doesn't. Not sure about the 8051 but the pics use a priority system for this. If the interupt has a higher priority then the cpu it runs the interupt. If the interupt has a lower priority then the cpu, the cpu continues normal operation. Basically in the most simple terms think of interupts like alarms to tell your mcu something has happened, or to go do something else.
     
  4. indianhits

    Thread Starter Active Member

    Jul 25, 2009
    86
    0
    thanks a million

    so UART is noting but our RS232(i.e like our computer monitor i guess correct me if i am wrong.Thanks)

    And is this possible or should i use interrupt:-
    i want to calculate the total power consumed by a bulb for 1 hour (or till i keep the switch ON).so let it calculate

    Now i want to send and receive data simultaneously(every 5 seconds(power/5 sec)) about the power consumed by the bulb till it is kept ON to the Computer

    So can i Multitask or should i buy 2 MC's.one for calculating power and other for sending & receiving data.cause while it is calculating power/sec if i interrupt then the that second power will not be recorded

    This is not a project.i really believe that until i do something by practical i can't understand anything.

    please help me thanks
     
  5. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Some UARTS have other protocols as well )like I2C for talking to memory chips, digital sensors, etc) but don't worry about that for now.
    The monitor connector is not RS232 although it looks superfically similar. RS232 connector is 9 pin and some newer computers don't have them. They used to be used for connecting to mice, modems, etc. You can use Realterm or Hyperteminal to connect with it or write something in VB or similar.

    This is easily possible on one MCU, although I'd suggest starting simple and working up.
    Flash an LED every five seconds, send 'Hello world' from the MCU to the PC over RS232, etc.
    Make sure you have all the datasheets, and find some working programs to examine.
     
  6. indianhits

    Thread Starter Active Member

    Jul 25, 2009
    86
    0
    thank you very much!

    and i have doubt on one thing that is

    Now i have referred to many books,e-books but did not understand this

    say i want to receive data from MC.Now how will the data arrive in my computer.since this is a 8bit MC i guess 8bit of data arrives in my PC now how do i convert this binary to human understandable language like as above mentioned i want to receive "Hello World" from my MC.Do i need to create a driver to receive data????then how????

    please help me

    and there is 4 different I/O ports in 8051 like p0,p1,p2,p3 each having 8 pins.so when i receive data from MC i must connect all the pins related to p0(like from p0.1,p0.1,p0.2,.....p0.7)if i am making use of p0.am i correct???so that i can receive all the 8 bits from these 8 pins right???

    Thanks!!!!
     
  7. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Not quite, the data is sent 1 bit at a time along 1 wire. Recieved data is on another wire, 1 bit at a time. You only need 2 pins for a 2 way connection.
    The uart deals with all that so you just put the byte you want to send in a register and tell the MCU to send it.
    If you download Realterm (freeware) that should be enough for the PC end of things for now. It just sends what you type and displays what it has recieved.
     
  8. indianhits

    Thread Starter Active Member

    Jul 25, 2009
    86
    0
    ok now i get it so if i want to send any data to My Computer i use for example p0.0 and for receiving something from My Computer i use p0.1 or even p0.3 as per my wish(as per my code as i wish) right

    and i know how to program in C can i create my own program that will communicate with my USB ports(i.e.RS232 as i am converting from RS232 to USB cable)

    and i don't know about this cause i asked many people about this but none had any idea.can i use My Computer's USB WIFI Adapter to connect to a WIFI Router and inturn connect to my MC to send and receive data???any idea about that???

    Thanks i am really learning about MC's thanks!!!

    Specially Markd77 sir and even maxpower097 sir thanks!.Hope to become like you soon.
     
    Last edited: Feb 12, 2010
  9. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    There are probably 2 specific pins on the MCU for send and recieve, the datasheet for your 8051 will tell you.
    Once you plug the RS232-USB converter in and install the driver, you will be able to use it as if it was a normal RS232 port - there is no need to worry about the USB bit, Windows does that for you.

    I don't know about WIFI.
     
  10. indianhits

    Thread Starter Active Member

    Jul 25, 2009
    86
    0
    so i just need to create my own C program that will read/write data from specific USB port

    i.e i type in my MC as "Hello World" and it will be converted to a Binary value and this binary value value will be sent to My Computer using RS232 to USB port of my computer and windows will convert this binary value back to "Hello World" and i just need to create a program that will receive the data and print "Hello World" on the screen.
     
  11. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Yes, that should work fine. I'd still recommend downloading realterm or using Hyperteminal if you have it, just to test that the MCU side of things is working.
     
  12. indianhits

    Thread Starter Active Member

    Jul 25, 2009
    86
    0
    k thanks a million really cleared up many things

    #include<stdio.h>
    void main()
    {
    while(1)
    printf("Thanks a millon");
    }
     
  13. indianhits

    Thread Starter Active Member

    Jul 25, 2009
    86
    0
    Is this correct.The one write indicates reading and other indicates writing(i.e using RS 232 ofcourse)

    [​IMG]


    and consider if i am sending "Hello World" from MC to My Computer then in computer it goes to the RAM(via USB)and stores there.But how do i know in Which memory location so that my Driver can extract data from the memory location and when i extract data will it be "Hello World" or like"00111010101101010"

    Similarly can i connect the two wires in any other ports like for example p1.2 and p1.3

    please help me the last thing i want to know!
    Thanks!!!!
     
  14. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    You are going to need a MAX232 chip or similar in between the PC and computer to convert the voltage levels. Probably the best thing to do for the PC program is to find some open source software that does a similar thing.
    It looks like those are the correct pins. The other pins will not work with the UART.
     
  15. indianhits

    Thread Starter Active Member

    Jul 25, 2009
    86
    0
    thank you sir and can you explain me about this part.

    "consider if i am sending "Hello World" from MC to My Computer then in computer it goes to the RAM(via USB)and stores there.But how do i know in Which memory location so that my Driver can extract data from the memory location and when i extract data will it be "Hello World" or like"00111010101101010"

    Similarly can i connect the two wires in any other ports like for example p1.2 and p1.3"
     
    Last edited: Feb 14, 2010
  16. Header

    New Member

    Nov 15, 2009
    5
    0
    If you used a program such as Hyper Terminal, you would not need to interpret the data from RAM at all. The program does that for you. You cannot change the location of the RX and TX pins because they are hardwired to that location by the chip itself.
     
Loading...