Digital Compass Project


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

    Default Digital Compass Project

    I recently bought a Honeywell HMR3100 digital compass. It has a serial output which I want to send data to a Serial LCD Module. The data from the compass requires some very simple math in order to get a usable output. I plan to use a 16F84A chip and PICBASIC PRO to control the compass output and perform this simple math function.

    For the compass, I'm using what is called "normal" mode. This requires pin 6 (on the compass chip) to be high and pin 3 (on the compass chip) to toggle (1 ms) in order to get an output from pin 5 (on the compass). I have written code and checked the outputs with LEDS and feel this part of my code is working.

    High 0 'Set pin RB0 high: PIN 6 on compass
    High 1 'Set pin RB1 high: PIN 3 on compass
    Pause 1000 'Delay for 1 second to let compass settle
    Low 1 'Sets pin RB1 low, triggers PIN 3 on compass

    Here is my problem, for now I am just trying to get a correct output from the compass with out the simple math conversion. I wired the output of the compass into RB2 of the 16F84A, B0 is my variable:

    SerIn2 2,4,[B0] '2400 baud: HEX input to RB2

    I then hooked the serial line from the Serial LCD Module into RB3:

    SerOut 3,4,[#B0] '2400 baud: HEX output to RB3


    Unfortunately, all I get is an output of 255 over and over displayed on the LCD. The data is suppose to come out similar to the example below (depending on the direction of the compass):

    80 02 85 (hex)

    fyi- the 80 with be thrown out, the MSB (2) will be multiplied by 256 and added to the decimal conversion of the LSB (85h=133). The total is 645 which is divided by 2. This would equal 322.5 degrees.

    The whole program (without the math conversion):

    'Compass PICBasic PRO program
    B0 VAR WORD
    Main: Pause 500
    High 0 'Set pin RB0 high: PIN 6 on compass
    High 1 'Set pin RB1 high: PIN 3 on compass
    Pause 1000 'Delay for 1 second to let compass settle
    Low 1 'Sets pin RB1 low, triggers PIN 3 on compass
    SerIn2 2,4,[B0] '2400 baud: HEX input to RB2
    SerOut 3,4,[#B0] '2400 baud: HEX output to RB3
    Pause 1 'Delay for 1 ms as per HMR3100 Manual
    GoTo main



    Please Help, I'm new to the PIC programming...

    I'm a hardware engineer stuck in a software kind of world......

  2. #2
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237

    Default

    Your baudrate for serin2 will not be 2400, baudvalue should be 396. You could also just change Serin2 to Serin.

  3. #3
    Join Date
    Aug 2005
    Posts
    57

    Default

    You might try using the timeout function with the serin command.There's a good possibility that when the compass is triggered for data,the pic program has moved on before the data arrives.Also you could set the trigger low for continous data until troubleshooting is complete.If you only want to read data once,use the pulsout command for the trigger.

Similar Threads

  1. Digital clock project
    By astouffer in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 27th February 2009, 03:00
  2. Digital Out on an A/D pin safe ?
    By mr.sneezy in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st January 2009, 22:48
  3. A Temperature & Humidity Data Recorder Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 9th July 2008, 18:47
  4. I2C Comm with Digital Compass HMC6352
    By jihlein in forum Serial
    Replies: 10
    Last Post: - 9th April 2008, 22:25
  5. Digital IC Tester
    By precision in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th September 2006, 03:38

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