Shop OBEX P1 Docs P2 Docs Learn Events
2914_altimeter object in combination with LCD_Ding_Batty gives strange result *SOLVED* — Parallax Forums

2914_altimeter object in combination with LCD_Ding_Batty gives strange result *SOLVED*

JeroenGJeroenG Posts: 5
edited 2015-09-04 18:25 in Propeller 1
Hi everyone,

I have a HD44780 lcd where I want to display altitude on.
Using the spin object of Ding-Batty (http://obex.parallax.com/object/337) I'm able to display text, and I've already used it to display gps information.
When I however call the start function of the 2914 Altimeter object (https://www.parallax.com/downloads/altimeter-driver-and-demo-spin-source-code) the display is showing strange things.
Sometimes it displays space characters in between the text (e x a m p l e), and sometimes also strange characters.

I confirmed that both objects work fine separately, but not together.
Unfortunatly I'm still a newbie on spin, and I have no clue on why this happens.

I attached the test project that I used to verify the problem.
Is there anyone who can help?

Thanks
Jeroen

Comments

  • If I get a chance later tonight I'll take a look. I'm not familiar with the code for the altimeter...
  • Ding-BattyDing-Batty Posts: 276
    edited 2015-09-03 03:22
    I was able to reproduce the problem (with a different display and no altimeter hardware).

    It looks like there's a bug in the 29124 Altimeter object code. In the start_explicit() function, the code tries to set the resolution to 1024, but it does this before initializing I2C or access to the altimeter, which I think results in collecting samples() using incompletely initialized variables.

    I moved the call to set_resolution() in the start_explicit() code that should be sufficient to fix the problem:
    PUB start_explicit(sc, sd, bkgnd) | i
    
      {{ Start the object using a prescribed pinout for SCL and SDA.
      ''
      '' `Parameters:
      ''
      ''     `sc: Pin number for SCL. Can be bitwise ORed with the constant `MS5611 to use that chip.
      ''     `sd: Pin number for SDA. Can be bitwise ORed with the constant `MS5611 to use that chip.
      ''     `bkgnd: `true to start background acquisitions, `false not to.
      ''
      '' `Return: 255 or the cogid + 1 of the background process on success, 0 on failure.
      ''
      '' `Example: alt.start_explicit(7, 8 | alt#MS5611, false)
      ''
      ''     Start the object using P7 for SCL and P8 for SDA, but do not start a  background
      '-     process. Use the MS5611 chip, rather than the default MS5607
      }}
    
      stop
      sea_press := SEA_PRESS_STA
    '  set_resolution(RES_1024)      ' <<<<--- I removed this line
      scl := sc & $1f
      sda := sd & $1f
      dev5611 := (sc | sd) & $80
      ptr~
      _i2c_init
      _i2c_send_cmd(CMD_Reset)
      waitcnt((clkfreq >> 3 #> 400) + cnt)
      repeat i from 0 to 5
        c1[i] := _read_prom(i + 1)
      started~~
      set_resolution(RES_1024)     ' <<<<---- and added the line back here
      samples
      if (bkgnd)
        if (lock := locknew + 1)
          ifnot (started := cognew(_do_background, @stack) + 1)
            lockret(lock - 1)
      return started
    

    By the way, the LCD display code was some of the first code I wrote for the Propeller -- well actually it is the second version of the code, the first version was terrible :)
  • I'll give it a try. Thanks for looking into this. I appreciate it.
    Nowedays the serial displays are more common, but I had this one lying around, so always good to see other people also still use them.
  • That indeed seems to do the trick.
    Thank you!
  • Good news!

    Please share your working project so that more new people can learn from it.

Sign In or Register to comment.