helooo........


Closed Thread
Results 1 to 8 of 8

Thread: helooo........

  1. #1
    Join Date
    Feb 2006
    Posts
    14

    Default helooo........

    ' using pic16f84 and 4Mhz
    `~~~~~~~~~~~~~~~~~~~~~~~~~```

    INCLUDE "modedefs.bas"

    w0 var word[2]
    b0 var w0.byte0
    b1 var w0.byte1

    DEFINE OSC 4
    pause 1000
    start:

    SerOut PORTA.3,t2400,["input a number",13,11]
    serin PORTA.2,t2400,b0,b1
    pause 1000

    SerOut PORTA.3,t2400,[" the number are",w0,13,11]

    where is my mistake?
    i try to input a 2 number example '56'

    the output only show '5' the first number that i input

    what should i do to correct it

    ........

  2. #2
    Join Date
    Jan 2005
    Posts
    72


    Did you find this post helpful? Yes | No

    Default

    becuase i'm not sure without testing, try this :

    SerOut PORTA.3,t2400,[" the first number is : ",b0,13,11]
    SerOut PORTA.3,t2400,[" the second number is : ",b1,13,11]

    if this works, you know that the w0 item only gives the first (low) byte back.
    try then something like that : w0.byte0, wo.byte1 ....
    i know it's only microcontrolling, but i like it!

  3. #3
    Join Date
    Feb 2006
    Posts
    14


    Did you find this post helpful? Yes | No

    Default mischl thank you..

    mischl thank you for the reply..

    now i try to build a dc motor posisition control system..

    the first thing i want to do is to make the PIC accept a number range from 1 to 360..

    the problem is how the PIC will accept number from 1 to 360 in single variable..?

    can any body show me some sample using STD...in serin2.?

    please help me...

  4. #4
    Join Date
    Jan 2005
    Posts
    72


    Did you find this post helpful? Yes | No

    Default

    use a word instead a byte...

    word = 16 bit = 2 byte
    i know it's only microcontrolling, but i like it!

  5. #5
    Join Date
    Feb 2006
    Posts
    14


    Did you find this post helpful? Yes | No

    Talking sorry...

    sorry...

    i still dont understand..
    may be you can show me some correction on my coding...so i can learn...

  6. #6
    Join Date
    Jan 2005
    Posts
    72


    Did you find this post helpful? Yes | No

    Default you are welcome

    take this elements in your code

    Code:
    number 	var 	word 	' a word sized variable with 2 bytes
    
    
    	number = 350	' give them the max value for testing
    
    
    	serout PORTA.3,t2400,[" the number are : ", number.byte0, number.byte1,13,11]
    you receive now two values : 94 and 1. this two must be added

    byte0 and byte1 has both a range from 0 to 255 (1byte = 8bit). but byte0 is the lowbyte and means really 0 to 255, but byte1 means how many times the value of 256. 256 is the value which is coming after 255 when byte0 is full.

    some examples.

    number = 0 : byte0 = 0, byte1 = 0 ' the minimum
    number = 1 : byte0 = 1, byte1 = 0
    number = 199 : byte0 = 199, byte1 = 0
    number = 255 : byte0 = 255, byte1 = 0
    number = 256 : byte0 = 0, byte1 = 1
    number = 266 : byte0 = 10, byte1 = 1
    number = 65536 : byte0 = 255, byte1 = 255 ' the maximum
    i know it's only microcontrolling, but i like it!

  7. #7
    Join Date
    Feb 2006
    Posts
    14


    Did you find this post helpful? Yes | No

    Cool thank a lot....

    to mischi
    thank you for helping me..
    willing to help me to understand..

    may god bless you...

  8. #8


    Did you find this post helpful? Yes | No

    Default confused...

    first of all, you've defined w0 as a 2 word array... and then later in the program you don't refer to the array element you want [0 or 1]. I think you need to drop the [2] part in your variable definitions, so you just have a standard single word variable.

    I am confused as to what you're trying to output. You should get a word sized number out (56 should give you 1541 as a result).

    -------------Picster--------------

Members who have read this thread : 0

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