please who can help me for sample code


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Dec 2008
    Posts
    12

    Default please who can help me for sample code

    hello my friend

    please who can help me for sample code to create serial communication between 16f84A to 16f84A when using SEROUT/SERIN
    I want to send a decimal number (0000 to 9999) from one PIC to the other where it's display it on 7 segment display 4 digit as shown in pictur attached


    and thankyou very much

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    I will help you but I will not do it for you, why? Because you learn nothing that way.
    So sit down and figure out what you want the chips to do and in what order, make a block diagram and that is how to start.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Where did you go ? This is what I was talking about:
    Attached Images Attached Images  
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  4. #4
    Join Date
    Feb 2009
    Posts
    26


    Did you find this post helpful? Yes | No

    Default Book

    You should buy the book "Programming PIC Microcontrollers With PicBasic" By Chuck Hellebuyck. There are examples of pic to pic and driving 7 segment displays. With all the explanation behind it.

    Good Luck!

    -Nemesis

  5. #5
    Join Date
    Dec 2008
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    thanks for JOE please excuse me i am begining in programtion of pic and my english is litelle

    i want to send number 4 digit like 1234 or 2564 or 2358 from pic 1684a to anoder 1684a where it's display it on 7 segment display 4 like your diagram
    if you dont understand me i try to explain to you

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi jasem700,
    I understand what you want to do, and it's not too tough. Look at the block diagram and take a swing at what commands you need to use to acheive your goal. For instance, how might you receive some data? You have choices of serin, serin2, hserin, i2cread, . . . pick one!
    then you need a place to store that information, a variable. You are storing a 4 digit number, correct? so the number will not be larger than 9999, and 9999 will not fit into a byte as a byte only holds up to 255 so the next larger variable is a word which will hold up to 65535.
    So in the paragraph above we know we have to store a word so here is how to do it:
    MyVar VAR WORD , you can call the variable almost anything like HOT_COFFEE or WHISKEY make it something meaningful to you, the compiler doesn't care.

    let's try serin as a way to get the number in.
    Code:
    include"modedefs.bas"
    main:
    SERIN PortA.0,T9600,MyVar
    GOTO main
    end
    the code above will receive your number and loop over and over, pretty useless as is,
    you need more code to make it do what you want, but it does get the information.
    Now that you have captured the number you need to isolate the digits, and again you need a place to store those numbers, yep you guessed it variables again, and they will be bytes as they are smaller than 255 ,so let's name them digit, so . . .
    Code:
    include"modedefs.bas"
    digit1 var byte
    digit2 var byte
    digit3 var byte
    digit4 var byte
    MyVar VAR WORD
    main:
    SERIN PortA.0,T9600,MyVar
    GOTO main
    end
    The DIG command isolates which digit you store in the variable like so
    myvar = 1298
    digit1 = MyVar DIG1
    digit2 = MyVar DIG2
    digit3 = MyVar DIG3
    digit4 = MyVar DIG4
    Now you have your number stored in MyVar and have them isolated as individual digits.
    Do you follow so far ?
    Code:
    include"modedefs.bas"
    digit1 var byte
    digit2 var byte
    digit3 var byte
    digit4 var byte
    MyVar VAR WORD
    main:
    SERIN PortA.0,T9600,MyVar
    digit1 = MyVar DIG1
    digit2 = MyVar DIG2
    digit3 = MyVar DIG3
    digit4 = MyVar DIG4
    GOTO main
    end
    As you see, building blocks add code as you need it and the large program begins to materialize.
    Next you have to figure out which port will output your 7 segment display will use, each segment will
    have a port address. Lay out the port in a binary fashion where 1 is on and 0 is off and you can figure out what to
    energise to display the number you want to display. Use a lookup table to assign the port output to achieve this and store in more variables. Let's call those variables Display, so Display1 var BYTE . . . and you would write it like
    LOOKDOWN2 digit1,[ your number for zero, yournumberforone, . . . ],display1
    this will give you the appropriate LED pattern for the number in digit1 variable ready to display.
    then to display you would simply make a statement like portB = display1
    Last edited by Archangel; - 17th February 2009 at 09:39.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  7. #7
    Join Date
    Dec 2008
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    thank you very much Mr joe i have read your reply and I try to apply what you write to me thanks please if you want tell me your email adress please I want to email you ok thannks

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 22:55
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 22:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 9th December 2008, 00:40
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 09:26
  5. Re-Writing IF-THEN-AND-ENDIF code?
    By jessey in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th August 2006, 18:23

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