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

    Problem using functions

    Scheduled Pinned Locked Moved Solved
    Gcode meta commands
    4
    21
    779
    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.
    • anaghundefined
      anagh @OwenD
      last edited by

      @owend strange. I am not sure how to fix it though.

      1 Reply Last reply Reply Quote 0
      • Phaedruxundefined
        Phaedrux Moderator
        last edited by

        Can you send M122 and copy paste the result here?

        Z-Bot CoreXY Build | Thingiverse Profile

        anaghundefined 1 Reply Last reply Reply Quote 0
        • anaghundefined
          anagh @Phaedrux
          last edited by anagh

          @phaedrux
          M122
          === Diagnostics ===
          RepRapFirmware for Duet 3 MB6HC version 3.4.0 (2022-03-15 18:57:24) running on Duet 3 MB6HC v1.01 or later (standalone mode)
          Board ID: 08DJM-956BA-NA3TN-6JTD4-3S46S-KBALT
          Used output buffers: 3 of 40 (25 max)
          === RTOS ===
          Static ram: 151000
          Dynamic ram: 94812 of which 0 recycled
          Never used RAM 102004, free system stack 208 words
          Tasks: NETWORK(ready,26.4%,251) ETHERNET(notifyWait,0.1%,168) HEAT(notifyWait,0.0%,321) Move(notifyWait,0.0%,352) CanReceiv(notifyWait,0.0%,944) CanSender(notifyWait,0.0%,374) CanClock(delaying,0.0%,333) TMC(notifyWait,7.8%,92) MAIN(running,65.6%,1273) IDLE(ready,0.0%,30), total 100.0%
          Owned mutexes:
          === Platform ===
          Last reset 00:05:58 ago, cause: software
          Last software reset at 2022-05-06 13:11, reason: User, GCodes spinning, available RAM 100856, slot 2
          Software reset code 0x0003 HFSR 0x00000000 CFSR 0x00000000 ICSR 0x00400000 BFAR 0x00000000 SP 0x00000000 Task MAIN Freestk 0 n/a
          Error status: 0x00
          Step timer max interval 130
          MCU temperature: min 49.7, current 49.9, max 50.9
          Supply voltage: min 24.2, current 24.3, max 24.3, under voltage events: 0, over voltage events: 0, power good: yes
          12V rail voltage: min 11.9, current 12.0, max 12.0, under voltage events: 0
          Heap OK, handles allocated/used 99/3, heap memory allocated/used/recyclable 2048/42/0, gc cycles 0
          Events: 0 queued, 0 completed
          Driver 0: standstill, SG min n/a, mspos 1000, reads 5805, writes 0 timeouts 0
          Driver 1: standstill, SG min n/a, mspos 8, reads 5806, writes 0 timeouts 0
          Driver 2: standstill, SG min n/a, mspos 88, reads 5806, writes 0 timeouts 0
          Driver 3: standstill, SG min n/a, mspos 88, reads 5806, writes 0 timeouts 0
          Driver 4: standstill, SG min n/a, mspos 688, reads 5806, writes 0 timeouts 0
          Driver 5: standstill, SG min n/a, mspos 720, reads 5806, writes 0 timeouts 0
          Date/time: 2022-05-06 13:17:03
          Slowest loop: 5.68ms; fastest: 0.05ms
          === Storage ===
          Free file entries: 10
          SD card 0 detected, interface speed: 25.0MBytes/sec
          SD card longest read time 2.3ms, write time 0.0ms, max retries 0
          === Move ===
          DMs created 125, segments created 0, maxWait 0ms, bed compensation in use: none, comp offset 0.000
          === MainDDARing ===
          Scheduled moves 0, completed 0, hiccups 0, stepErrors 0, LaErrors 0, Underruns [0, 0, 0], CDDA state -1
          === AuxDDARing ===
          Scheduled moves 0, completed 0, hiccups 0, stepErrors 0, LaErrors 0, Underruns [0, 0, 0], CDDA state -1
          === Heat ===
          Bed heaters 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1, chamber heaters -1 -1 -1 -1, ordering errs 0
          Heater 0 is on, I-accum = 0.0
          === GCodes ===
          Segments left: 0
          Movement lock held by null
          HTTP is idle in state(s) 0
          Telnet is idle in state(s) 0
          File is idle in state(s) 0
          USB is idle in state(s) 0
          Aux is idle in state(s) 0
          Trigger is idle in state(s) 0
          Queue is idle in state(s) 0
          LCD is idle in state(s) 0
          SBC is idle in state(s) 0
          Daemon is idle in state(s) 0
          Aux2 is idle in state(s) 0
          Autopause is idle in state(s) 0
          Code queue is empty
          === CAN ===
          Messages queued 2757, received 0, lost 0, boc 0
          Longest wait 0ms for reply type 0, peak Tx sync delay 0, free buffers 50 (min 50), ts 1532/0/0
          Tx timeouts 0,0,1532,0,0,1225 last cancelled message type 30 dest 127
          === Network ===
          Slowest loop: 1.94ms; fastest: 0.02ms
          Responder states: HTTP(0) HTTP(0) HTTP(0) HTTP(0) HTTP(0) HTTP(0) FTP(0) Telnet(0), 0 sessions Telnet(0), 0 sessions
          HTTP sessions: 1 of 8

          • Ethernet -
            State: active
            Error counts: 0 0 1 0 0
            Socket states: 5 2 2 2 2 0 0 0```
          1 Reply Last reply Reply Quote 0
          • Phaedruxundefined
            Phaedrux Moderator @anagh
            last edited by

            @anagh said in Problem using functions:

            When I run the macro, this is the error I get,
            Error: in file macro line 1 column 17: meta command: unknown value 'sin'

            Can you post the actual macro being used please?

            Z-Bot CoreXY Build | Thingiverse Profile

            anaghundefined 1 Reply Last reply Reply Quote 0
            • anaghundefined
              anagh @Phaedrux
              last edited by

              @phaedrux
              var testValue = sin(50)

              This is the trial macro I tried to run which contains only this one line. I tried using other functions like tan, abs, etc. as well. But I get the same error.

              infiniteloopundefined 1 Reply Last reply Reply Quote 0
              • Phaedruxundefined
                Phaedrux Moderator
                last edited by

                I mean can you post the actual file so we can see the actual text contents?

                Z-Bot CoreXY Build | Thingiverse Profile

                anaghundefined 1 Reply Last reply Reply Quote 0
                • anaghundefined
                  anagh @Phaedrux
                  last edited by anagh

                  @phaedrux This might be me doing something silly or missing something. I downloaded the macro file on my computer. Now I am trying to go to "upload file" and select the macro file, but it keeps saying invalid file format.
                  Also, the macro file contains only this line and no other text in it. I tried sending this same line using the console as well but I get a similar error:
                  Error: meta command: unknown value 'sin'

                  Phaedruxundefined 1 Reply Last reply Reply Quote 0
                  • infiniteloopundefined
                    infiniteloop @anagh
                    last edited by

                    @anagh said in Problem using functions:

                    var testValue = sin(50)

                    Being just curious: do you run your Duet in CNC mode?

                    anaghundefined 1 Reply Last reply Reply Quote 0
                    • anaghundefined
                      anagh @infiniteloop
                      last edited by

                      @infiniteloop yes.

                      infiniteloopundefined 1 Reply Last reply Reply Quote 0
                      • infiniteloopundefined
                        infiniteloop @anagh
                        last edited by

                        @anagh OK. I just had a look at the documentation, it says:

                        Sub-expressions may be enclosed in { } or in ( ). However, standard CNC GCode uses ( ) to enclose comments. So in CNC mode, RepRapFirmware treats ( ) as enclosing subexpressions when they appear inside { } and as enclosing comments when they do not. Therefore, when RepRapFirmware is running in CNC mode, any use of ( ) to enclose a subexpression or function parameter list must be within an expression enclosed in { }.

                        Try to enclose the expression in curly braces like this:

                        var testValue = { sin(50) }
                        
                        Phaedruxundefined 1 Reply Last reply Reply Quote 1
                        • Phaedruxundefined
                          Phaedrux Moderator @anagh
                          last edited by

                          @anagh said in Problem using functions:

                          but it keeps saying invalid file format.

                          What file extension does it have?

                          How did you create the file in the first place?

                          Can you test this macro?

                          testsinmacro.g

                          Z-Bot CoreXY Build | Thingiverse Profile

                          anaghundefined 1 Reply Last reply Reply Quote 0
                          • Phaedruxundefined
                            Phaedrux Moderator @infiniteloop
                            last edited by

                            @infiniteloop good catch

                            Z-Bot CoreXY Build | Thingiverse Profile

                            infiniteloopundefined anaghundefined 2 Replies Last reply Reply Quote 0
                            • infiniteloopundefined
                              infiniteloop @Phaedrux
                              last edited by

                              @phaedrux said in Problem using functions:

                              good catch

                              Let's wait what happens …

                              1 Reply Last reply Reply Quote 0
                              • anaghundefined
                                anagh @Phaedrux
                                last edited by anagh

                                @phaedrux I created the file by going to the macros tab, then "New File" and then writing this line in the file.
                                I tested the macro you uploaded. Here is the error message:
                                M98 P"0:/macros/testsinmacro.g"
                                Error: in file macro line 1 column 17: meta command: unknown value 'sin'

                                1 Reply Last reply Reply Quote 0
                                • anaghundefined
                                  anagh @Phaedrux
                                  last edited by

                                  @phaedrux is running the machine in CNC mode an issue?
                                  I still haven't been able to find a solution for this. I tried using math functions in macros and also sending them via the console. Both did not work.

                                  infiniteloopundefined 1 Reply Last reply Reply Quote 0
                                  • infiniteloopundefined
                                    infiniteloop @anagh
                                    last edited by

                                    @anagh said in Problem using functions:

                                    is running the machine in CNC mode an issue?

                                    Sure you can ask @Phaedrux any question you want, but in this case, I had already posted the answer: CNC mode isn't an issue, but it is different. Round brackets are a special case, so you have to enclose your expressions in curly braces. Did my sample work?

                                    I just entered the expression

                                    echo {sin(50)}
                                    

                                    into my console, and I'm pretty sure it works - notably: in CNC mode. The result is -0.2623748 😊

                                    anaghundefined 1 Reply Last reply Reply Quote 1
                                    • anaghundefined
                                      anagh @infiniteloop
                                      last edited by

                                      @infiniteloop Sorry, I missed your earlier answer. Your solution works. Thanks a lot for your help.

                                      1 Reply Last reply Reply Quote 0
                                      • dc42undefined dc42 marked this topic as a question
                                      • dc42undefined dc42 has marked this topic as solved
                                      • First post
                                        Last post
                                      Unless otherwise noted, all forum content is licensed under CC-BY-SA