View Full Version : helooo........
tkly36
- 11th April 2006, 10:05
' 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 :)
........
mischl
- 11th April 2006, 12:07
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 ....
tkly36
- 11th April 2006, 12:35
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...
mischl
- 11th April 2006, 12:58
use a word instead a byte...
word = 16 bit = 2 byte
tkly36
- 11th April 2006, 13:03
sorry...
i still dont understand..
may be you can show me some correction on my coding...so i can learn...
mischl
- 11th April 2006, 13:19
take this elements in your 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
tkly36
- 11th April 2006, 16:29
to mischi
thank you for helping me..
willing to help me to understand..
may god bless you... :)
picster
- 12th April 2006, 17:54
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--------------
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.