Problem with "DIG"


Closed Thread
Results 1 to 3 of 3
  1. #1
    Futterama's Avatar
    Futterama Guest

    Default Problem with "DIG"

    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?

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    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;
    Code:
    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?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Futterama's Avatar
    Futterama Guest


    Did you find this post helpful? Yes | No

    Default

    Hi,

    I made it work now, thanks :-)

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

Similar Threads

  1. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  2. Microcode Studio 18f2455 problem?????
    By volkan in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 21st May 2007, 21:04
  3. Hardware problem or what ?
    By Steve S. in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 4th March 2007, 21:39
  4. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 22:59
  5. PORTA.PinNo = 1 ' problem
    By frank small in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 6th May 2004, 14:30

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