A Bit manipulation brain teaser for you :)


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    how the data is sent? Did you tried to attach your radio directly to a PC? Maybe he just send you ASCII string or HEX value?

    in fact it could make sense... let's assume it send you 4 Bytes...
    30,000.000
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #2
    Join Date
    Jan 2007
    Posts
    78


    Did you find this post helpful? Yes | No

    Default

    Yes, the device is setup to talk to a PC.
    The PC queries the device for its set frequency, and the device returns the 4 bytes.

    I know I should push the 4 bytes into 2 seperate 16 bit words.
    Then I need to figure out what the decimal part is for:

    Millions
    Thousands
    Hundreds

    This seem pretty straight forward for a 1 byte word, but no so easy for me to get my head around doing it for 2 bytes, due to the carry effect.

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    if you have a LCD, you can do a simple test

    Code:
            HSERIN [ByteA, ByteB, ByteC, ByteD]
            LCDOUT $FE,1, HEX2 ByteA, HEX2 ByteB, HEX2 ByteC, HEX2 ByteD
    What's happen using that?

    Any model or link to your radio?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Jan 2007
    Posts
    78


    Did you find this post helpful? Yes | No

    Talking

    I think I got it !!!

    I created a program using VB which simulates the PICSs math processing.
    I realized that.
    1. Even though there are 32 bits sent all together, only 26 of them are used.
    Since the devices highest achievable number is 30,000,000.

    2. The 5 highest bits with their corresponding multipliers directly effect the 1,000,000s place.

    3. The 16 highest bits with their corresponding multipliers directly efffect the 1,000s place.

    4. 18 of the bits directly effect the 100s place

    So what I do is create 3 bytes.
    Symbol MHZ = B5 (8 bit word)
    Symbol KHZ = W3 (16 bit word)
    Symbol Hz = W4 (16 bit word)

    Then I go down through the 26 bits 3 times.
    The first run down looks at each bit and applies that bits MHZ multiplier adding these values to MHZ

    The second run looks at each bit and applies that bits KHZ multiplier adding these values to KHZ
    Any time KHZ goes > 999, I do the appropriate carry to MHZ

    The third run looks at each bit and applies that bits HZ multiplier adding these to the HZ value
    Any time HZ goes > 999, I do the appropriate carry up through KHZ and MHZ.

    Now all I have to do is transfere this code into PBC.
    I hope to get that done tonight.
    ** this is where a simulator program comes in real handy!! **

    My next step on this project is to slice some specific frequency windows into numbered slices so that the pic can control a second device based on a reading falling within a specific slice.

    I love this stuff!!!!

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. How to receive stream of bytes using PIC USART
    By unifoxz in forum mel PIC BASIC Pro
    Replies: 34
    Last Post: - 20th June 2009, 10:38
  3. Sleep Mode
    By Pesticida in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th March 2008, 10:31
  4. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 00:55
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

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