milan.rajik
Banned
Why this One Wire LCD not working ?
My Project is One Wire Serial LCD. I have used PIC12F683 with XT 4 MHz Oscillator. I am testing in both Proteus and hardware and I am getting garbage on LCD.
I am posting two projects. One is Roman Black's project which someone has made it successfully and it is working. Another is my project which is mikroC PRO PIC project and it is not working. It is printing garbage on LCD. I have used Roman Black's C Code to make my mikroC code.
Links that I have referred to.
**broken link removed**
https://developer.mbed.org/cookbook/1-wire-shifting-2x16-LCD
https://developer.mbed.org/users/ahmetunal/code/1WireLcd/
https://www.romanblack.com/shift1.htm
https://www.romanblack.com/shift1/sh1_projects.htm
https://www.instructables.com/id/low-cost-1-wire-lcd-for-8-pin-micro-controllers-ro/
The image shows working project made by someone based on Roman Black's code and circuit.
Roman Black's Circuit.
broken link removed
Roman Black's Circuit implemented by someone.
broken link removed
My Circuit
broken link removed
There was a mistake in my code. I have fixed it but still it is not working.
My Project is One Wire Serial LCD. I have used PIC12F683 with XT 4 MHz Oscillator. I am testing in both Proteus and hardware and I am getting garbage on LCD.
I am posting two projects. One is Roman Black's project which someone has made it successfully and it is working. Another is my project which is mikroC PRO PIC project and it is not working. It is printing garbage on LCD. I have used Roman Black's C Code to make my mikroC code.
Links that I have referred to.
**broken link removed**
https://developer.mbed.org/cookbook/1-wire-shifting-2x16-LCD
https://developer.mbed.org/users/ahmetunal/code/1WireLcd/
https://www.romanblack.com/shift1.htm
https://www.romanblack.com/shift1/sh1_projects.htm
https://www.instructables.com/id/low-cost-1-wire-lcd-for-8-pin-micro-controllers-ro/
The image shows working project made by someone based on Roman Black's code and circuit.
Roman Black's Circuit.
broken link removed
Roman Black's Circuit implemented by someone.
broken link removed
My Circuit
broken link removed
There was a mistake in my code. I have fixed it but still it is not working.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 #define _LCD_FIRST_ROW 0x80 //Move cursor to the 1st row #define _LCD_SECOND_ROW 0xC0 //Move cursor to the 2nd row #define _LCD_THIRD_ROW 0x94 //Move cursor to the 3rd row #define _LCD_FOURTH_ROW 0xD4 //Move cursor to the 4th row #define _LCD_CLEAR 0x01 //Clear display #define _LCD_RETURN_HOME 0x02 //Return cursor to home position, returns a shifted display to //its original position. Display data RAM is unaffected. #define _LCD_CURSOR_OFF 0x0C //Turn off cursor #define _LCD_UNDERLINE_ON 0x0E //Underline cursor on #define _LCD_BLINK_CURSOR_ON 0x0F //Blink cursor on #define _LCD_MOVE_CURSOR_LEFT 0x10 //Move cursor left without changing display data RAM #define _LCD_MOVE_CURSOR_RIGHT 0x14 //Move cursor right without changing display data RAM #define _LCD_TURN_ON 0x0C //Turn Lcd display on #define _LCD_TURN_OFF 0x08 //Turn Lcd display off #define _LCD_SHIFT_LEFT 0x18 //Shift display left without changing display data RAM #define _LCD_SHIFT_RIGHT 0x1E //Shift display right without changing display data RAM sbit One_Wire at GP0_bit; sbit One_Wire_Direction at TRISIO0_bit; //Function Prototypes void One_Wire_LCD_Init(); void One_Wire_LCD_Cmd(char out_char); void One_Wire_LCD_Chr(char row, char col, char out_char); void One_Wire_LCD_Chr_Cp(char out_char); void One_Wire_LCD_Out(char row, char col, char *str); void One_Wire_LCD_Out_Cp(char *str); void WriteNibble(char nib, char rs); unsigned char RS; unsigned char msg1[] = "One-Wire LCD"; unsigned char msg2[] = "4 bit"; unsigned char msg3[] = "20x4"; unsigned char msg4[] = "HD44780"; void Delay_6ms() { Delay_ms(6); } void Delay_15us() { Delay_us(11); } void One_Wire_LCD_Cmd(char out_char) { char rs = 0; WriteNibble(out_char, rs); Delay_ms(50); } void One_Wire_LCD_Chr(char row, char col, char out_char) { char rs = 1; switch(row){ case 1: One_Wire_LCD_Cmd(0x80 + col-1); break; case 2: One_Wire_LCD_Cmd(0xC0 + col-1); break; case 3: One_Wire_LCD_Cmd(0x94 + col-1); break; case 4: One_Wire_LCD_Cmd(0xD4 + col-1); break; } WriteNibble(out_char, rs); } void One_Wire_LCD_Chr_Cp(char out_char) { char rs = 1; WriteNibble(out_char, rs); } void One_Wire_LCD_Out(char row, char col, char *str) { while(*str) One_Wire_LCD_Chr(row,col++,*str++); } void One_Wire_LCD_Out_Cp(char *str) { while(*str) One_Wire_LCD_Chr_Cp(*str++); } void Send_Byte(char out_char, char rs) { char i = 0, mask = 0x80; out_char.F2 = rs; for(i = 0; i < 7; i++) { // send all 7 bits if(out_char & mask) { // if HI bit, make 1uS low pulse One_Wire = 0; // make LO pulse One_Wire = 1; // end LO pulse Delay_15uS(); // safe 15uS pulse recovery } else { // else is LO bit! One_Wire = 0; Delay_15uS(); // 15uS LO pulse One_Wire = 1; Delay_15uS(); // 30uS recovery Delay_15uS(); } // now we have sent that bit out using Shift1 timed protocol! mask >>= 1; // get the next bit } // The Shift1 protocol requires that the 8th bit is very // long, this causes the 74HC595 shift register to latch // all the 8 bits to its output port. // NOTE! the 8th bit (bit0) will always be received as zero. One_Wire = 0; // send 8th bit, lo pulse = 14x15 = 210uS for(i = 14; i; i--)Delay_15uS(); One_Wire = 1; // and hi recovery 20x15 = 300 uS for(i = 20; i; i--)Delay_15uS(); } void WriteNibble(char out_char, char rs) { char dummy; dummy = out_char & 0xF0; dummy.F3 = 1; Send_Byte(dummy, rs); dummy.F3 = 0; Send_Byte(dummy, rs); dummy = out_char & 0x0F; dummy <<= 4; dummy.F3 = 1; Send_Byte(dummy, rs); dummy.F3 = 0; Send_Byte(dummy, rs); } void One_Wire_LCD_Init() { Delay_ms(150); One_Wire_LCD_Cmd(0x30); Delay_ms(30); One_Wire_LCD_Cmd(0x30); Delay_ms(30); One_Wire_LCD_Cmd(0x30); Delay_ms(30); One_Wire_LCD_Cmd(0x20); Delay_ms(20); One_Wire_LCD_Cmd(0x28); Delay_ms(10); One_Wire_LCD_Cmd(0x0C); Delay_ms(10); One_Wire_LCD_Cmd(0x06); Delay_ms(10); One_Wire_LCD_Cmd(0x0C); Delay_ms(10); } void main() { ANSEL = 0x00; TRISIO = 0x00; GPIO = 0x00; One_Wire_LCD_Init(); One_Wire_LCD_Cmd(_LCD_CLEAR); One_Wire_LCD_Cmd(_LCD_CURSOR_OFF); One_Wire_LCD_Out(1,1,"One-Wire"); One_Wire_LCD_Out(2,1,"Serial LCD"); One_Wire_LCD_Out(3,1,"20X4"); One_Wire_LCD_Out(4,1,"Using 74HC595"); while(1){ ; } }
Attachments
Last edited by a moderator: