@@ -259,7 +259,7 @@ static void state_thc_pid (void)
259259 strcat(buf, ftoa(err, 1));
260260 report_message(buf, Message_Info);
261261*/
262- st2_motor_move (z_motor , - err / plasma .arc_height_per_volt , settings .axis [Z_AXIS ].max_rate , Stepper2_mm );
262+ st2_motor_move (z_motor , - err * plasma .arc_height_per_volt , settings .axis [Z_AXIS ].max_rate , Stepper2_mm );
263263 }
264264 }
265265 }
@@ -318,25 +318,25 @@ static void reset (void)
318318}
319319
320320// Start or stop arc
321- static void arcSetState (spindle_state_t state , float rpm )
321+ static void arcSetState (spindle_ptrs_t * spindle , spindle_state_t state , float rpm )
322322{
323323 if (driver_reset == NULL ) {
324- spindle_set_state_ (state , rpm );
324+ spindle_set_state_ (spindle , state , rpm );
325325 if (state .on )
326326 report_message ("Plasma mode not available!" , Message_Warning );
327327 return ;
328328 }
329329
330- if (!state .on ) {
330+ if (!state .on ) {
331331 if (plasma .pause_at_end > 0.0f )
332332 delay_sec (plasma .pause_at_end , DelayMode_Dwell );
333- spindle_set_state_ (state , rpm );
333+ spindle_set_state_ (spindle , state , rpm );
334334 thc .torch_on = thc .arc_ok = thc .enabled = Off ;
335335 stateHandler = state_idle ;
336336 } else {
337337 uint_fast8_t retries = plasma .arc_retries ;
338338 do {
339- spindle_set_state_ (state , rpm );
339+ spindle_set_state_ (spindle , state , rpm );
340340 thc .torch_on = On ;
341341 report_message ("arc on" , Message_Plain );
342342 if ((thc .arc_ok = port .wait_on_input (Port_Digital , port_arc_ok , WaitMode_High , plasma .arc_fail_timeout ) != -1 )) {
@@ -347,12 +347,12 @@ static void arcSetState (spindle_state_t state, float rpm)
347347 } else if (!(-- retries )) {
348348 thc .torch_on = Off ;
349349 report_message ("arc failed" , Message_Warning );
350- spindle_set_state_ ((spindle_state_t ){0 }, 0.0f );
350+ spindle_set_state_ (spindle , (spindle_state_t ){0 }, 0.0f );
351351 pause_on_error (); // output message and enter similar state as tool change state (allow jogging before resume)
352352 } else {
353353 thc .torch_on = Off ;
354354 report_message ("arc delay" , Message_Plain );
355- spindle_set_state_ ((spindle_state_t ){0 }, 0.0f );
355+ spindle_set_state_ (spindle , (spindle_state_t ){0 }, 0.0f );
356356 delay_sec (plasma .arc_retry_delay , DelayMode_Dwell );
357357 }
358358 } while (retries );
@@ -529,7 +529,7 @@ static const setting_descr_t plasma_settings_descr[] = {
529529 "For initial setup multiply the arc voltage out value by -1 and enter that for Voltage Offset."
530530 },
531531 { Setting_Arc_HeightPerVolt , "The distance the torch would need to move to change the arc voltage by one volt.\\n"
532- "Used for manual height change only."
532+ // "Used for manual height change only."
533533 },
534534 { Setting_Arc_OkHighVoltage , "High voltage threshold for Arc OK." },
535535 { Setting_Arc_OkLowVoltage , "Low voltage threshold for Arc OK." },
@@ -570,10 +570,14 @@ static void plasma_settings_restore (void)
570570 plasma .pid .d_gain = 0.0f ;
571571
572572 if (ioport_can_claim_explicit ()) {
573+
574+ n_ain = ioports_available (Port_Analog , Port_Input );
575+ n_din = ioports_available (Port_Digital , Port_Input );
576+
573577 plasma .port_arc_voltage = n_ain - 1 ;
574578 plasma .port_arc_ok = n_din - 1 ;
575- plasma .port_cutter_down = n_din - 2 ;
576- plasma .port_cutter_up = n_din - 3 ;
579+ plasma .port_cutter_down = updown_enabled ? n_din - 2 : 255 ;
580+ plasma .port_cutter_up = updown_enabled ? n_din - 3 : 255 ;
577581 }
578582
579583 hal .nvs .memcpy_to_nvs (nvs_address , (uint8_t * )& plasma , sizeof (plasma_settings_t ), true);
@@ -693,7 +697,7 @@ static void plasma_report_options (bool newopt)
693697 on_report_options (newopt );
694698
695699 if (!newopt )
696- hal .stream .write ("[PLUGIN:PLASMA v0.08 ]" ASCII_EOL );
700+ hal .stream .write ("[PLUGIN:PLASMA v0.11 ]" ASCII_EOL );
697701 else if (driver_reset ) // non-null when successfully enabled
698702 hal .stream .write (",THC" );
699703}
@@ -730,7 +734,7 @@ void plasma_init (void)
730734 ok = (nvs_address = nvs_alloc (sizeof (plasma_settings_t )));
731735 }
732736
733- if (ok && (z_motor = st2_motor_init (Z_AXIS )) != NULL ) {
737+ if (ok && (z_motor = st2_motor_init (Z_AXIS , false )) != NULL ) {
734738
735739 if (n_ain )
736740 strcpy (max_aport , uitoa (n_ain - 1 ));
0 commit comments