Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
utterances-bot opened this issue Apr 24, 2023 · 38 comments
Labels
utterance Is an issue assigned

Comments

@utterances-bot
Copy link

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/

Copy link

taktako commented Apr 24, 2023

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
Copy link
Owner

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
Copy link

taktako commented Apr 24, 2023

All clear, thanks a lot 😄

Copy link

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
Copy link
Owner

freakydude commented May 8, 2023

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
Copy link

Ricky1966 commented May 8, 2023 via email

@freakydude
Copy link
Owner

@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
Copy link

Ricky1966 commented May 8, 2023 via email

Copy link

taktako commented May 30, 2023

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
Copy link

Maybe is a issue of baudrate tft/klipper

@freakydude
Copy link
Owner

freakydude commented May 31, 2023

You can double check some things

  • As @Ricky1966 says - check that baudrate is the equal in display & serial-btt-bridge service
  • Make sure, your display finished booting before PI/CB1 (at least, power them at the same time)
  • Keep in mind: after display reset or emergency stop of klipper - the connection is often lost. Restart the bridge.service usually helps
  • Are there any errors (red lines) on your mainsailOS console?
  • Check your wires: Try switch TX/RX PINs. This does not destroy anything
  • Check your PI/CB1 "overlay" setup. Make sure your used UART GPIO pins are really enabled. Check if your /dev/ttyS0 exists and points to the correct interface
  • Check if "socat" is installed
  • Check your linux logs for errors
    • sudo dmesg
    • sudo journalctl -b
    • sudo systemctl status serial-btt-bridge

@freakydude freakydude added the utterance Is an issue assigned label May 31, 2023
@taktako
Copy link

taktako commented May 31, 2023

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
Copy link
Owner

freakydude commented May 31, 2023

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

Copy link

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
Copy link
Owner

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

Copy link

elsi06 commented Oct 24, 2023

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
Copy link
Owner

freakydude commented Oct 24, 2023

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

  • Make sure you power on display+pi at the same time, reset them together for a new try. (bridge service can only bridge to a connected, activated display)
  • Wrong UART baud rate (same in display and in bridge service 115200...)
  • Cable connections between pi+level shifter+display (rx/tx must be crossed)
  • Wrong or missing raspi/cb1 overlay settings
  • Wrong gpio pins, wrong display pins
  • Your klipper installation is on a non-standard folder (test if the bridge server runs, test the socat command with -dd without the service)

Hope that helps

Copy link

elsi06 commented Oct 24, 2023

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

@freakydude
Copy link
Owner

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

Copy link

elsi06 commented Oct 24, 2023

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

Copy link

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
Copy link
Owner

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
Copy link

Thanks for hint.
Solution for newbee like me:
Verify if you have got in /boot/config.txt:
enable_uart=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
Copy link

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

Copy link

comishi commented Dec 18, 2023

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!

Copy link

Avrution commented Jan 9, 2024

@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.

Copy link

iz3man commented Mar 14, 2024

@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
Copy link
Owner

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

Copy link

iz3man commented Mar 15, 2024

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

Copy link

iz3man commented Mar 15, 2024

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?

Copy link

iz3man commented Mar 15, 2024

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

Copy link

iz3man commented Mar 18, 2024

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
Copy link
Owner

freakydude commented Mar 18, 2024

Seems like the forwarding is not working as expected

Some hints:

  • disable the service while debugging after that restart pi/cb1 & display together.
  • no, there is no need of a special firmware.
  • establish the debug connection with socat (service disabled). Options -dd are more than enough. Use the options -v and -x and watch the results with tail -f filename on another console ... What you like to see is just the send/received GCode commands nothing else.
  • double check that /dev/ttyUSB0 is the serial device
  • your wireing is incorrect

Copy link

iz3man commented Mar 18, 2024

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?

Copy link

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!

Copy link

Also how can you update the firmware on the tft?

@freakydude
Copy link
Owner

freakydude commented Mar 23, 2024

Copy link

ns-bcr commented Jul 25, 2024

Thanks you so much for this! But I have an MKS TFT28, will it work same? And does the levelshifter is necessary? And last question, does I really need to have the BTT TouchScreenFirwmare or I can work with others firmware?
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
utterance Is an issue assigned
Projects
None yet
Development

No branches or pull requests