AX58100 IN OUT PINES
- SOLD
- Offline
- Premium Member
- Posts: 115
- Thank you received: 10
What I don't understand is when an index is detected, how does your encoder command element change the state?
For example:
Obj.IndexStatus = Encoder1.indexHappened();
Checks if an index pulse has occurred (uses the indexPulseFired variable).
If it has, it returns 1 and resets the state.
Obj.IndexByte = Encoder1.getIndexState();
Reads the digital value of the index pin directly (0 or 1).
Used to check the current state of the index signal.
This information, even monitoring with Twincat, does not detect any.
I am now starting to practice debugging and serial monitoring.
And next I think I will try EaserCAT-2000 with AX58100, but it is still difficult to change from LAN9295 to AX58100 with the original firmware of EaserCAT-2000.
Please Log in or Create an account to join the conversation.
- Hakan
- Offline
- Platinum Member
- Posts: 489
- Thank you received: 155
Just to assign Obj.D1 = interesting_value and watch that value.
An alternative to the index shift is to have a counter counting up when the callback happens, there is
actually one already in my code "encCnt" which increments every time the index callback is called.
Just quickly checked in the debugger, here the callback is triggered when index passes by.
Please Log in or Create an account to join the conversation.
- Hakan
- Offline
- Platinum Member
- Posts: 489
- Thank you received: 155
Please Log in or Create an account to join the conversation.
- SOLD
- Offline
- Premium Member
- Posts: 115
- Thank you received: 10
Please Log in or Create an account to join the conversation.
- Hakan
- Offline
- Platinum Member
- Posts: 489
- Thank you received: 155
This is the traditional syntax in hal to enable synchronization on index signal
linuxcnc.org/docs/html/examples/spindle...._synchronized_motion
net spindle-index-enable encoder.3.index-enable => spindle.0.index-enable
First look at what motion.spindle.M.index-enable says
spindle.M.index-enable I/O BIT
For correct operation of spindle synchronized moves,
this signal must be hooked to the index-enable pin
of the spindle encoder.
Then look at what the encoder's index-enable pin says
linuxcnc.org/docs/html/man/man9/encoder.9.html
These three lines say a lot. This is the behavior the EtherCAT client tries to replicate.encoder.N.index-enable bit i/o
When true, counts and position are reset to zero on the
next rising edge of Phase-Z. At the same time, index-enable
is reset to zero to indicate that the rising edge has occurred.
index-enable is a I/O bit, that means read AND write variable. As mentioned, EtherCAT variables
are read OR write. The metalmusings_encoder component split index-enable in two variables
one read variable that forwards the value to the EtherCAT client, and one write variable
that when set will change index-enable, as specified above.
In the EaserCAT 3000 client, when Obj.IndexLatchEnable is set, i.e. when index-enable is set, it waits for the next Z-index interrupt, which then then zeroes the counters. This needs to be done exactly when the Z index happens, not any time afterwards. Because this happens in an ISR it communicates to the rest of EaserCAT with indexPulseFired variable. So in cb_get_inputs() when setting whether the index fired it will know that from this variable.
It is pretty indirect programming, but that is how I have been taught to communicate with ISRs.
Then it will set Obj.IndexHappened, which will go the the metalmusings_encoder component whioch will reset the i/o variable.
Not sure this clears things up, not so easy to write a good clear answer to this.
Please Log in or Create an account to join the conversation.
- SOLD
- Offline
- Premium Member
- Posts: 115
- Thank you received: 10
After receiving your explanation, I'll go back to metalmusings_encoder.comp to double check the bindings with the GPT explanation.
Components and pins:
Component metalmusings_encoder: This component represents the encoder's function related to the index signal.
Index-c-enable pin (bit): This pin is used to control whether the index-enable signal is on or off.
Index-status pin (u32): This pin holds the status of the index signal, indicating whether the index is latched.
Index-latch-enable pin (u32): This pin is used to latch the index-enable state to synchronize it with the correct position.
Main function logic:
Initialization:
index_latch_enable = index_c_enable;
This causes index-latch-enable to follow the value of index_c_enable , if index_c_enable Set to true (high), index-latch-enable will be enabled.
When index_latch_enable is true:
If index_latch_enable is set to true (when index_c_enable is high), it checks whether index_status is true.
If index_status is true (i.e., a jitter occurs on the index signal), it resets index_c_enable to 0.
if (index_status) { index_c_enable = 0; }
This means that when the index signal is detected, index_c_enable will be reset to prevent re-jittering.
When index_latch_enable is false:
If index_latch_enable is false (i.e., not synchronized), the system will wait for index_status to trigger index_c_enable to true.
index_c_enable = index_status;
This means that index_c_enable will be set based on the state of index_status and wait for a jitter from the index signal.
Overall behavior:
When index_c_enable is true:
The system checks index_status. If index_status is true (i.e. the index is latched), index_c_enable is set to 0 to prevent re-latching.
When index_c_enable is false:
The system waits for index_status to be true to trigger index_c_enable again, which causes synchronization when the index signal is latched.
Summary:
This component handles the index-enable signal by varying the value of index_c_enable depending on the state of index_status. It causes position synchronization to occur when the index signal is latched, and when index_latch_enable is set, the system resets index_c_enable after a latch from the index, which allows position synchronization to occur at the appropriate time.
Please Log in or Create an account to join the conversation.
- SOLD
- Offline
- Premium Member
- Posts: 115
- Thank you received: 10
Information about Name Data type in Obj Direction Data type EEPROM Generator Associated function Description
IndexLatchEnable uint8_t UNSIGNED8 cb_set_outputs() Enable or disable Index Pulse latch
EncPos double REAL32 cb_get_inputs() + MyEncoder.currentPos() Current position of the Encoder
EncFrequency double REAL32 cb_get_inputs() + MyEncoder.frequency() Frequency of the Encoder
IndexStatus uint8_t UNSIGNED8 cb_get_inputs() + MyEncoder.indexHappened() Status of the Index Pulse
IndexByte uint8_t UNSIGNED8 cb_get_inputs() + MyEncoder.getIndexState() Status of the Index
Velocity double REAL32 cb_get_inputs() Speed of the system (calculated from the Encoder or other data)
Please Log in or Create an account to join the conversation.
- SOLD
- Offline
- Premium Member
- Posts: 115
- Thank you received: 10
Attachments:
Please Log in or Create an account to join the conversation.
- Hakan
- Offline
- Platinum Member
- Posts: 489
- Thank you received: 155
As you found out, the variable updates when the program is paused, or stepping.
Please Log in or Create an account to join the conversation.
- COFHAL
- Offline
- Platinum Member
- Posts: 334
- Thank you received: 37
Please Log in or Create an account to join the conversation.