Raspberry PI B - Model V2 - problems with LCD 20X - Raspberry Pi Forums
hello,
i've connected 20x4 lcd shield on raspberry pi b - model v2, characters strange displays them, shown in link:
http://www.robofun.ro/forum/download/fi ... &mode=view
lcd shield is:
http://www.robofun.ro/lcd/shield-lcd-raspberry-pi-20x4
use os: raspbian, debian wheezy, python language , code is:
i've connected 20x4 lcd shield on raspberry pi b - model v2, characters strange displays them, shown in link:
http://www.robofun.ro/forum/download/fi ... &mode=view
lcd shield is:
http://www.robofun.ro/lcd/shield-lcd-raspberry-pi-20x4
use os: raspbian, debian wheezy, python language , code is:
code: select all
import rpi.gpio gpio import time lcd_rs = 25 lcd_e = 24 lcd_d4 = 23 lcd_d5 = 17 lcd_d6 = 18 lcd_d7 = 22 led_on = 15 lcd_width = 20 lcd_chr = true lcd_cmd = false lcd_line_1 = 0x80 lcd_line_2 = 0xc0 lcd_line_3 = 0x94 lcd_line_4 = 0xd4 e_pulse = 0.00005 e_delay = 0.00005 def main(): gpio.setmode(gpio.bcm) gpio.setup(lcd_e, gpio.out) gpio.setup(lcd_rs, gpio.out) gpio.setup(lcd_d4, gpio.out) gpio.setup(lcd_d5, gpio.out) gpio.setup(lcd_d6, gpio.out) gpio.setup(lcd_d7, gpio.out) gpio.setup(led_on, gpio.out) lcd_init() lcd_byte(lcd_line_1, lcd_cmd) lcd_string("robofun.ro",2) lcd_byte(lcd_line_2, lcd_cmd) lcd_string("raspberry pi",2) lcd_byte(lcd_line_3, lcd_cmd) lcd_string("lcd", 2) lcd_byte(lcd_line_4, lcd_cmd) lcd_string("20x4", 2) def lcd_init(): lcd_byte(0x33,lcd_cmd) lcd_byte(0x32,lcd_cmd) lcd_byte(0x28,lcd_cmd) lcd_byte(0x0c,lcd_cmd) lcd_byte(0x06,lcd_cmd) lcd_byte(0x01,lcd_cmd) def lcd_string(message,style): # style=1 left justified # style=2 centred # style=3 right justified if style==1: message = message.ljust(lcd_width," ") elif style==2: message = message.center(lcd_width," ") elif style==3: message = message.rjust(lcd_width," ") in range(lcd_width): lcd_byte(ord(message[i]),lcd_chr) def lcd_byte(bits, mode): # send byte data pins # bits = data # mode = true character # false command gpio.output(lcd_rs, mode) # rs # high bits gpio.output(lcd_d4, false) gpio.output(lcd_d5, false) gpio.output(lcd_d6, false) gpio.output(lcd_d7, false) if bits&0x10==0x10: gpio.output(lcd_d4, true) if bits&0x20==0x20: gpio.output(lcd_d5, true) if bits&0x40==0x40: gpio.output(lcd_d6, true) if bits&0x80==0x80: gpio.output(lcd_d7, true) # toggle 'enable' pin time.sleep(e_delay) gpio.output(lcd_e, true) time.sleep(e_pulse) gpio.output(lcd_e, false) time.sleep(e_delay) # low bits gpio.output(lcd_d4, false) gpio.output(lcd_d5, false) gpio.output(lcd_d6, false) gpio.output(lcd_d7, false) if bits&0x01==0x01: gpio.output(lcd_d4, true) if bits&0x02==0x02: gpio.output(lcd_d5, true) if bits&0x04==0x04: gpio.output(lcd_d6, true) if bits&0x08==0x08: gpio.output(lcd_d7, true) # toggle 'enable' pin time.sleep(e_delay) gpio.output(lcd_e, true) time.sleep(e_pulse) gpio.output(lcd_e, false) time.sleep(e_delay) if __name__ == '__main__': main()
given appear using "4-bit" interface suspect it's timing issue** - values of e_pulse , e_delay (in us) , how e_pulse value compare values various 4-bit methods shown here?****:mariusionescu wrote:hello,
i've connected 20x4 lcd shield on raspberry pi b - model v2, characters strange displays them, shown in link:
http://www.robofun.ro/forum/download/fi ... &mode=view
lcd shield is:
http://www.robofun.ro/lcd/shield-lcd-raspberry-pi-20x4
use os: raspbian, debian wheezy, python language , code is:code: select all
import rpi.gpio gpio import time lcd_rs = 25 lcd_e = 24 lcd_d4 = 23 lcd_d5 = 17 lcd_d6 = 18 lcd_d7 = 22 led_on = 15 lcd_width = 20 lcd_chr = true lcd_cmd = false lcd_line_1 = 0x80 lcd_line_2 = 0xc0 lcd_line_3 = 0x94 lcd_line_4 = 0xd4 e_pulse = 0.00005 e_delay = 0.00005 def main(): gpio.setmode(gpio.bcm) gpio.setup(lcd_e, gpio.out) gpio.setup(lcd_rs, gpio.out) gpio.setup(lcd_d4, gpio.out) gpio.setup(lcd_d5, gpio.out) gpio.setup(lcd_d6, gpio.out) gpio.setup(lcd_d7, gpio.out) gpio.setup(led_on, gpio.out) lcd_init() lcd_byte(lcd_line_1, lcd_cmd) lcd_string("robofun.ro",2) lcd_byte(lcd_line_2, lcd_cmd) lcd_string("raspberry pi",2) lcd_byte(lcd_line_3, lcd_cmd) lcd_string("lcd", 2) lcd_byte(lcd_line_4, lcd_cmd) lcd_string("20x4", 2) def lcd_init(): lcd_byte(0x33,lcd_cmd) lcd_byte(0x32,lcd_cmd) lcd_byte(0x28,lcd_cmd) lcd_byte(0x0c,lcd_cmd) lcd_byte(0x06,lcd_cmd) lcd_byte(0x01,lcd_cmd) def lcd_string(message,style): # style=1 left justified # style=2 centred # style=3 right justified if style==1: message = message.ljust(lcd_width," ") elif style==2: message = message.center(lcd_width," ") elif style==3: message = message.rjust(lcd_width," ") in range(lcd_width): lcd_byte(ord(message[i]),lcd_chr) def lcd_byte(bits, mode): # send byte data pins # bits = data # mode = true character # false command gpio.output(lcd_rs, mode) # rs # high bits gpio.output(lcd_d4, false) gpio.output(lcd_d5, false) gpio.output(lcd_d6, false) gpio.output(lcd_d7, false) if bits&0x10==0x10: gpio.output(lcd_d4, true) if bits&0x20==0x20: gpio.output(lcd_d5, true) if bits&0x40==0x40: gpio.output(lcd_d6, true) if bits&0x80==0x80: gpio.output(lcd_d7, true) # toggle 'enable' pin time.sleep(e_delay) gpio.output(lcd_e, true) time.sleep(e_pulse) gpio.output(lcd_e, false) time.sleep(e_delay) # low bits gpio.output(lcd_d4, false) gpio.output(lcd_d5, false) gpio.output(lcd_d6, false) gpio.output(lcd_d7, false) if bits&0x01==0x01: gpio.output(lcd_d4, true) if bits&0x02==0x02: gpio.output(lcd_d5, true) if bits&0x04==0x04: gpio.output(lcd_d6, true) if bits&0x08==0x08: gpio.output(lcd_d7, true) # toggle 'enable' pin time.sleep(e_delay) gpio.output(lcd_e, true) time.sleep(e_pulse) gpio.output(lcd_e, false) time.sleep(e_delay) if __name__ == '__main__': main()
http://www.cpmspectrepi.webspace.virgin ... gdata.html
, here:
http://www.raspberrypi.org/forums/viewt ... 44&t=91735
trev.
** similar shown here?:
http://www.cpmspectrepi.webspace.virgin ... ml#testing_...
**** full circuit details can found elsewhere within webpages
raspberrypi
Comments
Post a Comment