Digital Counter: Defining digits array to be displayed with custom LCD

Hello, I have a custom LCD (no LCD driver just a bare and multiplexed LCD) with this mapping


l2

this is my reference document in learning to interface with LCD: [see page 19] https://www.ti.com/lit/an/slaa654a/slaa654a.pdf?ts=1690892767609&ref_url=https%253A%252F%252Fwww.google.com%252F

Now, I have this memory mapping wherein unlike in the document that a single digit is controlled by a single LCDM, mine has to be a LCDM 1.5 as a single digit in my LCD is controlled by 3 segments. I am having a hard time in making a definition for each digit in each position in the LCD.

This digit will be incrementing as this is for a counter.

I'm not sure what you mean. I've not checked for all the possible segments (seems F, B, E and C of the first digit cannot be turned on)

it seems to turn on one segment you need to create the circuit between one of the bottom pins and one of the top COM port

so it's one pin HIGH, one pin LOW and making sure you don't power the rest and then cycling fast enough to create the illusion (retinal persistence) that all the segments are turned on at once.

if you know the type of LCD maybe there is a library already
anyway i would recommend MAX7912 to control this matrix

I was questioning the

The way I see it is that the LCD segments are "controlled" by the pins at the bottom and the COM pins at the top. The segments are not controlling anything

I am making a look up table as I will be using MSP430 microcontroller that has built in lcd driver.

I tried to make this one

unsigned char digits[10][3] = {
    { 0x0c, 0x0a, 0x0c}, // 0 
    { 0x00, 0x00, 0x0c}, // 1 
    { 0x04, 0x0e, 0x08}, // 2 
    { 0x00, 0x0e, 0x0c}, // 3 
    { 0x08, 0x04, 0x0c}, // 4 
    { 0x08, 0x0e, 0x04}, // 5 
    { 0x0c, 0x0e, 0x04}, // 6 
    { 0x00, 0x08, 0x0c}, // 7 
    { 0x0c, 0x0e, 0x0c}, // 8 
    { 0x08, 0x0c, 0x0c}, // 9 
    { 0x00, 0x00, 0x00}, // OFF
};

void update_counter (int counter_value)
{
int d2 = ...
int d3 = ...
int d4 = ...

LCDM1 = (digits[d4][1] << 4) | (digits[d4][0] << 0); 
LCDM2 = (digits[d3][0] << 4) | (digits[d4][2] << 0); 
LCDM3 = (digits[d3][2] << 4) | (digits[d3][1] << 0); 
LCDM4 = (digits[d2][1] << 4) | (digits[d2][0] << 0); 
LCDM5 = (digits[d1][0] << 4) | (digits[d2][2] << 0); 
LCDM6 = (digits[d1][2] << 4) | (digits[d1][1] << 0);
}

I don't know what to set in d2 to d4 inside the void_counter

I am having a hard time in this logic that if buttonA is pressed, count should increment, and if buttonB is pressed, count should decrement.

byte d2= counter_value/100;
byte d3= (counter_value/10)%10;
byte d4= counter_value%10;

what should this do?

your display is a matrix 9x3 pins. a cycle should scan thru 3 Com pins and proper segment dependent of d2/d3/d4 need to be activated

just to clarify, it should be byte instead of int?


image

Sorry I haven't went back on this post but there is this small changes where Y and A are added (MIN/MAX removed) so it will now be 4 com pins

and this LCDM1 to LCDM6 is allocation of LCDM register of MCU digit display as a single digit occupies 1.5LCDM
here's what I tried to do with that:

unsigned char digits[10][3] = {
  { 0x0c, 0x0a, 0x0c}, // 0
  { 0x00, 0x00, 0x0c}, // 1
  { 0x04, 0x0e, 0x08}, // 2
  { 0x00, 0x0e, 0x0c}, // 3
  { 0x08, 0x04, 0x0c}, // 4
  { 0x08, 0x0e, 0x04}, // 5
  { 0x0c, 0x0e, 0x04}, // 6
  { 0x00, 0x08, 0x0c}, // 7
  { 0x0c, 0x0e, 0x0c}, // 8
  { 0x08, 0x0c, 0x0c}, // 9
  { 0x00, 0x00, 0x00}, // OFF
};

void update_counter (int counter_value, bool sA, bool sY, byte Dig1, bool sPower){
  byte d2 = counter_value / 100;
  if(!d2)d2=10;
  byte d3 = (counter_value / 10) % 10;
  if(!d2 && !d3)d3=10;
  byte d4 = counter_value % 10;

  LCDM1 = digits[d4][1] << 4 | digits[d4][0]);
  LCDM2 = digits[d3][0] << 4 | digits[d4][2] ;
  LCDM3 = digits[d3][2] << 4 | digits[d3][1] | sA;
  LCDM4 = digits[d2][1] << 4 | digits[d2][0] ;
  LCDM5 = (Dig1 & 0x07) << 5 | digits[d2][2] ;
  LCDM6 = sPower << 2 | sY << 4);
}

May I ask why is there sA, sY and changes in LCDM3, LCDM5, and LCDM6?

savvy?

is something wrong?

Yes, the logic does not work as expected.

i am happy that it works at all. so how unexpected logic looks like?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.