Remora - ethernet NVEM / EC300 / EC500 cnc board

  • tuxcnc
  • Away
  • Premium Member
  • Premium Member
More
19 Jun 2025 16:08 - 19 Jun 2025 16:29 #330518 by tuxcnc
I can't drive EC500 spindle encoder to work.
(The counter works properly, but index not. I can use encoder's index output as ordinary I/O, but this not satisfied me due to delays)
I suspect, this never will work, because the used code is wrong way.
I'm developing similar project (but only spindle support) on STM32F103, and my code seems works properly.
Here you are most important fragments:
[code]//********************************************************
This is a fragment of code from other project
Not for copy/paste, only for explanation
//********************************************************

// EC500 side
// fb. prefix means variables will send from EC500 to hal component

struct fbPacket {
    float raw_encoder;
    float encoder_latched;
} fb = { 0.0, 0.0 };

fb.raw_encoder = encoder.getCount();
void index_ISR1() {        // interrupt handler
  fb.encoder_latched  = encoder.getCount();
}

//********************************************************

// Hal component side
// fb. prefix means variables received from EC500
// index_ena is i/o hal pin for connect to spindle.0.index_enable
// pos_scale is hal input pin
// period is LinuxCNC global variable
// pos and vel are hal output pins
// Not need anything else for synchronising spindle

float old_pos;
float latched_enc;
float encoder_latched_old;
float delta_pos;
float delta_time;
struct FB {
    float raw_encoder;
    float encoder_latched;
} fb = { 0.0, 0.0 };

            if  ((encoder_latched_old != fb.encoder_latched) && (index_ena)) {
            latched_enc = fb.encoder_latched;
        old_pos = (fb.raw_encoder - latched_enc);
            index_ena = false;
            }
            encoder_latched_old = fb.encoder_latched;

   pos = (fb.raw_encoder - latched_enc) / pos_scale;
   delta_pos = pos - old_pos;
   old_pos = pos;
   delta_time = period * 1e-9;
   vel = delta_pos / delta_time;
   
//******************************************************** 
[/code]
 
Last edit: 19 Jun 2025 16:29 by tuxcnc. Reason: edit the code

Please Log in or Create an account to join the conversation.

  • scotta
  • scotta's Avatar Topic Author
  • Away
  • Platinum Member
  • Platinum Member
More
19 Jun 2025 20:35 #330531 by scotta
Hi, which module have you been trying to use? The software Encoder module or the QDC module? Both support the index pulse detection and encoder count latching so LinuxCNC can acquire the index position count.

Please Log in or Create an account to join the conversation.

Time to create page: 0.143 seconds
Powered by Kunena Forum