PDA

View Full Version : Problem with "DIG"



Futterama
- 14th July 2005, 22:22
Hi all,

I'm having trouble using the DIG function.

I have a byte array, and I want to fill it with the digits from a measurement from PulsIn. So I have the following code:

RX VAR BYTE[4]
MeasureResult VAR WORD

PulsIn PORTB.5,1,MeasureResult

RX[0] = MeasureResult DIG 3
RX[1] = MeasureResult DIG 2
RX[2] = MeasureResult DIG 1
RX[3] = MeasureResult DIG 0

The problem is, that whenever "MeasureResult" is more than 2048, DIG simply doesn't work. I've tried to make some dummy code to locate the problem and to find the "limit" of 2048. I simply replace the PulsIn statement with "MeasureResult = 2050" and the thing won't work. If I set MeasureResult to 2048 and below, it works kinda (it screws up some of my other code, but this is not the main issue).

What is wrong here?

Bruce
- 15th July 2005, 03:30
The DIG operator should work regardless of the number value, but it only works with the right-most digits 0 to 4.

Try something like this to test it;


Main:
MeasureResult = 62928
RX[0] = MeasureResult DIG 4
RX[1] = MeasureResult DIG 3
RX[2] = MeasureResult DIG 2
RX[3] = MeasureResult DIG 1
RX[4] = MeasureResult DIG 0
HSEROUT ["MeasureResult = ",DEC5 MeasureResult]
HSEROUT [" DIG's = ",DEC RX[0],DEC RX[1],DEC RX[2],DEC RX[3],DEC RX[4],13,10]
HERE:
GOTO HERE

Returns; MeasureResult = 62928 DIG's = 62928 with PBP v2.46
What version are you using?

Futterama
- 15th July 2005, 21:19
Hi,

I made it work now, thanks :-)

PS. I'm using version 2.45,(c)