FluidNC icon indicating copy to clipboard operation
FluidNC copied to clipboard

Problem: Spindel spinup_ms doesn't work

Open 20Jakob09 opened this issue 1 month ago • 11 comments

Wiki Search Terms

Spindel

Controller Board

6-pack

Machine Description

4 axis CNC using stepperonline NEMA 23 closed loop motors with CL57T-V41 drivers, with 1.5kW china spindle on a Siemens V20 VFD

Input Circuits

homing limit switches on all axis normally open
safety door pin on a "stop switch", normally open
resume button on cycle_start_pin, normally open

homing working fine, safety door action working in normal operation as expected.

Configuration file

board: 6 Pack CNC by Bart Dring
name: JaRa CNC
meta: 2025-11-29 RMk RS485 + FLuidDial

macros:
  after_homing: G53G00X520Y-165Z130

control:
# STOP Taste
  safety_door_pin: gpio.35:low
# Start Taste:
  cycle_start_pin: gpio.34:low
# Home Taste:
  homing_button_pin: gpio.39:low
# FU + Motortreiber WARN
  fault_pin: gpio.2:low:pu

  reset_pin: NO_PIN
#  fault_pin: gpio.36
#  feed_hold_pin: gpio.2:low:pu


status_outputs:
# LED Start
  hold_pin: I2SO.23
# LED Home:
  run_pin: I2SO.21

i2so:
  bck_pin: gpio.22
  data_pin: gpio.21
  ws_pin: gpio.17

spi:
  miso_pin: gpio.19
  mosi_pin: gpio.23
  sck_pin: gpio.18

sdcard:
  card_detect_pin: NO_PIN
  cs_pin: gpio.5

start:
  must_home: true

# used on opening DOOR
parking:
  enable: true
  axis: Z
  pullout_distance_mm: 20.000
  pullout_rate_mm_per_min: 250.000
  target_mpos_mm: 120.000
  rate_mm_per_min: 800.000

probe:
# not touching is high
  pin: gpio.36:low
  toolsetter_pin: NO_PIN
  check_mode_start: true
  hard_stop: true

# UART for FluidDial
uart2:
  txd_pin: gpio.27
  rxd_pin: gpio.25
  rts_pin: NO_PIN
  cts_pin: NO_PIN
  baud: 1000000
  mode: 8N1

uart_channel1:
  report_interval_ms: 200
  uart_num: 2
  message_level: warn

#UART for RS485
#uart1:
#  txd_pin: gpio.15
#  rxd_pin: gpio.16
#  rts_pin: gpio.14
#  cts_pin: NO_PIN
#  baud: 9600
#  mode: 8E1

#use correct UART!
#ModbusVFD:
# see https://support.industry.siemens.com/cs/mdm/109824500?c=160470548491&dl=nl&lc=en-US
#  debug: 3
#  uart_num: 1
#  modbus_id: 1
#  model: SiemensV20
#  ccw_cmd: 06 00 63 0c 7f > echo
#  cw_cmd: 06 00 63 04 7f > echo # maybe ccw and cw are flipped
#  off_cmd: 06 00 63 0c 7e > echo
#  set_rpm_cmd: 06 00 64 rpm  > echo
#  get_rpm_cmd: 03 00 6e 00 01 > 03 02 rpm

#  get_max_rpm_cmd: 03 00 0F 00 01 > 03 02 maxrpm*6/10 # this uses the base RPM and works
#  get_max_rpm_cmd: 03 10 82 00 01 > 03 02 rpm*60/100
#  get_min_rpm_cmd: 03 10 80 00 01 > 03 02 rpm*60/100
#  get_max_rpm_cmd: 03 01 69 00 01 > 03 02 maxrpm*6/10
#  get_min_rpm_cmd: 03 01 68 00 01 > 03 02 minrpm*6/10

#  speed_map: 0=0% 1=12.5% 3000=37.5% 9000=37.5% 24000=100%
#  off_on_alarm: true

SiemensV20:
  debug: 0
  uart:
    txd_pin: gpio.15
    rxd_pin: gpio.16
    rts_pin: gpio.14
    baud: 9600
    mode: 8E1
  modbus_id: 1
  tool_num: 0
  spinup_ms: 20000	
  spindown_ms: 20000
  speed_map: 0=0% 1=12.5% 3000=37.5% 9000=37.5% 24000=100%
  off_on_alarm: true
#  poll_ms: 2000 # to be changed later, we use 2s right now only to reduce the debug output
#  disable_with_s0: true
#  s0_with_disable: true

#10V:
#  forward_pin: NO_PIN
#  reverse_pin: NO_PIN
#  pwm_hz: 15000
#  output_pin: gpio.13
#  enable_pin: gpio.15
#  direction_pin: gpio.14:low
#  disable_with_s0: false
#  s0_with_disable: true
#  spinup_ms: 1500
#  spindown_ms: 1500
#  tool_num: 0
#  speed_map: 0=0.000% 1000=0.000% 24000=100.000%
#  speed_map: 0=0% 1=12.5% 3000=37.5% 9000=37.5% 24000=100%
#  off_on_alarm: true

stepping:
  engine: I2S_STREAM
#we never disable the output pins automatically, so set to 255
  idle_ms: 255
# the CL57T can handle stepping frequencies up to 200 kHz, so in theory 2.5us pulses should be possible.
# other sources claim 500kHz, so we could go with 1us pulses
# 5 limits to 100kHz
  pulse_us: 6
  dir_delay_us: 6
  disable_delay_us: 0
  segments: 6

axes:
  shared_stepper_disable_pin: NO_PIN
  homing_runs: 2
  x:
    steps_per_mm: 1000.0
    max_rate_mm_per_min: 2200.000
    acceleration_mm_per_sec2: 50.000
    max_travel_mm: 558.000
    soft_limits: true
    homing:
      cycle: 2
      positive_direction: false
      mpos_mm: 0.000
      feed_mm_per_min: 50.000
      seek_mm_per_min: 200.000
      settle_ms: 500
      seek_scaler: 1.100
      feed_scaler: 1.100

    motor0:
      limit_neg_pin: gpio.33:low:pu
      limit_pos_pin: NO_PIN
      limit_all_pin: NO_PIN
      hard_limits: true
      pulloff_mm: 1.500
      standard_stepper:
        step_pin: I2SO.2
        direction_pin: I2SO.1
        disable_pin: I2SO.0

  y:
    steps_per_mm: 1000.000
    max_rate_mm_per_min: 2000.000
    acceleration_mm_per_sec2: 50.000
    max_travel_mm: 411.000
    soft_limits: true
    homing:
      cycle: 2
      positive_direction: true
      mpos_mm: 0.000
      feed_mm_per_min: 50.000
      seek_mm_per_min: 200.000
      settle_ms: 500
      seek_scaler: 1.100
      feed_scaler: 1.100

    motor0:
      limit_neg_pin: NO_PIN
      limit_pos_pin: gpio.26:low:pu
      limit_all_pin: NO_PIN
      hard_limits: true
      pulloff_mm: 1.500
      standard_stepper:
        step_pin: I2SO.5
        direction_pin: I2SO.4
        disable_pin: I2SO.7
    
  z:
    steps_per_mm: 1000.000
    max_rate_mm_per_min: 2000.000
    acceleration_mm_per_sec2: 25.000
    max_travel_mm: 165.000
    soft_limits: true
    homing:
      cycle: 1
      positive_direction: true
      mpos_mm: 140.000
      feed_mm_per_min: 50.000
      seek_mm_per_min: 150.000
      settle_ms: 500
      seek_scaler: 1.100
      feed_scaler: 1.100

    motor0:
      limit_neg_pin: NO_PIN
      limit_pos_pin: gpio.32:low:pu
      limit_all_pin: NO_PIN
      hard_limits: true
      pulloff_mm: 1.500
      standard_stepper:
        step_pin: I2SO.10
        direction_pin: I2SO.9
        disable_pin: I2SO.8
  
  a:
    steps_per_mm: 142.22222222222222
    max_rate_mm_per_min: 2000.000
    acceleration_mm_per_sec2: 100.000
    max_travel_mm: 960.000
    soft_limits: false
      
    motor0:
      limit_neg_pin: NO_PIN
      limit_pos_pin: NO_PIN
      limit_all_pin: NO_PIN
      hard_limits: false
      pulloff_mm: 1.500
      standard_stepper:
        step_pin: I2SO.13
        direction_pin: I2SO.12
        disable_pin: I2SO.15

Startup Messages

$G
<Alarm|MPos:0.000,0.000,0.000,0.000|FS:0,0|WCO:264.889,-294.471,-15.151,0.000>
[GC:G0 G54 G17 G21 G90 G94 M5 M9 T0 F0 S0]
[GC:G0 G54 G17 G21 G90 G94 M5 M9 T0 F0 S0]
ok
$SS
<Alarm|MPos:0.000,0.000,0.000,0.000|FS:0,0|Ov:100,100,100>
[MSG:INFO: FluidNC v4.0.0-pre2 https://github.com/bdring/FluidNC]
[MSG:INFO: Local filesystem type is littlefs]
[MSG:INFO: Configuration file:JaRa_CNC.yaml]
[MSG:DBG: Running after-parse tasks]
[MSG:DBG: Checking configuration]
[MSG:INFO: Machine JaRa CNC]
[MSG:INFO: Board 6 Pack CNC by Bart Dring]
[MSG:INFO: UART2 Tx:gpio.27 Rx:gpio.25 RTS:NO PIN Baud:1000000]
[MSG:INFO: uart_channel1 created at report interval: 200]
[MSG:INFO: I2SO BCK:gpio.22 WS:gpio.17 DATA:gpio.21Min Pulse:2us]
[MSG:INFO: SPI SCK:gpio.18 MOSI:gpio.23 MISO:gpio.19]
[MSG:INFO: SD Card cs_pin:gpio.5 detect:NO PIN freq:8000000]
[MSG:INFO: Stepping:I2S_STREAM Pulse:6us Dsbl Delay:0us Dir Delay:6us Idle Delay:255ms]
[MSG:INFO: Axis count 4]
[MSG:INFO: Axis X (0.000,558.000)]
[MSG:INFO:   Motor0]
[MSG:INFO:     standard_stepper Step:I2SO.2 Dir:I2SO.1 Disable:I2SO.0]
[MSG:INFO:  X Neg Limit gpio.33:low:pu]
[MSG:INFO: Axis Y (-411.000,0.000)]
[MSG:INFO:   Motor0]
[MSG:INFO:     standard_stepper Step:I2SO.5 Dir:I2SO.4 Disable:I2SO.7]
[MSG:INFO:  Y Pos Limit gpio.26:low:pu]
[MSG:INFO: Axis Z (-25.000,140.000)]
[MSG:INFO:   Motor0]
[MSG:INFO:     standard_stepper Step:I2SO.10 Dir:I2SO.9 Disable:I2SO.8]
[MSG:INFO:  Z Pos Limit gpio.32:low:pu]
[MSG:INFO: Axis A (-960.000,0.000)]
[MSG:INFO:   Motor0]
[MSG:INFO:     standard_stepper Step:I2SO.13 Dir:I2SO.12 Disable:I2SO.15]
[MSG:INFO: safety_door_pin gpio.35:low]
[MSG:INFO: cycle_start_pin gpio.34:low]
[MSG:INFO: fault_pin gpio.2:low:pu]
[MSG:INFO: homing_button_pin gpio.39:low]
[MSG:INFO: Kinematic system: Cartesian]
[MSG:INFO: Connecting to STA SSID:PalimPalim]
[MSG:INFO: Connecting.]
[MSG:INFO: Connecting..]
[MSG:INFO: Connected - IP is 192.168.0.77]
[MSG:INFO: WiFi on]
[MSG:INFO: Start mDNS with hostname:http://fluidnc.local/]
[MSG:INFO: HTTP started on port 80]
[MSG:INFO: Telnet started on port 23]
[MSG:INFO: Status outputs Interval:500 Idle:NO PIN Cycle:I2SO.21 Hold:I2SO.23 Alarm:NO PINDoor:NO PIN]
[MSG:INFO: UART1 Tx:gpio.15 Rx:gpio.16 RTS:gpio.14 Baud:9600]
[MSG:INFO: SiemensV20 Spindle Tx:gpio.15 Rx:gpio.16 RTS:gpio.14 Baud:9600]
[MSG:DBG: SiemensV20: setState:5 SpindleSpeed:0]
[MSG:DBG: setSpeed 0]
[MSG:INFO: Probe gpio.36:low]
ok
<Alarm|MPos:0.000,0.000,0.000,0.000|FS:0,0>

User Interface Software

WebUI, FluidDial pendant

What happened?

When starting the spindle at a speed of 10,000 rpm via the webui, the spindle starts but stops before reaching the correct speed and before exceeding spinup_ms: 20,000 ms, and displays the error message (see Other Information). Changing spinup_ms does not change this. It feels like the spinup_ms is not considered at all. Am I wrong to expect that only after 20 sec this error should occur if the spindle didn't reach its target speed.

GCode File

No response

Other Information

[GC:G0 G54 G17 G21 G90 G94 M5 M9 T0 F0 S10000] [MSG:DBG: SiemensV20: setState:3 SpindleSpeed:10000] [MSG:DBG: setSpeed 166] [MSG:DBG: set_mode 3] [MSG:DBG: Setting VFD speed to 166] [MSG:DBG: Setting VFD Scaled Value -6799 Byte 1 229 Byte 2 113] [MSG:DBG: VFD Measured Value 0 Freq 0] [MSG:DBG: VFD Measured Value 0 Freq 0] [MSG:DBG: VFD Measured Value 0 Freq 0] [MSG:DBG: VFD Measured Value 445 Freq 10] [MSG:INFO: RS485 received message of unexpected length; expected:7 got:6] [MSG:INFO: RS485 received message from other modbus device] [MSG:DBG: VFD Measured Value 5272 Freq 128] [MSG:ERR: SiemensV20: spindle did not reach device units 166. Reported value is 128] ok [MSG:DBG: SiemensV20: setState:5 SpindleSpeed:0] [MSG:DBG: setSpeed 0] [MSG:DBG: set_mode 5] [MSG:DBG: Setting VFD speed to 0] [MSG:DBG: Setting VFD Scaled Value 0 Byte 1 0 Byte 2 0] <Idle|MPos:520.000,-165.000,130.000,0.000|FS:0,0|Ov:100,100,100> [GC:G0 G54 G17 G21 G90 G94 M3 M9 T0 F0 S10000] [MSG:INFO: RS485 received message of unexpected length; expected:7 got:5] [MSG:DBG: VFD Measured Value 5441 Freq 132] [MSG:DBG: VFD Measured Value 4957 Freq 121] [MSG:DBG: VFD Measured Value 4472 Freq 109] [MSG:DBG: VFD Measured Value 3987 Freq 97] [MSG:DBG: VFD Measured Value 3503 Freq 85] [MSG:DBG: VFD Measured Value 3018 Freq 73] [MSG:DBG: VFD Measured Value 2533 Freq 61] [MSG:ERR: SiemensV20: spindle did not reach device units 0. Reported value is 61] [MSG:INFO: ALARM: Spindle Control] ALARM:10 ALARM:10 <Alarm|MPos:520.000,-165.000,130.000,0.000|FS:0,0> [MSG:DBG: SiemensV20: setState:5 SpindleSpeed:0] [MSG:DBG: VFD Measured Value 1222 Freq 29] [MSG:DBG: VFD Measured Value 737 Freq 17] [MSG:DBG: VFD Measured Value 252 Freq 6] [MSG:DBG: VFD Measured Value 0 Freq 0] [MSG:DBG: VFD Measured Value 0 Freq 0] [MSG:DBG: VFD Measured Value 0 Freq 0] [MSG:DBG: VFD Measured Value 0 Freq 0] [MSG:DBG: VFD Measured Value 0 Freq 0] [MSG:DBG: VFD Measured Value 0 Freq 0] [MSG:DBG: VFD Measured Value 0 Freq 0] [MSG:ERR: SiemensV20: spindle did not reach device units 0. Reported value is 0] [MSG:INFO: ALARM: Spindle Control] ALARM:10 ALARM:10 [MSG:DBG: SiemensV20: setState:5 SpindleSpeed:0] [MSG:INFO: ALARM: Spindle Control] ALARM:10 ALARM:10 ERROR:9 G-code commands are locked out during alarm or jog state. [MSG:ERR: GCode cannot be executed in lock or alarm state]

20Jakob09 avatar Nov 29 '25 21:11 20Jakob09

Try defining the UART outside the "SiemensV20" block, as described in the wiki:

Image

http://wiki.fluidnc.com/en/config/config_spindles#:~:text=uart1%3A%20txd_pin%3A%20gpio.17%20rxd_pin%3A%20gpio.16%20rts_pin%3A%20gpio.4%20baud%3A%209600%20mode%3A%208e1%20siemensv20%3A%20uart_num%3A%201%20modbus_id%3A%201%20tool_num%3A%200%20speed_map%3A%200%3D0%25%2024000%3D100%25

pseudorandomnumber avatar Nov 29 '25 21:11 pseudorandomnumber

Like so:

uart1:
    txd_pin: gpio.15
    rxd_pin: gpio.16
    rts_pin: gpio.14
    baud: 9600
    mode: 8E1

SiemensV20:
  uart_num: 1
  debug: 0
  modbus_id: 1
  tool_num: 0
  spinup_ms: 20000	
  spindown_ms: 20000
  speed_map: 0=0% 1=12.5% 3000=37.5% 9000=37.5% 24000=100%
  off_on_alarm: true

pseudorandomnumber avatar Nov 29 '25 21:11 pseudorandomnumber

what is the spin up time on the VFD?

bdring avatar Nov 29 '25 22:11 bdring

Like so:

uart1:
    txd_pin: gpio.15
    rxd_pin: gpio.16
    rts_pin: gpio.14
    baud: 9600
    mode: 8E1

SiemensV20:
  uart_num: 1

The RS485 communication is working, the spindle starts, so I don't think that should make a difference.

what is the spin up time on the VFD?

I don´t know exactly but mayby around 2 to 5 seconds. Definitely shorter than 20 seconds and the error occurs after about 1 second.

BTW: I updated from version 3.9.6 to 4.0 pre2

20Jakob09 avatar Nov 29 '25 22:11 20Jakob09

The alternative form with the uart section is more correct, but it won't affect the problem behavior.

MitchBradley avatar Nov 29 '25 22:11 MitchBradley

  • Was everything working before the upgrade to v4.0.0 pre2?
  • What command did you send to create there error? (like M3)
  • Where did you send the command from?

bdring avatar Nov 29 '25 23:11 bdring

  • Was everything working before the upgrade to v4.0.0 pre2?

Yes, it always worked well, at least when the spindle was started or stopped by the gcode. However, when the spindle was started via the WebUI, sometimes an error occurred. When stopping the spindle by pressing the off button in the WebUI, everything worked fine if the speed was above16.000 or 18.000 rpm. If it was below that, the spindle rotated at minimum speed in the other direction until the fluidnc issued the spindle control alarm.

* What command did you send to create there error? (like M3)

I Started the spindle via the buttons on the Web UI, I didn't know exactly what command it is.

* Where did you send the command from?

From the Web UI

BTW: It looks like the debug messages from the VFD appear faster in the Version 4.0 pre2 as in the version 3.9.6 But that's only a feeling. ;-)

20Jakob09 avatar Nov 30 '25 14:11 20Jakob09

I tried what happens when I type m3 S10000 into the command line, and the same error occurs.

Is it correct to assume that if spinup_ms is set to 20000 ms, the message [MSG:ERR: SiemensV20: spindle did not reach device units 166. Reported value is 128] should only appear after 20 seconds?

20Jakob09 avatar Nov 30 '25 14:11 20Jakob09

If it was working before with no hardware or config changes, there is likely a bug in the new release.

v4.0.0 is current in pre release so people can catch issues like this. The developers don't have every type of VFD, so this may take some time. Please revert to the version that was working for you.

bdring avatar Nov 30 '25 15:11 bdring

Hi, I'm working on implementing a protocol for the MK100 VFD, and I noticed a similar issue. I think the problem is in this fragment:

while ((_last_override_value == sys.spindle_speed_ovr()) && // skip if the override changes ((_sync_dev_speed < minSpeedAllowed || _sync_dev_speed > maxSpeedAllowed) && unchanged < limit)) { if (!xQueueReceive(VFD::VFDProtocol::vfd_speed_queue, &_sync_dev_speed, 3000)) { mc_critical(ExecAlarm::SpindleControl); log_error(name() << ": spindle did not reach device units " << dev_speed << ". Reported value is " << _sync_dev_speed); _syncing = false; return; } }

I couldn’t find where the speed is actually being pushed into VFD::VFDProtocol::vfd_speed_queue.

So I believe the current behavior is:

  1. Check the entry condition – enter the loop
  2. Wait to receive a message
  3. No message received – timeout after 3 seconds
  4. mc_critical(ExecAlarm::SpindleControl); is called

piotrs1 avatar Dec 01 '25 23:12 piotrs1

Adding xQueueSend(VFD::VFDProtocol::vfd_speed_queue, &vfd->_sync_dev_speed, 0); to method VFDProtocol::response_parser MK100Protocol::get_current_speed(ModbusCommand& data) fit it

I know this is a bad fix — especially since I don't fully understand the unchanged < limit check. It’s likely that unchanged needs to be updated within the while loop to ensure the condition behaves as expected.

The message should probably be added to the queue somewhere within the VFDSpindle class.

piotrs1 avatar Dec 02 '25 00:12 piotrs1