freakydude / freakydude.github.io

My freakydu.de blog
https://blog.freakydu.de
2 stars 1 forks source link

posts/2023-03-23-use_bigtreetech_touchscreenfirmware_with_klipper_on_sidewinder_x2/ #7

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

Use your TouchScreen with Klipper on Sidewinder X2 | freakyDude's Blog

Intro If you have been following my recent posts, you know that I switched from Marlin to Klipper firmware on my Artillery Sidewinder X2. If you have done the same, you may be experiencing the same problem as me. I have already received questions from you about how much better the printing results are with Klipper, but that is another topic. Our integrated display is useless! But I found a solution - well - not perfect yet, but more than OK for my main use cases.

https://blog.freakydu.de/posts/2023-03-23-use_bigtreetech_touchscreenfirmware_with_klipper_on_sidewinder_x2/

taktako commented 1 year ago

Hey,

Thank you very much for this fabulous blog. It's been tremendously helpful to me :)

I have one question about the wiring schema. The HV pin on the Level Shifter is connected to both the TFT screen and the 5V pin on the RPi. Is that correct?

Cheers!

freakydude commented 1 year ago

It's correct. The PI powers the TFT too.

It is important that the UART of the TFT controller gets 5V (because it has 5V) and the GPIO pins of the RPi get only 3.3V. I wired it like in the picture ... but if you have an alternative source of 5V, then you could also use that.

taktako commented 1 year ago

All clear, thanks a lot 😄

Ricky1966 commented 1 year ago

Hi FreakyDude, isn't more easy put GND in commin and connect 5V for TFT to MOBO and wiring with jumpers TX and RX on Raspberry?

freakydude commented 1 year ago

Hi FreakyDude, isn't more easy put GND in commin and connect 5V for TFT to MOBO and wiring with jumpers TX and RX on Raspberry?

Hi Ricky.

As long as level shifter is in between the 3.3V and 5V you can play the game as you like. As I wrote in the comment before, if the RPi gets 5V signals on it's TX/RX GPIO pins, it will die.

Regards

Ricky1966 commented 1 year ago

I'm stupid. With this email, I didn't want to ask you that, but one more thing. I found this sensor to be used instead of the BLTOUCH with Klipper, it uses the I2C and therefore I wanted to ask you if with Klipper, in the printer configuration file I can say that the two pins used by the BLTOUCH are instead SDA/SCL of the I2C, so having the sensor connected to the board instead xhe to the Raspberry pipins.This osbthe sensor's linkhttps://www.pandapi3d.com/product-page/bed-distance-sensorDistinti saluti, Riccardo Bramati -------- Messaggio originale --------Da: freakyDude @.> Data: 08/05/23 15:44 (GMT+01:00) A: "freakydude/freakydude.github.io" @.> Cc: Ricky1966 @.>, Comment @.> Oggetto: Re: [freakydude/freakydude.github.io] posts/2023-03-23-use_bigtreetech_touchscreenfirmware_with_klipper_on_sidewinder_x2/ (Issue #7)

Hi FreakyDude, isn't more easy put GND in commin and connect 5V for TFT to MOBO and wiring with jumpers TX and RX on Raspberry?

Hi Ricky. As long as level shifter is in between the 3.3V and 5V you can play the game as you like. As I wrote in the comment before, if the RPi gets 5V signals on the TX/RX GPIO pins, it will die. Regards

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

freakydude commented 1 year ago

@Ricky1966 For your understanding. Within klipper itself you can configure any pin to any component. More parts of the puzzle are the wiring and logic controller on your Board itself. In short, your device must support I2C protocol on the pins you like to connect the sensor. The BLTouch (or Artillery clone) are connected to servo pins of the Artillery Ruby Board - as far as I know they don't support that.

So either you find free pins, which are support i2c on your mainboard or on your RPi itself.

I can't answer that in detail here and I didn't try it.

Regards

Ricky1966 commented 1 year ago

Tks for your answer. I onow there is not a diagram of Ruby, so I attach to Raspberry directlyDistinti saluti, Riccardo Bramati -------- Messaggio originale --------Da: freakyDude @.> Data: 08/05/23 16:26 (GMT+01:00) A: "freakydude/freakydude.github.io" @.> Cc: Ricky1966 @.>, Mention @.> Oggetto: Re: [freakydude/freakydude.github.io] posts/2023-03-23-use_bigtreetech_touchscreenfirmware_with_klipper_on_sidewinder_x2/ (Issue #7) @Ricky1966 For your understanding. Within klipper itself you can configure any pin to any component. More parts of the puzzle are the wiring and logic controller on your Board itself. In short, your device must support I2C protocol on the pins you like to connect the sensor. The BLTouch (or Artillery clone) are connected to servo pins of the Artillery Ruby Board - as far as I know they don't support that. So either you find free pins, which are support i2c on your mainboard or on your RPi itself. I can't answer that in detail here and I didn't try it. Regards

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

taktako commented 1 year ago

Hi again FreakyDude

I followed your instructions to the letter (I even wired the level shifter exactly like your image), but the screen still does not recognize the printer (No printer attached)

Any idea why this is happening?

Note that when I check the service activation status, it says "Activating" and not "Active"

Thanks in advance

Ricky1966 commented 1 year ago

Maybe is a issue of baudrate tft/klipper

freakydude commented 1 year ago

You can double check some things

taktako commented 1 year ago

Thank you both for your feedback. My screen baudrate is at 250000 and so is my config so I don't think that's where the issue is.

@freakydude I followed your instructions, and the last command (sudo systemctl status serial-btt-bridge) gives me these errors

serial-btt-bridge.service - Bridge BTT Touchscreen wired with UART to virtual Klipper console
     Loaded: loaded (/etc/systemd/system/serial-btt-bridge.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Wed 2023-05-31 11:58:14 BST; 2s ago
    Process: 2116 ExecStart=socat -d /dev/ttyAMA0,b250000 /home/assim/printer_data/comms/klippy.serial,b250000 **(code=exited, status=1/FAILURE)**
   **Main PID: 2116 (code=exited, status=1/FAILURE)**
        CPU: 23ms

In the journal, I see these lines:

 Started Bridge BTT Touchscreen wired with UART to virtual Klipper console.
May 31 11:52:53 mainsail systemd[656]: serial-btt-bridge.service: Failed to locate executable socat: No such file or directory
May 31 11:52:53 mainsail systemd[656]: serial-btt-bridge.service: Failed at step EXEC spawning socat: No such file or directory
May 31 11:52:53 mainsail systemd[1]: Starting Sonar - A WiFi Keepalive daemon...
May 31 11:52:53 mainsail systemd[1]: serial-btt-bridge.service: Main process exited, code=exited, status=203/EXEC

I have socat installed. Below is the output when I run socat:

2023/05/31 12:59:07 socat[5902] E exactly 2 addresses required (there are 0); use option "-h" for help

freakydude commented 1 year ago

Try to run 'whereis socat' add this path before the command in the service file

rediculum commented 10 months ago

I also ran into the missing socat package when I started the service. You should include the installation of that pkg in the docs.

freakydude commented 10 months ago

I also ran into the missing socat package when I started the service. You should include the installation of that pkg in the docs.

Thank you for that constructive feedback, I will.

Best regards

elsi06 commented 8 months ago

Hello

Thanks for you work! I tried to install it and it looks everything fine but the display still stay there is no Printer available. Do I have to change also something on the Display?

freakydude commented 8 months ago

This happened to me if something was wrong with the serial connection

Hope that helps

elsi06 commented 8 months ago

Which Baud rate is the right one? Where can I see it?

freakydude commented 8 months ago

You can see it in: -> https://github.com/freakydude/klipper-serial-btt/blob/main/systemd-service/serial-btt-bridge-rpi.service

ExecStart=socat -d /dev/ttyAMA0,b115200 /home/pi/printer_data/comms/klippy.serial,b115200

115200

elsi06 commented 8 months ago

So Installed the MainsailOS again and now it works with my Sidewinder X1

AndrewsBig commented 7 months ago

Hi.

I try realize this on my Genius PRO. Display is MKS TFT28 v1.0 with FW> V27.x Aug 10 2022 in 72Mhz and Pi 3B+. I don't use user pi but my users is eadmin...

I have problem with start service> eadmin@geniuspi:~ $ sudo systemctl status serial-btt-bridge ● serial-btt-bridge.service - Bridge BTT Touchscreen wired with UART to virtual Klipper console Loaded: loaded (/etc/systemd/system/serial-btt-bridge.service; enabled; preset: enabled) Active: activating (auto-restart) (Result: exit-code) since Tue 2023-12-05 22:32:30 CET; 4s ago Process: 1823 ExecStart=socat -d /dev/ttyAMA0,b115200 /home/eadmin/printer_data/comms/klippy.serial,b115200 (code=exited, status=1/FAILURE) Main PID: 1823 (code=exited, status=1/FAILURE) CPU: 27ms

My /dev eadmin@geniuspi:~ $ ls /dev autofs dri initctl loop7 net ram14 rfkill tty11 tty21 tty31 tty41 tty51 tty61 v4l vcs7 vcsu1 video13 watchdog0 block fd input loop-control null ram15 serial tty12 tty22 tty32 tty42 tty52 tty62 vchiq vcsa vcsu2 video14 zero btrfs-control full kmsg mapper ppp ram2 shm tty13 tty23 tty33 tty43 tty53 tty63 vcio vcsa1 vcsu3 video15 bus fuse log media0 ptmx ram3 snd tty14 tty24 tty34 tty44 tty54 tty7 vc-mem vcsa2 vcsu4 video16 cachefiles gpiochip0 loop0 media1 pts ram4 stderr tty15 tty25 tty35 tty45 tty55 tty8 vcs vcsa3 vcsu5 video18 cec0 gpiochip1 loop1 media2 ram0 ram5 stdin tty16 tty26 tty36 tty46 tty56 tty9 vcs1 vcsa4 vcsu6 video20 char gpiomem loop2 mem ram1 ram6 stdout tty17 tty27 tty37 tty47 tty57 ttyACM0 vcs2 vcsa5 vcsu7 video21 console hidraw0 loop3 mmcblk0 ram10 ram7 tty tty18 tty28 tty38 tty48 tty58 ttyprintk vcs3 vcsa6 vhci video22 cuse hidraw1 loop4 mmcblk0p1 ram11 ram8 tty0 tty19 tty29 tty39 tty49 tty59 uhid vcs4 vcsa7 video10 video23 disk hwrng loop5 mmcblk0p2 ram12 ram9 tty1 tty2 tty3 tty4 tty5 tty6 uinput vcs5 vcsm-cma video11 video31 dma_heap i2c-2 loop6 mqueue ram13 random tty10 tty20 tty30 tty40 tty50 tty60 urandom vcs6 vcsu video12 watchdog

Is problem when a don't see /dev/ttyAMA0 but /dev/ttyACM0 ? I try replace this in /etc/systemd/system/serial-btt-bridge.service and restart service. Then i got success, but display still says "No printer attached".
Switching TX/RX same sate. Please Any other hints?

freakydude commented 7 months ago

The user itself should not be the problem.

I think your "second" serial is still not configured right. On my machine the /dev/ttyACM0 is the serial usb connection to your board running the klipper firmware itself.

You could check that with ls -lisa /dev/serial/by-id/ this results into something like usb-Klipper_stm32g0b1xx_1E00140013504B4633373520-if00 -> ../../ttyACM0

And thats the wrong endpoint. You should have two "serial" connections here. One to the board, one to the screen via level shifter.

I would search on the "overlay" settings in your /boot/config.txt or if it is a cb1 /boot/BoardEnv.txt

Hope this helps.

AndrewsBig commented 7 months ago

Thanks for hint. Solution for newbee like me: Verify if you have got in /boot/config.txt: _enableuart=1 dtoverlay=disable-bt The second line helped me... After reboot verify> ls -l /dev a look for serial1 -> ttyAMA0

Now display and communication work perfectly! Thanks very useful project.

One more side effect. It keeps writing to the console: Unknown command: "M710" Apparently, this is about querying the display for the state of the fan. Any tips where to disable it?

AndrewsBig commented 7 months ago

solution M710: edit and apply display config.ini with: controller_fan:0

comishi commented 6 months ago

Hi! I'm just passing by to say I´m successfully using the touchscreen with an usb TTL uart converter on a netbook as host. I can even print over sd connected to the touchscreen 😱 Thanks for this guide!

Avrution commented 6 months ago

@comishi what converter did you use and what OS is the netbook running? I had wanted to try doing the same thing when I first came across this project, but never got around to trying it.

iz3man commented 3 months ago

@freakydude: I plan using my MKS TFT 2.8 together with an SKR PICO and a RPI Zero. The Pico is using the RPI's serial on pin14/15 already. So there is no useable serial left to connect the display to. Correct? How about connecting a FTDI serial adapter to the RPI's usb port? Those adapters can be set to 3.3/5V, so no need for a level shift. Would that work?

freakydude commented 3 months ago

Hi, I think that is correct. There only one serial specified in pinout of the PI. I don't know if other gpio ports could be misused. What should work is your suggested solution with the usb adapter. I think there was a guy last year, reported solving it this way.

I my self didn't try it, but as long as linux accept it as a serial connection - it should be fine.

Regards

iz3man commented 3 months ago

Danke dir! So now the FTDI adapter is attached. The port /dev/ttyUSB0 is there, the display is connected to power and TX/RX are crossed out. I then edited the serial-btt-bridge.service line to ExecStart=socat -d /dev/ttyUSB0,b115200 /home/pi/printer_data/comms/klippy.serial,b115200, reloaded the service change, restarted the service and changed the serial port in the display to 115k2. That should be all, correct? Still the display is showing: Status: No printer attached (and no temperature are shown etc. What would be the first step to debug? Thanks

iz3man commented 3 months ago

Just trying to get some debugging info out of socat, but I see nothing, so next thing to check was klippy.serial and it shows:

pi@ender2:/dev/serial/by-id $ ls -la /home/pi/printer_data/comms/klippy.serial lrwxrwxrwx 1 pi pi 10 Mar 15 12:09 /home/pi/printer_data/comms/klippy.serial -> /dev/pts/0

is that correct?

iz3man commented 3 months ago

Here's a -d -d -d -d output of socat running on the console https://pastebin.com/huMtKVpG

iz3man commented 3 months ago

I know I'm pretty annoying, but this issue is going around in my head all the time until I solve it :) Is there some special firmware needed for the TFT? IMHO there must be some firmware POLLING data from the MCU, right? Because the printer is not sending out data by itself? Or is it the other way around? But shouldn't I see data in the socat console? I really miss the display. Klipper webfront end is nice, but nothing beats a direct attached display to adjust babystepping, preheating everything etc ... Thank you!

freakydude commented 3 months ago

Seems like the forwarding is not working as expected

Some hints:

iz3man commented 3 months ago

Thanks. For my understanding: What needs to happen so the display shows that it's connected? How does it "know" that it's connected? I mean when nothing is printed no data is sent? Or is receiving data like bed & extruder temperature all the display needs to now that there is printer connected? I want to rule out any errors on the cfg files needed. So printer turned on, and tft connected. Nothing else, and the display should show the correct temperatures. Correct?

akshad09 commented 3 months ago

Thanks So much! this helped alot and got it work ! Just wondering have you tried to flash klipperscreen as the firmware on the tft. Ps.. i tried this on my sidewinder x1 tft28 and the guide works perfect!

akshad09 commented 3 months ago

Also how can you update the firmware on the tft?

freakydude commented 3 months ago

Use this one: https://github.com/bigtreetech/BIGTREETECH-TouchScreenFirmware

Questions/Answers found here: https://github.com/bigtreetech/BIGTREETECH-TouchScreenFirmware/issues/2391