AX58100 IN OUT PINES

More
03 Dec 2024 14:05 #315890 by Hakan
Replied by Hakan on topic AX58100
It is only A and B for counting. You should probably verify with an oscilloscope that the signals from the encoder look like a nice quadrature signal.
The following user(s) said Thank You: SOLD

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

More
03 Dec 2024 15:27 #315897 by SOLD
Replied by SOLD on topic AX58100
Now I changed the new encoder, it works fine both cw ccw. I use oscilloscope to check ABZ, it's complete.
But I still can't find the index working in Hal.
And another question, the pin name in .comp and the name in pdo are different. Are they related?

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

More
03 Dec 2024 16:20 #315903 by Hakan
Replied by Hakan on topic AX58100
They are related, but not the same. You connect them together in the hal file, using the metalmusings_encoder comp.
Best is to look in the EaserCAT-2000 folder for how it is done there and replicate that, and adapt to your variable naming.
I see these lines in Turner.hal over there
loadrt metalmusings_encoder
addf metalmusings-encoder.0     servo-thread
net  to_encoder           metalmusings-encoder.0.index-latch-enable lcec.0.6.enc-index-latch-enable
net  from_encoder         metalmusings-encoder.0.index-status       lcec.0.6.index-status
net  spindle-index-enable metalmusings-encoder.0.index-c-enable

As mentioned before, you compile the module with
halcompile --compile metalmusings_encoder.comp

Uncomment also this line in main.cpp
Encoder1.setLatch(Obj.IndexLatchEnable);
The following user(s) said Thank You: SOLD

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

More
03 Dec 2024 16:22 #315904 by COFHAL
Replied by COFHAL on topic AX58100
My encoder now counts correctly, now I have to learn how to use it with LCN.
The following user(s) said Thank You: SOLD

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

More
04 Dec 2024 02:39 - 04 Dec 2024 06:42 #315929 by SOLD
Replied by SOLD on topic AX58100

My encoder now counts correctly, now I have to learn how to use it with LCN.
 

When you rotate the motor shaft, do you notice any changes in the hal index component?
What additional configurations do you have?
And what is your differential circuit?
Last edit: 04 Dec 2024 06:42 by SOLD.

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

More
04 Dec 2024 09:13 - 04 Dec 2024 09:37 #315937 by SOLD
Replied by SOLD on topic AX58100
My update encpos is working
- Pin PA0 PA1 PA3 checked with oscillator scope, when no pulse, it is high 5V and low 0V when pulse (test both pull up and pull down)
- Manage Txpdo Rxpdo according to EaserCAT-2000 example
- Improve Hal according to EaserCAT-2000 example
- I tried debugging with Chinese ST-Link, failed
- I monitor with TWINCAT, no change of IndexStatus when motor shaft rotated
I updated STM32 / ESI /EEPROM / XML, but still no change of index

Hal
loadusr -W lcec_conf ethercat-conf.xml
loadrt lcec
loadrt metalmusings_encoder

addf lcec.read-all            servo-thread
addf metalmusings-encoder.0     servo-thread
addf motion-command-handler   servo-thread
addf motion-controller        servo-thread

setp lcec.0.1.scale [SPINDLE_9]ENCODER_SCALE
#setp lcec.0.1.enc-pos-scale [SPINDLE_9]ENCODER_SCALE

net spindle-revs <= lcec.0.1.encpos
#net spindle-revs <= lcec.0.1.Encoder Position
loadrt invert 
loadrt mult2    names=mult2.rps,mult2.rpm
addf   invert.0   servo-thread
addf   mult2.rps  servo-thread
addf   mult2.rpm  servo-thread

setp invert.0.in          [SPINDLE_9]ENCODER_SCALE
setp mult2.rpm.in0        -60.0
setp mult2.rpm.in0        60.0
net  enc-invert-pos-scale mult2.rps.in0  <= invert.0.out
#net  enc-get-freq-rps     mult2.rps.in1  <= lcec.0.1.encfrequency
#net  spindle-vel-fb-rps   mult2.rpm.in1  <= mult2.rps.out
net  spindle-vel-fb-rpm   mult2.rpm.out
#net  spindle-index-enable lcec.0.1.indexstatus

net  spindle-vel-fb-rps   mult2.rpm.in1  <= lcec.0.1.encfrequency
net  spindle-vel-fb-rpm   mult2.rpm.out

net  to_encoder           metalmusings-encoder.0.index-latch-enable lcec.0.1.indexlatchenable
net  from_encoder         metalmusings-encoder.0.index-status       lcec.0.1.indexstatus
net  spindle-index-enable metalmusings-encoder.0.index-c-enable

main.cpp
///////// Spindle Encoder
#include "MyEncoder.h"
volatile uint16_t encCnt = 0;
void indexPulseEncoderCB1(void);
MyEncoder Encoder1(TIM2, PA3, indexPulseEncoderCB1);  
void indexPulseEncoderCB1(void)
{
   encCnt++;
   Encoder1.indexPulse();
}

////// EtherCAT routines called regularly, to read data, do stuff and write data
void cb_set_outputs(void) // Get Master outputs, slave inputs, first operation
{
   for (int i = 0; i < min(sizeof(Obj.Outputs), sizeof(OUTPUTS)); i++)
      digitalWrite(OUTPUTS[i], Obj.Outputs[i] == 1 ? HIGH : LOW);
   analogWrite(DAC1_pin, Obj.Voltage);
   Encoder1.setLatch(Obj.IndexLatchEnable);
   // Encoder1.setScale(2000);
   Step->stepgen_array[0].pos_scale = -Obj.StepsPerMM1; // Scale perhaps changed
   Step->stepgen_array[1].pos_scale = -Obj.StepsPerMM2;
   Step->stepgen_array[2].pos_scale = -Obj.StepsPerMM3;
   Step->stepgen_array[3].pos_scale = -Obj.StepsPerMM4;
   posCmd1 = Obj.CommandedPosition1; // The position update
   posCmd2 = Obj.CommandedPosition2;
   posCmd3 = Obj.CommandedPosition3;
   posCmd4 = Obj.CommandedPosition4;
}
void cb_get_inputs(void) // Set Master inputs, slave outputs, last operation
{
   Obj.Velocity = Obj.Scale * FrequencyMeasured;
   float scale = 1;
   if (Obj.Scale != 0.0)
      scale = Obj.Scale;
   Obj.Velocity = scale * sin(ESCvar.Time * 1e-8 * 6.28); // Test
   for (int i = 0; i < min(sizeof(Obj.Inputs), sizeof(INPUTS)); i++)
      Obj.Inputs[i] = digitalRead(INPUTS[i]) == HIGH ? 1 : 0;
#if 1
   Obj.IndexStatus = Encoder1.indexHappened();
   Obj.EncPos = Encoder1.currentPos();
   Obj.EncFrequency = Encoder1.frequency(longTime.extendTime(micros()));
   Obj.IndexByte = Encoder1.getIndexState();
   Obj.Velocity = Obj.Scale * FrequencyMeasured;
#endif
   Obj.ActualPosition1 = Step->stepgen_array[0].pos_fb;
   Obj.ActualPosition2 = Step->stepgen_array[1].pos_fb;
   Obj.ActualPosition3 = Step->stepgen_array[2].pos_fb;
   Obj.ActualPosition4 = Step->stepgen_array[3].pos_fb;
}

utypes.c
   /* Inputs */
   float Velocity;
   uint8_t Inputs[8];
   float Frequency;
   float ActualPosition1;
   float ActualPosition2;
   float ActualPosition3;
   float ActualPosition4;
   float EncPos;
   float EncFrequency;
   uint16_t DiffT;
   uint32_t IndexByte;
   uint8_t IndexStatus;
   /* Outputs */
   float Scale;
   uint8_t Outputs[4];
   float CommandedPosition1;
   float CommandedPosition2;
   float CommandedPosition3;
   float CommandedPosition4;
   int32_t StepsPerMM1;
   int32_t StepsPerMM2;
   int32_t StepsPerMM3;
   int32_t StepsPerMM4;
   float Voltage;
   uint8_t IndexLatchEnable;
 
Last edit: 04 Dec 2024 09:37 by SOLD.

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

More
04 Dec 2024 13:50 #315952 by COFHAL
Replied by COFHAL on topic AX58100
I am using the card designed by Hakan and it does not have a driver to make the differential encoder input. I have not tested the index yet, I have only tested the encoder with one that does not have an index pin. In the next few days I will try to test it with one that does have one.
The following user(s) said Thank You: SOLD

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

More
04 Dec 2024 14:04 #315953 by SOLD
Replied by SOLD on topic AX58100

I am using the card designed by Hakan and it does not have a driver to make the differential encoder input. I have not tested the index yet, I have only tested the encoder with one that does not have an index pin. In the next few days I will try to test it with one that does have one.

OK.
The following user(s) said Thank You: COFHAL

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

More
05 Dec 2024 00:37 #315988 by COFHAL
Replied by COFHAL on topic AX58100
I connected an encoder that has index, but I don't see any activity regarding that pin.
The following user(s) said Thank You: SOLD

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

More
05 Dec 2024 06:13 - 05 Dec 2024 06:16 #315996 by Hakan
Replied by Hakan on topic AX58100
The Index signal is short, in EtherCAT it is only one servo cycle long so you will most likely miss it, or the linuxcnc tools will miss it. Unless you happen to position the encoder exactly where the index signal is, then you can see it on the IndexByte.
Use halscope to watch the index signal in linuxcnc. Set sample time short enough to capture all data.
Last edit: 05 Dec 2024 06:16 by Hakan.
The following user(s) said Thank You: SOLD

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

Time to create page: 0.094 seconds
Powered by Kunena Forum