Repair DIBAL M350 by using STM32F103

What are you developing?
Post Reply
poiuycat
Posts: 17
Joined: Tue Aug 22, 2017 4:53 pm

Repair DIBAL M350 by using STM32F103

Post by poiuycat » Wed Sep 13, 2017 5:54 pm

My friend sent me this DIBAL M350 see if I can make it work.
After few hour checking the problem that I found some damage part I have to replace.
1. Thermal Print Head.
2. Printer driver board chip.
3. 8085 CPU.


Those chip can be buy at the shop except print head are obsolete even the 2nd hand part also cost me more that 100 dollars. So I am thinking if I can replace other cheap thermal printer just only about 20 dollars but due to the old 8085 are direct drive to the printer that I cannot replace any kind of USB or serial port printer on it. To make it work I have to use other MCU to hook up those display and keyboard and the final result to printer. So lets get started….

HOW many pin I need ?
1. IC7135 ======== 12 pin
2. LCD display ==== 6 pin
3. 7 segment =====20 pin
4. Keyboard ====== 8 pin
5. Printer ======= 2 pin
Total about 48 pin.

What board do I need ?
1. RTC clock
2. More RAM to store up to 10 customer order. About 1kbyte each customer.
3. Flash memory to store PLU.
Finally, I decided using CZ miniSTM32F103VE-EK
http://www.stm32duino.com/viewtopic.php?f=28&t=2492
Image

Image

Driving ICL7135 chip
It convert the load cell into 1+4digit BCD.
To driving the ICL7135 we need a clock between 120KHz ~ 400KHz
So we use PWM to generate the clock.

Code: Select all

  uint16_t prescaler = 1;          // 72 Mhz
  uint16_t overflow = 240;         // divide 240  = 300Khz
  timer_set_prescaler(&timer4, (uint16)(prescaler - 1));
  timer_set_reload(&timer4, overflow);
  pwmWrite(CLK, 120);              // 50% cycle of 240
using STROBE as interrupt input

Code: Select all

void ICL7135::getADC() {
  pinstate = digitalRead(DP1);
  pinstate |= digitalRead(DP2) << 1;
  pinstate |= digitalRead(DP3) << 2;
  pinstate |= digitalRead(DP4) << 3;
  pinstate |= digitalRead(DP5) << 4;

  BCDvalue = digitalRead(BCD1);
  BCDvalue |= digitalRead(BCD2) << 1;
  BCDvalue |= digitalRead(BCD4) << 2;
  BCDvalue |= digitalRead(BCD8) << 3;
  //Serial.println(pinstate,BIN);
  switch (pinstate) {
    case 16:
      ADCvalue = BCDvalue * 10000;
      break;
    case 8:
      if (oldstate != 16)  return;
      ADCvalue += BCDvalue * 1000;
      break;
    case 4:
      if (oldstate != 8) return;
      ADCvalue += BCDvalue * 100;
      break;
    case 2:
      if (oldstate != 4) return;
      ADCvalue += BCDvalue * 10;
      break;
    case 1:
      if (oldstate != 2) return;
      ADCvalue += BCDvalue;
      stringComplete = true;
      if (digitalRead(ORR) == HIGH) {
        //Serial.println("OVERLOAD");
        weightValue = "OVERLOAD";
        return;
      }
      if (digitalRead(POL) == HIGH) {
        ADCvalue = -ADCvalue;
      }
      if (TAZ == 0) {
        resetTAZ();
        return;
      }
      weight = (ADCvalue - TAZ) * Tscale;
      if (weight!=0) {
         weight = ((weight % 5) == 0 ? weight / 5: weight / 5 + 1) * 5;
      }
      if (weight > -ECC && weight < ECC) {
        weight = 0; // Error correction by ECC
        autoTAZ();
      }
      price = weight * priceKG * 0.001;
      //newPrice(weight);
      //Serial.println(ADCvalue);

      break;
  }
  oldstate = pinstate;
}

Image Image
KEYBOARD.pdf
(35.62 KiB) Downloaded 4 times
Driving 7 segment display
It have 3x6 of 7 segment display by using HEF4028 4bit data to generate 10 scan line and 16bit data bus to display 2 LED segment display each time.

Code: Select all

 int dd=1;
  unsigned long ct=0;
  int sp=0;

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(A0, OUTPUT);
  pinMode(A1, OUTPUT);
  pinMode(A2, OUTPUT);
  pinMode(A3, OUTPUT);
  pinMode(A4, OUTPUT);
  pinMode(A5, OUTPUT);

  digitalWrite(2, LOW); 
  digitalWrite(3, LOW); 
  digitalWrite(4, LOW); 
  digitalWrite(5, LOW); 
  digitalWrite(6, LOW); 
  digitalWrite(7, LOW); 
  digitalWrite(8, LOW); 
  digitalWrite(9, LOW); 
}

void setdigit(int col, int num) {
  switch (num) {
  case  0:
  digitalWrite(2, LOW); 
  digitalWrite(3, LOW); 
  digitalWrite(4, LOW); 
  digitalWrite(5, LOW); 
  digitalWrite(6, HIGH); 
  digitalWrite(7, HIGH); 
  digitalWrite(8, LOW); 
  digitalWrite(9, LOW); 
  break;
  case    1:
  digitalWrite(2, HIGH); 
  digitalWrite(3, LOW); 
  digitalWrite(4, LOW); 
  digitalWrite(5, HIGH); 
  digitalWrite(6, HIGH); 
  digitalWrite(7, HIGH); 
  digitalWrite(8, HIGH); 
  digitalWrite(9, HIGH); 
   break;
  case 2:
  digitalWrite(2, LOW); 
  digitalWrite(3, LOW); 
  digitalWrite(4, HIGH); 
  digitalWrite(5, LOW); 
  digitalWrite(6, HIGH); 
  digitalWrite(7, LOW); 
  digitalWrite(8, LOW); 
  digitalWrite(9, HIGH);
  break; 
  case 3:
  digitalWrite(2, LOW); 
  digitalWrite(3, LOW); 
  digitalWrite(4, LOW); 
  digitalWrite(5, LOW); 
  digitalWrite(6, HIGH); 
  digitalWrite(7, LOW); 
  digitalWrite(8, HIGH); 
  digitalWrite(9, HIGH);
  break; 
  case 4:
  digitalWrite(2, HIGH); 
  digitalWrite(3, LOW); 
  digitalWrite(4, LOW); 
  digitalWrite(5, HIGH); 
  digitalWrite(6, HIGH); 
  digitalWrite(7, LOW); 
  digitalWrite(8, HIGH); 
  digitalWrite(9, LOW);
  break; 
  case 5:
  digitalWrite(2, LOW); 
  digitalWrite(3, HIGH); 
  digitalWrite(4, LOW); 
  digitalWrite(5, LOW); 
  digitalWrite(6, HIGH); 
  digitalWrite(7, LOW); 
  digitalWrite(8, HIGH); 
  digitalWrite(9, LOW);
  break; 
  case 6:
  digitalWrite(2, LOW); 
  digitalWrite(3, HIGH); 
  digitalWrite(4, LOW); 
  digitalWrite(5, LOW); 
  digitalWrite(6, HIGH); 
  digitalWrite(7, LOW); 
  digitalWrite(8, LOW); 
  digitalWrite(9, LOW);
  break; 
  case 7:
  digitalWrite(2, LOW); 
  digitalWrite(3, LOW); 
  digitalWrite(4, LOW); 
  digitalWrite(5, HIGH); 
  digitalWrite(6, HIGH); 
  digitalWrite(7, HIGH); 
  digitalWrite(8, HIGH); 
  digitalWrite(9, LOW);
  break; 
  case 8:
  digitalWrite(2, LOW); 
  digitalWrite(3, LOW); 
  digitalWrite(4, LOW); 
  digitalWrite(5, LOW); 
  digitalWrite(6, HIGH); 
  digitalWrite(7, LOW); 
  digitalWrite(8, LOW); 
  digitalWrite(9, LOW);
  break; 
  case 9:
  digitalWrite(2, LOW); 
  digitalWrite(3, LOW); 
  digitalWrite(4, LOW); 
  digitalWrite(5, LOW); 
  digitalWrite(6, HIGH); 
  digitalWrite(7, LOW); 
  digitalWrite(8, HIGH); 
  digitalWrite(9, LOW);
  break; 
  }
  digitalWrite(col, HIGH); 
  delay(dd); 
  digitalWrite(col, LOW);   
}

// the loop function runs over and over again forever
void loop() {
//  if (sp>2) {
//    ct++;
//    sp=0;
//  }else sp++;
  ct++;
  setdigit(A0,ct % 1000000 /100000);
  setdigit(A1,ct % 100000 /10000);
  setdigit(A2,ct % 10000 /1000);
  setdigit(A3,ct % 1000 /100);
  setdigit(A4,ct % 100 /10);
  setdigit(A5,ct % 10);
}
Image

Driving keyboard
It have 6 x 17 matrix keyboard by using the same scan line with LED display.
First 6bit x 10 scan line we can easily get from the output data bus.
The other 6bit x 7 line it using the last bit as a page. So that first 1 col 1 raw is b00000001 and the next page 11 col 1 raw is b10000001.

Code: Select all

/*
  DIBAL Keyboard
  8 col x 6 row   = 48 key
  9 col x 6 row   = 54 key
  1 col x 3 row   = 3 rotary key 
  total 102 keyboard + 3 idel key

  18 Julai 2017
  by poiuycat
 */
  const int funckey1 =  0;  // idel 
  const int funckey2 =  2;  // sale
  const int funckey3 =  4;  // pc connect
  const int funckey4 =  8;  // program mode
  
  int data0,data1,data2,data3,data4,data5,data6,data7;
  int pin[9];
  int sp=0;
  unsigned int scancode;
  unsigned int keycode;

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  keybegin(A0,A1,A2,A3,A4,A5,2,3,4,5,6,7,8,9,10,11,12,13);
  Serial.begin(9600); 
}

// the loop function runs over and over again forever
void loop() {
  getkey();
  if (keycode!=scancode) {
    Serial.println(scancode,HEX);
    keycode=scancode;
    delay(20);
  }
}

void getkey() {
  for (byte c1=0; c1<9; c1++) {
     scancode=0; 
     digitalWrite(pin[c1], LOW);
     delay(10);
     scancode|=digitalRead(data0);
     scancode|=digitalRead(data1) << 1;
     scancode|=digitalRead(data2) << 2;
     scancode|=digitalRead(data3) << 3;
     scancode|=digitalRead(data4) << 4;
     scancode|=digitalRead(data5) << 5;
     scancode|=digitalRead(data6) << 6;
     scancode|=digitalRead(data7) << 7;
     digitalWrite(pin[c1], HIGH);
     if (scancode!=255) {
      scancode |=  c1 << 8;
      return;
     }
  } 
  
}

void keybegin(int D0,int D1,int D2,int D3,int D4,int D5,int D6,int D7,
              int p01,int p02,int p03,int p04,int p05,int p06,int p07,int p08,int p09,int p10) {
  data0=D0;  data1=D1;  data2=D2;  data3=D3;  data4=D4;  data5=D5;  data6=D6;  data7=D7;
  pin[0]=p01;  pin[1]=p02;  pin[2]=p03;  pin[3]=p04;  pin[4]=p05;  pin[5]=p06;  pin[6]=p07;  pin[7]=p08;  pin[8]=p09;  pin[9]=p10;    
  pinMode(data0, INPUT);
  pinMode(data1, INPUT);
  pinMode(data2, INPUT);
  pinMode(data3, INPUT);
  pinMode(data4, INPUT);
  pinMode(data5, INPUT);
  pinMode(data6, INPUT);
  pinMode(data7, INPUT);
//  pinMode(data0, INPUT_PULLUP);
//  pinMode(data1, INPUT_PULLUP);
//  pinMode(data2, INPUT_PULLUP);
//  pinMode(data3, INPUT_PULLUP);
//  pinMode(data4, INPUT_PULLUP);
//  pinMode(data5, INPUT_PULLUP);
//  pinMode(data6, INPUT_PULLUP);
//  pinMode(data7, INPUT_PULLUP);
  pinMode(pin[0], OUTPUT);
  pinMode(pin[1], OUTPUT);
  pinMode(pin[2], OUTPUT);
  pinMode(pin[3], OUTPUT);
  pinMode(pin[4], OUTPUT);
  pinMode(pin[5], OUTPUT);
  pinMode(pin[6], OUTPUT);
  pinMode(pin[7], OUTPUT);
  pinMode(pin[8], OUTPUT);
  pinMode(pin[9], OUTPUT);
  digitalWrite(pin[0], HIGH);
  digitalWrite(pin[1], HIGH);
  digitalWrite(pin[2], HIGH);
  digitalWrite(pin[3], HIGH);
  digitalWrite(pin[4], HIGH);
  digitalWrite(pin[5], HIGH);
  digitalWrite(pin[6], HIGH);
  digitalWrite(pin[7], HIGH);
  digitalWrite(pin[8], HIGH);
  digitalWrite(pin[9], HIGH);
}
  
After all combine together will look like this ;-)

Image

Image Image

Total cost $20 printer and $10 STM32F103VET and coding $0. 8-)
And always……. Thanks for your watching.
Last edited by poiuycat on Sat Sep 16, 2017 10:38 am, edited 1 time in total.

User avatar
RogerClark
Posts: 7177
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Repair DIBAL M350 by using STM32F103

Post by RogerClark » Wed Sep 13, 2017 10:03 pm

Very cool...

Thanks for sharing..

(Its possibly something Hackaday would be interested in)

User avatar
ahull
Posts: 1630
Joined: Mon Apr 27, 2015 11:04 pm
Location: Sunny Scotland
Contact:

Re: Repair DIBAL M350 by using STM32F103

Post by ahull » Thu Sep 14, 2017 12:15 am

RogerClark wrote:
Wed Sep 13, 2017 10:03 pm
Very cool...

Thanks for sharing..

(Its possibly something Hackaday would be interested in)
+1 Definitely something Hackaday would be interested in.
- Andy Hull -

Post Reply