• Tags
  • Documentation
  • Order
  • Register
  • Login
Duet3D Logo Duet3D
  • Tags
  • Documentation
  • Order
  • Register
  • Login

Serials Communication with Arduino Uno?

Scheduled Pinned Locked Moved Unsolved
General Discussion
8
36
2.7k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • undefined
    Sindarius
    last edited by 16 Jan 2022, 18:47

    @adam-v3d Sorry you have to open the comms in your config.g after you have wired the arduino to a serial capable IO using M575. I lost some of my notes when the computer I wrote that on crashed. The code you probably want to look at is where the comms is handled in /src/DuetData.cpp that handles talking back and forth with the duet.

    this video shows it showing the print % progress on a simulated g-code file on a Duet 3 Mini5+
    https://www.youtube.com/watch?v=OjPsP5I6l70

    undefined 1 Reply Last reply 16 Jan 2022, 23:12 Reply Quote 0
    • undefined
      Sindarius @Adam - V3D
      last edited by 16 Jan 2022, 18:50

      @adam-v3d In that code I use AltSoftSerial package which on an arduino uno forces the use of pins 8/9 on the arduino uno. If you use a different board you need to look up the required pins. There is a package bblanchon/ArduinoJson@^6.17.2 that takes the json data sent from the Duet and turns it into a document that you can look up the ObjectModel values.

      undefined undefined 2 Replies Last reply 16 Jan 2022, 19:03 Reply Quote 0
      • undefined
        Sindarius @Sindarius
        last edited by 16 Jan 2022, 19:03

        I found an old SD card which had the config

        ;Duet Mini5+
        M575 P2 B57600 S0

        1 Reply Last reply Reply Quote 0
        • undefined
          MintyTrebor @Adam - V3D
          last edited by 16 Jan 2022, 20:04

          @adam-v3d If this helps as a backup/alternative ---

          Because you are already planning to capture the data on a laptop, you can log data easily with node-red & nodeDSF:

          For example - The screen shot below show a csv which logged T0 temp with a time stamp (millisecond) as it cooled down..

          9ab5fcdf-165d-4e08-8e4f-99ada01812e5-image.png

          It took less than 5 mins to put together and gives you access to nearly the entire object model in almost real-time over the network (it uses the same connection methods as DWC).

          NodeDSF - Native Node-Red integration with Duet boards.
          BtnCmd - Customise DWC with user defined buttons/layouts/panels (DWC Plugin)
          ReleaseMgr - Duet update info inside DWC.
          Repo

          undefined 2 Replies Last reply 16 Jan 2022, 23:13 Reply Quote 0
          • undefined
            Sindarius
            last edited by 16 Jan 2022, 21:14

            Here's a short video that shows the project that I did. https://www.youtube.com/watch?v=WQDmI404N5k

            1 Reply Last reply Reply Quote 1
            • undefined
              Adam - V3D @Sindarius
              last edited by 16 Jan 2022, 23:12

              @sindarius I think I kind of understood most of the code, only little bits of syntax I didn't understand. I turn on debugging and the end result was that it either paused completely after 500ms (first time it polled the duet) or ran mostly correctly but hotend temps and fan always showed the original values in the library of 10, 285 etc.

              I guess this means there was no data coming from the Duet. Maybe wrong port number. I used M575 P1 B57600 S0 and connector to the RX and TX on the Panel due 4 pin connector next to the 4 pin probe connector.

              1 Reply Last reply Reply Quote 0
              • undefined
                Adam - V3D @MintyTrebor
                last edited by 16 Jan 2022, 23:13

                @mintytrebor This is cool, I guess its easy when you know how. I've never used this before though and not sure how I would sync it up with the other data from the arduino.

                1 Reply Last reply Reply Quote 0
                • undefined
                  Adam - V3D @Sindarius
                  last edited by 16 Jan 2022, 23:14

                  @sindarius Oh i did get the thing with pins 8 and 9 after realising what the library was for and that the designated TX and RX pins are basically the same serial i'm using to connect to the laptop.
                  For connection, do you connect duet TX to pin 8, and duet RX to pin 9?

                  undefined 1 Reply Last reply 17 Jan 2022, 00:45 Reply Quote 0
                  • undefined
                    Adam - V3D @MintyTrebor
                    last edited by 16 Jan 2022, 23:29

                    @mintytrebor I've just installed and had a little look at this. I quite like it and might be more my speed but don't understand it really yet. It looks like it'll be capable of polling the arduino and duet at the same time and just merging them into a single file on the pc which could be useful. Maybe also a powerful option for when i'm adding more features later down the line.

                    Are you able to share details on what you showed here?

                    undefined 2 Replies Last reply 17 Jan 2022, 07:13 Reply Quote 0
                    • undefined
                      Sindarius @Adam - V3D
                      last edited by Sindarius 17 Jan 2022, 00:45

                      @adam-v3d you mentioned you are using a duet 2 wifi but I didn’t see what firmware version you are running on the duet

                      1 Reply Last reply Reply Quote 0
                      • undefined
                        MintyTrebor @Adam - V3D
                        last edited by MintyTrebor 17 Jan 2022, 07:13

                        @adam-v3d Sure.

                        There is an attempt at a wiki for the nodes used to connect to the duet here :
                        https://github.com/MintyTrebor/NodeDSF/wiki/About

                        I also have a nodeDSF channel over on TeamGloomy's discord
                        https://discord.gg/bXcYqGvt

                        The quick POC I threw together earlier, just pulls the T0 temp from the Duet object model ~5 times a second, adds a time stamp, and writes a line to a csv file. That's it. There is an import/export function in nodered, so I can share the POC with you if its useful.

                        I have not used nodered to talk to arduino, there is a nodered faq that covers it here:
                        https://nodered.org/docs/faq/interacting-with-arduino. But if all you need is serial connectivity, then something like this (https://flows.nodered.org/node/node-red-node-serialport) will probably work.

                        .

                        NodeDSF - Native Node-Red integration with Duet boards.
                        BtnCmd - Customise DWC with user defined buttons/layouts/panels (DWC Plugin)
                        ReleaseMgr - Duet update info inside DWC.
                        Repo

                        1 Reply Last reply Reply Quote 0
                        • undefined
                          dc42 administrators @Adam - V3D
                          last edited by 17 Jan 2022, 09:52

                          @adam-v3d you might like to take a look at the CN Pendant project at https://github.com/Duet3D/CNC-Pendant-Firmware. This communicates to the Duet through the serial port.

                          If you will he using the USB interface to the Arduino as well, then I suggest you use an Arduino Leonardo, Arduino Pro Micro, or Arduino Mega. All of these give you a hardware serial port that is separate from the USB port. Also, the Leonardo and the Pro Micro accept 3.3V input signals, so although you need a simple resistive divider to reduce the Tx output of the Arduino from 5V to 3.3V, you don't need to level shift the output from the Duet up to 5V - although I suggest you use a 1K series resistor.

                          Duet WiFi hardware designer and firmware engineer
                          Please do not ask me for Duet support via PM or email, use the forum
                          http://www.escher3d.com, https://miscsolutions.wordpress.com

                          1 Reply Last reply Reply Quote 0
                          • undefined
                            MintyTrebor @Adam - V3D
                            last edited by MintyTrebor 17 Jan 2022, 12:47

                            @adam-v3d
                            Attached is a example flow you can import which creates 2 connections to 2 different control boards, 1 via serial com port (over usb), the second over the network using the NodeDSF nodes.

                            For the example:
                            Serial Connection Board 1: Send the M409 command via serial to get the chamber temp from the object model, and request a new update every 200ms, writing the values to a csv file.
                            Network Connection Board 2: Connect to board, and get updated bed temp every 200ms and write result to different csv file.

                            You can then combine this data in whatever tool is required (excel etc).

                            If you want to push it further you can map the data to a chart in real-time in node-red using dashboard nodes eg
                            9fdcb9c4-0989-49f5-b8e9-5010d38e82b6-image.png

                            Flow in node-red

                            6d289e47-2c4d-491b-83c7-e668b76c34c0-image.png
                            serialcsvtest.json

                            NodeDSF - Native Node-Red integration with Duet boards.
                            BtnCmd - Customise DWC with user defined buttons/layouts/panels (DWC Plugin)
                            ReleaseMgr - Duet update info inside DWC.
                            Repo

                            undefined 1 Reply Last reply 17 Jan 2022, 12:49 Reply Quote 1
                            • undefined
                              Adam - V3D @MintyTrebor
                              last edited by 17 Jan 2022, 12:49

                              @mintytrebor thankyou!

                              undefined 1 Reply Last reply 19 Jan 2022, 17:33 Reply Quote 0
                              • undefined
                                Adam - V3D @Adam - V3D
                                last edited by 19 Jan 2022, 17:33

                                @adam-v3d Gave the node red thing a pretty good shot today, spent some time learning how it works and managed to get it working and sending back data. In the current state I have it, on a 200ms request, it take anywhere from 227ms to over 1600ms to get a response when idle and also seems to be crashing the duet quite often too which would make the test void so going to abandon that idea. Currently I can get reading every 25.5ms +-0.5ms with the arduino and would like to keep that kind of rate and precision where possible.

                                I got some new level shifters that seem to work a bit better so i'm going to give the direct serial connection another go and also try with the arduino mega if It doesn't go well with the uno.

                                undefined 1 Reply Last reply 19 Jan 2022, 17:48 Reply Quote 0
                                • undefined
                                  MintyTrebor @Adam - V3D
                                  last edited by 19 Jan 2022, 17:48

                                  @adam-v3d said in Serials Communication with Arduino Uno?:

                                  on a 200ms request, it take anywhere from 227ms to over 1600ms to get a response when idle and also seems to be crashing the duet quite often too

                                  Out of interest is that using the serial connection node?

                                  NodeDSF - Native Node-Red integration with Duet boards.
                                  BtnCmd - Customise DWC with user defined buttons/layouts/panels (DWC Plugin)
                                  ReleaseMgr - Duet update info inside DWC.
                                  Repo

                                  undefined 1 Reply Last reply 19 Jan 2022, 21:46 Reply Quote 0
                                  • undefined
                                    Adam - V3D @MintyTrebor
                                    last edited by 19 Jan 2022, 21:46

                                    @mintytrebor no sorry that was wifi, i didn't expect wifi to be good.

                                    undefined 1 Reply Last reply 19 Jan 2022, 22:13 Reply Quote 0
                                    • undefined
                                      Adam - V3D @Adam - V3D
                                      last edited by 19 Jan 2022, 22:13

                                      @adam-v3d the node was the DSF monitor node.

                                      undefined 1 Reply Last reply 20 Jan 2022, 07:02 Reply Quote 0
                                      • undefined
                                        MintyTrebor @Adam - V3D
                                        last edited by 20 Jan 2022, 07:02

                                        @adam-v3d Would you mind sharing the flow please. If you have found a new bug with the Monitor node I would like to try and track it down. I have never seen it cause a board crash, so I need to investigate.

                                        Thanks

                                        NodeDSF - Native Node-Red integration with Duet boards.
                                        BtnCmd - Customise DWC with user defined buttons/layouts/panels (DWC Plugin)
                                        ReleaseMgr - Duet update info inside DWC.
                                        Repo

                                        undefined 1 Reply Last reply 20 Jan 2022, 11:41 Reply Quote 0
                                        • undefined
                                          Adam - V3D @MintyTrebor
                                          last edited by 20 Jan 2022, 11:41

                                          @mintytrebor Sure. flows.json

                                          1 Reply Last reply Reply Quote 0
                                          26 out of 36
                                          • First post
                                            26/36
                                            Last post
                                          Unless otherwise noted, all forum content is licensed under CC-BY-SA