Remora - ethernet NVEM / EC300 / EC500 cnc board

More
3 years 3 months ago #275373 by cakeslob
Hey tux, thats not exactly within the scope of the remora project, and more of a general linuxcnc thing.


But since I am also trying to do lathe threading, here is my attempt so far. the encoder/spindle portion is at the bottom

github.com/cakeslob/Remora/blob/nucleo_s...nuc_q/remora-xyz.hal

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

More
3 years 3 months ago #275395 by tuxcnc

Hey tux, thats not exactly within the scope of the remora project, and more of a general linuxcnc thing.


But since I am also trying to do lathe threading, here is my attempt so far. the encoder/spindle portion is at the bottom

github.com/cakeslob/Remora/blob/nucleo_s...nuc_q/remora-xyz.hal
 
You don't understand the question.
There is this line in config file you linked:
net encoder-phaseZ <= remora.input.15 => encoder.0.phase-Z
The remora.input.15 is a HAL PIN, not internal EC500 pin declared in this line of github.com/scottalford75/Remora-RT1052-c.../encoder/encoder.cpp file:
const char* pinI = module["Index Pin"];
The HAL pin is read by HAL and must be at least as long as HAL servo-thread period. This causes problem and produce big angle error.
There is internal "Index Pin" read by RT1052 in EC500, works immediately when encoder device's index signal change, but of course there is no information how to use it...
The configuration with HAL pin I already have.
Let's assume 3000 rpm and 1 ms HAL servo thread.
This is 20 ms per rotate, the encoder index must be at least 18 degree (1 ms of 20 ms is 5%, 5% of 360 degrees is 18 degrees) and the possible error will be 18 degree too. This is useless in practice, because if synchronize lost (for example G0 between G33) you will not hit the same thread.
Don't ask who make threads at 3000 rpm, it must work even if nobody.

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

More
3 years 3 months ago #275396 by scotta
Hi, 

Yes, LinuxCNC can only read IO as fast as the servo thread frequency. So some "smarts" are built into the LinuxCNC encoder component and the Remora PRU encoder module / component. The encoder count is latched internally in the controller board and sent to LinuxCNC for a number of servo periods. This way LinuxCNC will see the correct encoder count when it sees the index input.
Code:
        // handle index, index pulse and pulse count         if (this->pinI->get() && (this->pulseCount == 0))    // rising edge on index pulse         {             this->indexCount = this->count;                 //  capture the encoder count at the index, send this to linuxCNC for one servo period              *(this->ptrEncoderCount) = this->indexCount;             this->pulseCount = this->indexPulse;                     *(this->ptrData) |= this->mask;                 // set bit in data source high         }

Also, please check that you can actually keep up with the encoder pulses per rev. If not then I'll need to look at how we can implement hardware counting which may / may not be available on the pins.

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

More
3 years 3 months ago #275421 by tuxcnc

Code:
Also, please check that you can actually keep up with the encoder pulses per rev. If not then I'll need to look at how we can implement hardware counting which may / may not be available on the pins.
 
I try to explain what I did.

### Test 1 ###

In the ec500-rt1052.txt :

{
    "Thread": "Base",
    "Type": "Encoder",
        "Comment":            "Encoder A-IN9 B-IN10",
        "PV":            0,
        "ChA Pin":            "P3_19",
        "ChB Pin":            "P3_20"
    }
    
In the remora-ec500.hal :

# Initialize the encoder (spindle)
    loadrt PRUencoder names=encoder.1
    addf PRUencoder.capture-position servo-thread
    setp encoder.1.position-scale 1200.000000 #6
# connect the hal encoder to linuxcnc
    net encoder-count remora.PV.0 encoder.1.raw_count
    net encoder-phaseZ remora.input.11 encoder.1.phase-Z

I removed the blocks configured IN9 and IN10 as inputs from ec500-rt1052.txt (I suspect the pins may be defined only once).

Works as expected.
I ran halmeter, chose encoder.1.position and seen that value changed when encoder turned.
I ran halcmd setp encoder.1.index-enable 1
The pin changed state to True, but when encoder changed index output the index-enable changed to False and position changed to zero.

### Test 2 ###

In the remora-ec500.hal I removed the line with net encoder-phaseZ remora.input.11 encoder.1.phase-Z
In the ec500-rt1052.txt I added this line : "Index Pin": "P3_21" and removed declaration this pin as input.
I can change value of encoder.1.position, but encoder Z output does nothing, the encoder.1.index-enable after set is always True, and positon not resets.

What I do wrong ?

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

More
3 years 3 months ago #275454 by scotta

Code:
Also, please check that you can actually keep up with the encoder pulses per rev. If not then I'll need to look at how we can implement hardware counting which may / may not be available on the pins.   I try to explain what I did. ### Test 1 ### In the ec500-rt1052.txt : {     "Thread": "Base",     "Type": "Encoder",         "Comment":            "Encoder A-IN9 B-IN10",         "PV[i]":            0,         "ChA Pin":            "P3_19",         "ChB Pin":            "P3_20"     }      In the remora-ec500.hal : # Initialize the encoder (spindle)     loadrt PRUencoder names=encoder.1     addf PRUencoder.capture-position servo-thread     setp encoder.1.position-scale 1200.000000 #6 # connect the hal encoder to linuxcnc     net encoder-count remora.PV.0 encoder.1.raw_count     net encoder-phaseZ remora.input.11 encoder.1.phase-Z I removed the blocks configured IN9 and IN10 as inputs from ec500-rt1052.txt (I suspect the pins may be defined only once). Works as expected. I ran halmeter, chose encoder.1.position and seen that value changed when encoder turned. I ran halcmd setp encoder.1.index-enable 1 The pin changed state to True, but when encoder changed index output the index-enable changed to False and position changed to zero. ### Test 2 ### In the remora-ec500.hal I removed the line with net encoder-phaseZ remora.input.11 encoder.1.phase-Z In the ec500-rt1052.txt I added this line : "Index Pin": "P3_21" and removed declaration this pin as input. I can change value of encoder.1.position, but encoder Z output does nothing, the encoder.1.index-enable after set is always True, and positon not resets. What I do wrong ?[/i]
Good to see you are making progress. 
This is your original working index pin input, correct?
Code:
    {     "Thread": "Servo",     "Type": "Digital Pin",         "Comment":            "IN08",         "Pin":                "P3_21",         "Mode":                "Input",         "Data Bit":            11,         "Invert":            "False"     },

You will also need to set the Data Bit in the encoder configuration.
Code:
{     "Thread": "Base",     "Type": "Encoder",         "Comment":            "Encoder A-IN9 B-IN10",         "PV[i]":            0,         "ChA Pin":            "P3_19",         "ChB Pin":            "P3_20",     "Data Bit":          11,         "Index Pin":          "P3_21",     }

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

More
3 years 3 months ago - 3 years 3 months ago #275481 by tuxcnc

Code:
[i][code]You will also need to set the Data Bit in the encoder configuration. [code]{     "Thread": "Base",     "Type": "Encoder",         "Comment":            "Encoder A-IN9 B-IN10",         "PV[i]":            0,         "ChA Pin":            "P3_19",         "ChB Pin":            "P3_20",     "Data Bit":          11,         "Index Pin":          "P3_21",     }[/i]
[/code][/i][/code]

Works with line < net encoder-phaseZ remora.input.11 encoder.1.phase-Z > in remora-ec500.hal, but I suspect the PRUencoder component works, not internal EC500 procedure.
If you remove that line from hal config, index input does not work - counter works, but you can't reset it.
You wrote, you do not have 24V encoder. It is not problem for tests, you can use switch connected to index input and com- terminals, it is enough to see is the index-enable pin resets on index edge.
Run < halcmd setp encoder.1.index-enable 1 >, click switch, see encoder.1.index-enable in halmeter, if it is still TRUE, the code not works.
Last edit: 3 years 3 months ago by tuxcnc.

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

Time to create page: 0.651 seconds
Powered by Kunena Forum