Shop OBEX P1 Docs P2 Docs Learn Events
Object Question — Parallax Forums

Object Question

Need a refresher/review on using "objects". I have a spin file called "HMC5883L_data" that is a trimmed version of the "HMC5883" file downloaded from Parallax. I trimmed it down to read/display the Azimuth. The second file, "HMC5883Compass" is the start a spin file in which I hope to take the Azimuth and use it to calculate additional variables. The issue as it stands is I'm having difficulty bringing the Azimuth value into the second file. As the file is now I keep getting a "Expected Subroutine Name" error.
I ask for guidance on what I need to do to correct this.
Thank you for your help!!

Comments

  • The compiler is telling your the problem: What is the name of the method call that triggers that error (the line will be highlighted in Propeller Tool)?
  • The compiler highlights the following line;
    HMC.start(aziadjust) the word "start" is highlighted. The "aziadjust" is the subroutine in the "data" code that calculates the azimuth. Tried a variety of configurations on the line to call the object.
    Thanks
  • I looked at your code but cannot help because you didn't include the whole project -- it's not safe to assume that everyone has all the same libraries you do. You may want to archive your project and upload that for others to have a look.
  • I've attached the project archived. What my goal is to get the "azimuth" value from HMC5883L_Data to HMC5883Compass. I hope to use that value. Presently when I run the HMC5883Compass code, it compiles with no errors but printing on the serial terminal, x = 0. I've tested the hardware setup and know that it is reading the value; (using a demo code that was downloaded from the Parallax website).
    Again thank you for your help!!
  • The azimuth method is only able to perform the conversion after new data is requested from the sensor. Try modifying your main to:
    PUB Main
    
      waitcnt(clkfreq/100_000 + cnt)      'Wait while compass has time to startup.
      HMC.SetCont
      pst.start(31, 30, 0, 9600)
      
      Repeat
        HMC.GetRaw                        'Gather raw data from compass
         x := HMC.Azimuth
         pst.Str(String("Degrees = "))
         pst.Dec(x)
         WaitCnt(ClkFreq / 2 + Cnt)
         pst.tx(13)
    
  • Awesome! That did it!
    Thank you very much!!
Sign In or Register to comment.