Shop OBEX P1 Docs P2 Docs Learn Events
AdaFruit 14 segment display with Propeller — Parallax Forums

AdaFruit 14 segment display with Propeller

David BetzDavid Betz Posts: 14,511
edited 2018-10-05 22:35 in Propeller 1
Has anyone tried using this part with the Propeller?

https://www.adafruit.com/product/1911

It looks like it ought to be possible to supply 3.3v as Vi2c and 5v as VCC and have it work but I haven't been able to get it to do anything. I don't even get i2c ACKs back when I send it commands. I'm using the SimpleIDE i2c code below:
#include "simpletools.h"
#include "simplei2c.h"

#define SCL         9
#define SDA         10

#define I2C_ADDR    0xe0

#define HT16K33_ADDR            0x00
#define HT16K33_OSC_ON          0x21
#define HT16K33_BLINK_CMD       0x80
#define HT16K33_BLINK_DISPLAYON 0x01
#define HT16K33_BLINK_OFF       0
#define HT16K33_BLINK_2HZ       1
#define HT16K33_BLINK_1HZ       2
#define HT16K33_BLINK_HALFHZ    3

#define HT16K33_CMD_BRIGHTNESS  0xe0

uint8_t turnOn[] = { HT16K33_OSC_ON };
uint8_t blinkOff[] = { HT16K33_BLINK_CMD | HT16K33_BLINK_DISPLAYON };
uint8_t fullBrightness[] = { HT16K33_CMD_BRIGHTNESS | 15 };
uint8_t cmd[] = { HT16K33_ADDR, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

terminal *term;

int main(void)
{
  i2c i2cBus;
  i2c *dev;
  
  term = simpleterm_pointer();
  
  dev = i2c_open(&i2cBus, SCL, SDA, 0);
  
  SendCmd(dev, turnOn, sizeof(turnOn));
  SendCmd(dev, blinkOff, sizeof(blinkOff));
  SendCmd(dev, fullBrightness, sizeof(fullBrightness));
  SendCmd(dev, cmd, sizeof(cmd));
  
  while (1)
    ;
  
  return 0;
}

void SendCmd(i2c *dev, uint8_t *cmd, int len)
{
  int sts;
  i2c_start(dev);
  sts = i2c_writeByte(dev, I2C_ADDR);
  while (--len >= 0)
    sts += i2c_writeByte(dev, *cmd++);
  i2c_stop(dev);
  dprint(term, "sts %d\n", sts);
}  

Comments

  • jmgjmg Posts: 15,144
    David Betz wrote: »
    Has anyone tried using this part with the Propeller?
    Nope.
    With no ACK, did you try a sweep of all i2c address, to see if any generate ACK-after-address ?
    Sometimes i2c addr is not quite the same as docs...

  • JonnyMac wrote: »
    I have used it several times.
    Thanks! Unfortunately, I'm still not having much luck. Here is the code I wrote using your objects. I have a 4.7k pull-up on both SCL and SDA. If I run this I see nothing on the displays. What dumb mistake am I making?
    CON
      _clkmode = XTAL1 + PLL16X
      _clkfreq = 80000000
      
      SCL = 9
      SDA = 10
    
    OBJ
      display : "jm_ht16k33_4x14segs"
        
    PUB main
      display.startx(SCL, SDA, 0)
      display.set_display(1, 0)
      display.set_brightness(15)
      display.direct_write(0, $ffff)
      display.direct_write(3, $aaaa)
      display.refresh(4)
      repeat
    

  • Jeff HaasJeff Haas Posts: 418
    edited 2018-10-06 04:50
    David, I have a guess...in calling startx, I think the device parameter needs to be in a different format:
    pub startx(scl, sda, device)
    
    '' Starts i2c display device
    '' -- scl is the device SCL pin
    '' -- sda is the device SDA pin
    '' -- device is address, %000 to %111
    
  • David,

    Your code works fine for me...changing the bits displayed affects it as expected, too, so I know it's not just a fluke poweron glitch that makes it look like it's working.
    I don't think you need pullups, though...most (or all?) of her I2C breakout boards have pullups on them, already. Have you tried without them? Also, the supply connection (+) that is 2nd in from the edge of the board is the one that works for me (don't have the schematic handy, so not sure what the leftmost one on the edge is supposed to be - it doesn't work for me...or it does, but very dimly), so that'd be another thing to check.

    Cheers,
    Jesse
  • I removed the pull-up resistors and now it seems to work for me as well. Here is how I have it wired:
    SCL -> P9
    SDA -> P10
    GND -> GND
    VCC -> 5V
    Vi2c -> 3.3V
    

    My understanding is that the Vi2c pin defines the logic level and that the VCC pin powers the LEDs.
  • Actually, I spoke too soon. My code *sometimes* works. In fact, only occasionally.
  • Another thing that is odd is that if I comment out the "display.refresh(4)'' line the LEDs are much brighter but they still only work occasionally.
  • I moved the VCC wire to 3.3v and now it seems to work reliably although at a lower brightness. Maybe you can't really supply the module with two voltages even though the documentation says it should work.
  • I don't see a change in brightness here if I remove it, but I think the refresh method is only necessary if you're using buffered writes (i.e., if using put_buf), where it wouldn't actually update the display until you called refresh, but with direct_write, it sends the bits right out to the bus. Interesting re: the dual voltages...will have to try that here to see.
  • Yes, you're right about the refresh method. It isn't needed if you do direct writes. I'm not sure why I see a difference in brightness
Sign In or Register to comment.