diff --git a/README.md b/README.md index c7a42b9..b3b55bf 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,12 @@ # lcd2serial +Reads out a 7-segment lcd display and sends the value via serial. -Reads out a 7-segment lcd display and send the value via serial. \ No newline at end of file +## How to port another display? +Analyse the display pins. You can use the ProMicro as a logic analyzer, to find the relevant segment pins and the common pins. +You can use the information provided here: https://lowpowerlab.com/forum/projects/moteino-kitchen-scale/ +To use the Pro Micro together with PulseView you can use this repository: https://github.com/gillham/logic_analyzer +For more Information on LCD display consult: http://awawa.hariko.com/avr_lcd_drive_en.html + +## possible improvements +- error handlich of the serial connection. (If screen is kill in operation. The microcontroller needs a restart to reset the serial connection) +- handle all 4 digits by the print_digit() function. diff --git a/intermediate-examples b/intermediate-examples new file mode 100644 index 0000000..868aa2a --- /dev/null +++ b/intermediate-examples @@ -0,0 +1,55 @@ +## +# This is, what the scale puts out when using the print_segments() function +## +# 545g 695g + +8: 1111 1111 +9: 1111 1111 +A: 0010 0000 +B: 0101 0101 +C: 0011 0010 +D: 1001 0001 +E: 0000 0010 +F: 0101 0101 + +## +# The raw output of the arduino as some kind of logic analyser looks like this +## +# 0g + +0: 10001110000001111111000111000111000000111111000111000111 +1: +2: +3: 01110001110001111000111000111000111000111000111000111000 +4: 01110001110001111000111000111000111000111000111000111000 +5: 01110001111110000000111000111000111111000000111000111000 +6: 01110001110001111000111000111000111000111000111000111000 +7: 01110001110001111000111000111000111000111000111000111000 +8: 01110001110001111000111000111000111000111000111000111000 +9: 01110001110001111000111000111000111000111000111000111000 +A: 01110001110001111000111000111000111000111000111000111000 +B: +C: +D: +E: +F: + + +# 45g + +0: 00111111000111000111000000111111000111000011100000011111 +1: +2: +3: 11000111000000111000111111000111000000111100011111100011 +4: 00111000111000111000111000111000111000111100011100011100 +5: 11000000111000111000111111000000111000111100011111100000 +6: 00111000111000111000111000111000111000111100011100011100 +7: 00111000111000111000111000111000111000111100011100011100 +8: 00111000111000111000111000111000111000111100011100011100 +9: 00111000111000111000111000111000111000111100011100011100 +A: 00111000111000111000111000111000111000111100011100011100 +B: +C: +D: +E: +F: diff --git a/lcd2serial.ino b/lcd2serial.ino new file mode 100644 index 0000000..c80bf05 --- /dev/null +++ b/lcd2serial.ino @@ -0,0 +1,236 @@ +/* + reads out a lcd display + based on: + https://lowpowerlab.com/forum/projects/moteino-kitchen-scale/ + + An Arduino Pro Micro was used first as a simple logic analyser, + to find the common pins and the segment pins. See the other sketch. + Later the same arduino was put with this sketch inside the scale to provide + serial output via usb. + + This paricular display is part of a transtek kitchen scale + (pcb label: tsk759) + + The connector in numbered like this + + ----top border of the board---- + + 0 2 4 6 8 10 12 14 + 1 3 5 7 9 11 13 15 + + Pins 0 to 3 are the common pins, but since they are phase shifted by 90° only one + is needed. + + Only Pins 8 to 15 carry useful information. All others are ignored. + +*/ + +byte samples[2][56]; + +// lcd mapping +int seg1[2] = { PINB2, PINB6 }; +int seg2[2] = { PINB4, PINB3 }; +int seg3[2] = { PINB2, PINB6 }; +int seg4[2] = { PINB2, PINB6 }; + +void setup() { + Serial.begin(115200); +} + +void loop() { + get_samples(); // reads out the registers + if (Serial.read() > 0) { + int pulse = get_pulse(); + //print_segments(pulse); + print_4digit(pulse); + print_3digit(pulse); + print_digit(pulse, seg2); + print_digit(pulse, seg1); + Serial.println(); + } +} + +void get_samples() { + int f=0; + while (f<56) { + samples[0][f] = PINB; + samples[1][f] = PIND; + delayMicroseconds(333); // = 1/3 ms. three samples in 1ms, which is the approximate pulse width. + f++; + } +} + +// try to find the position, where the control signal triggers +// looking for a sequence of more than four ones seams sufficient +int get_pulse() { + int n = 0; + int f = 0; + while (f<30) { + if ((samples[1][f]& (1 << PIND3))) { + n++; + if (n>4) break; + } + else n=0; + f++; + } + return f - 3; // sets the index in the first 1ms of the trigger event +} + +void print_digit(int start, int seg[]) { + byte digit = InterpretSevenSegmentSet( + samples[0][start + 18]&(1<