Klipper3d / klipper

Klipper is a 3d-printer firmware
GNU General Public License v3.0
9.48k stars 5.32k forks source link

st7920 display glitching #884

Closed mkuf closed 5 years ago

mkuf commented 5 years ago

Hello,

I'm using a 12864 Full graphics display (identical to the RR-Discount one) with a RADDS 1.0 on a DUE.

It works fine on Repetier 1.0.3

With klipper on the other hand, the display outputs random data alsongside the correct temperatures. Accessing a menue results in even more scrambled data.

The Configured pins in Klipper are identical to the ones in Repetier.

https://github.com/repetier/Repetier-Firmware/blob/c09783a0f4f1bc2bedefc8df2c90709172ae74b2/src/ArduinoDUE/Repetier/DisplayList.h#L1235-L1239

[display]
lcd_type = st7920
cs_pin = PC19
sclk_pin = PC17
sid_pin = PC18
encoder_pins = ^PC13,^PB21
click_pin = ^PC15

Any idea, what's happening here and how this can be fixed?

Thanks, -Markus

klippy.log

KevinOConnor commented 5 years ago

That's surprising. If you look at the top of the file klippy/extras/display/st7920.py you'll see two variables - ST7920_CMD_DELAY and ST7920_SYNC_DELAY. If you increase these variables and then run "sudo service klipper restart" after each change, does the problem go away?

-Kevin

mkuf commented 5 years ago

Thanks for your Reply.

I'm on a conference this week. I'll let you know if changing the delays worked out, when I am back at my printer.

-Markus

mkuf commented 5 years ago

Increasing both values did unfortunately not fix any of the glitching. It just changed the appearence of the glitches. Just to be sure i also reset the mcu every time i restarted klippy.

Tested Values/Pairs

ST7920_CMD_DELAY  = .000020
ST7920_SYNC_DELAY = .000045

ST7920_CMD_DELAY  = .000020
ST7920_SYNC_DELAY = .000072

ST7920_CMD_DELAY  = .000072
ST7920_SYNC_DELAY = .000045

ST7920_CMD_DELAY  = .000072
ST7920_SYNC_DELAY = .000072

-Markus

KevinOConnor commented 5 years ago

If you pull the test code on the work-st7920-20181124 branch, and reflash the micro-controller, does it improve the results?

cd ~/klipper ; git fetch ; git checkout origin/work-st7920-20181124 ; sudo service klipper stop ; make ; make flash ; sudo service klipper start

mkuf commented 5 years ago

With work-st7920-20181124 it seems a little less glitchy, but it's still not usable. 20181126_181107

KevinOConnor commented 5 years ago

That looks like it's the ST7920_CMD_DELAY being too low. When you tried both delays set to .000072, did the display still glitch or did it not come up at all? If the latter, try setting ST7920_SYNC_DELAY=.000072 and then try gradually increasing ST7920_CMD_DELAY (eg, try it at .000045). Be sure to do a "sudo service klipper restart" after any code change.

-Kevin

mkuf commented 5 years ago

This is on work-st7920-20181124 with both delays set to .000072 20181127_185515

I tried ST7920_SYNC_DELAY=.000072 and gradually increasing ST7920_CMD_DELAY (starting from .000045, .000005 intervals). With both values on .000072 the glitching seems better but is still existent.

KevinOConnor commented 5 years ago

That's really quite strange. I haven't seen any reports from other users. It definitely looks like a timing issue, but the only timeouts are the ones you've changed. If you're familiar with C code, you could try increasing the "nops" in src/lcd_st7920.c . (I've also pushed up another change to that branch with some more "nops" in a slightly different location.)

Are you powering the display with 5v or with 3.3v?

-Kevin

mkuf commented 5 years ago

The Display itself is powered via 5v and all Data-Lines are level-shifted to 5v via the RADDS' onboard Levelshifter on the Display-Port.

grafik

I'll test your changes this weekend and let you know how it went.

-Markus

jakep82 commented 5 years ago

I'm guessing this is related to the level shifting. I run this same type of screen on a Due, but without level shifting. I have separate 5V connected to power the screen, and everything else is connected directly to pins on the Due.

KevinOConnor commented 5 years ago

I agree with @jakep82 - that level shifter is a large unknown. Each bit transmitted to the st7920 needs a certain hold time - it's not clear if the level shifter can match the transmit rate that Klipper generates.

I've run my st7920 display with 5V power and 3.3V signalling lines. That is okay, as far as I know, because the signal lines are mcu->st7920 only.

-Kevin

mkuf commented 5 years ago

As of now, I'm not able to connect the display to any other port on the RADDS as they are either blocked by something else, or would need more hardware modifications.

I'll stay with Repetier for now, also because of #879

Thanks for your Time.

-Markus

mkuf commented 5 years ago

Quick follow up on this issue, if anyone is facing the same problems. I had some time on hand to go over the electronics of my printer. I removed the levelshifter and bridged the contacts, so that the DUEs IO-Pins are directly connected to the RADDS Display-header.

The display now works fine with Klipper.

-Markus

kssdl888 commented 3 years ago

how to solve this problem ?