Problem using functions
-
@owend strange. I am not sure how to fix it though.
-
Can you send M122 and copy paste the result here?
-
@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```
- Ethernet -
-
@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?
-
@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.
-
I mean can you post the actual file so we can see the actual text contents?
-
@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' -
@anagh said in Problem using functions:
var testValue = sin(50)
Being just curious: do you run your Duet in CNC mode?
-
@infiniteloop yes.
-
@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) }
-
@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?
-
@infiniteloop good catch
-
-
@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' -
@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. -
@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
-
@infiniteloop Sorry, I missed your earlier answer. Your solution works. Thanks a lot for your help.
-
-