- Configuring LinuxCNC
- Advanced Configuration
- EtherCAT
- Ethercat compatible Encoder board tentative STM32F4 + LAN9252
Ethercat compatible Encoder board tentative STM32F4 + LAN9252
- Hakan
- Offline
- Platinum Member
-
Less
More
- Posts: 1152
- Thank you received: 412
13 Dec 2025 17:49 #340063
by Hakan
Replied by Hakan on topic Ethercat compatible Encoder board tentative STM32F4 + LAN9252
Are you sure spi works?
Apart from that, make sure the stm32 and the eeprom are in sync, that is, they both come from the same saving of "Save all files"
and that the firmware is compiled and downloaded. It doesn't hurt to do it one more time.
Power cycle the board to make sure both stm32 and lan9252 read the most recent data.
Right-click the mouse on the marked item and remove it. Scan for new boxes to make it reappear.
Also quit Twincat and start it.
All a bit extra cautious to make sure any old data/cache is eliminated.
Apart from that, make sure the stm32 and the eeprom are in sync, that is, they both come from the same saving of "Save all files"
and that the firmware is compiled and downloaded. It doesn't hurt to do it one more time.
Power cycle the board to make sure both stm32 and lan9252 read the most recent data.
Right-click the mouse on the marked item and remove it. Scan for new boxes to make it reappear.
Also quit Twincat and start it.
All a bit extra cautious to make sure any old data/cache is eliminated.
Please Log in or Create an account to join the conversation.
- vibram
- Offline
- Senior Member
-
Less
More
- Posts: 79
- Thank you received: 1
14 Dec 2025 09:16 #340089
by vibram
Replied by vibram on topic Ethercat compatible Encoder board tentative STM32F4 + LAN9252
I managed to get spi working but I might have an issue with the eeprom. Apparently I'm stuck in PDI mode and lan9252 is not communicating through spi
Please Log in or Create an account to join the conversation.
- Hakan
- Offline
- Platinum Member
-
Less
More
- Posts: 1152
- Thank you received: 412
14 Dec 2025 10:54 #340091
by Hakan
Replied by Hakan on topic Ethercat compatible Encoder board tentative STM32F4 + LAN9252
PDI = that parallel communication mode? Noone uses it. Everyone uses SPI.
The last few lines in the xml file should look similar to this. The first "80" means spi, then there
is polarity and other settings.Read out the eeprom from the board and verify that is says "80" in the first byte.
I have had my fair share of problems with SPI so I think you again should verify that you can get past the ESC_init() function.
Use the debugger and verify that you read 0x87654321 from LAN9252 on line 445 in the figure
You may need to power cycle the LAN9252, it only reads eeprom after power down.
The last few lines in the xml file should look similar to this. The first "80" means spi, then there
is polarity and other settings.
<Eeprom>
<ByteSize>2048</ByteSize>
<ConfigData>80060344640000</ConfigData>
</Eeprom>I have had my fair share of problems with SPI so I think you again should verify that you can get past the ESC_init() function.
Use the debugger and verify that you read 0x87654321 from LAN9252 on line 445 in the figure
You may need to power cycle the LAN9252, it only reads eeprom after power down.
Attachments:
Please Log in or Create an account to join the conversation.
- vibram
- Offline
- Senior Member
-
Less
More
- Posts: 79
- Thank you received: 1
14 Dec 2025 21:07 #340099
by vibram
Replied by vibram on topic Ethercat compatible Encoder board tentative STM32F4 + LAN9252
My ESC TEST VALUE reading is fine...
i tried a lot of things but dont know why i cant get the eeprom correctly set up. Maybe its something with the board I dont know
i tried a lot of things but dont know why i cant get the eeprom correctly set up. Maybe its something with the board I dont know
Please Log in or Create an account to join the conversation.
- vibram
- Offline
- Senior Member
-
Less
More
- Posts: 79
- Thank you received: 1
14 Dec 2025 22:00 #340105
by vibram
Replied by vibram on topic Ethercat compatible Encoder board tentative STM32F4 + LAN9252
In order to limit costs and continue tests maybe I should try to build a lan9252 prototype board with eeprom spi and i2c.
Please Log in or Create an account to join the conversation.
- Hakan
- Offline
- Platinum Member
-
Less
More
- Posts: 1152
- Thank you received: 412
15 Dec 2025 00:43 #340107
by Hakan
Replied by Hakan on topic Ethercat compatible Encoder board tentative STM32F4 + LAN9252
Ok ok. Spi was a pain for me until I got it sorted that's why I wanted to be really sure it works. Nothing works without spi.
There are a few hardware bootstrap jumpers on the Lan9252.
They are described in the schematics for lan9252 evaluation board.
I have them marked on all board schematics.
You can compare them with your board, perhaps there is something different?
I guess it wouldn't be too difficult to replicate your board and try to troubleshoot it.
Can you make sure to push relevant code to github and I can have a look at that.
I'm pretty sure I can puzzle together the hardware.
You are going to end up designing a board, just start haha.
You mention I2C. If you need it, yes. Otherwise no. I used it for
plasma arch voltage. Worked great, but if you don't need it don't include I2C.
There are a few hardware bootstrap jumpers on the Lan9252.
They are described in the schematics for lan9252 evaluation board.
I have them marked on all board schematics.
You can compare them with your board, perhaps there is something different?
I guess it wouldn't be too difficult to replicate your board and try to troubleshoot it.
Can you make sure to push relevant code to github and I can have a look at that.
I'm pretty sure I can puzzle together the hardware.
You are going to end up designing a board, just start haha.
You mention I2C. If you need it, yes. Otherwise no. I used it for
plasma arch voltage. Worked great, but if you don't need it don't include I2C.
The following user(s) said Thank You: besriworld
Please Log in or Create an account to join the conversation.
- Hakan
- Offline
- Platinum Member
-
Less
More
- Posts: 1152
- Thank you received: 412
15 Dec 2025 08:23 - 15 Dec 2025 08:24 #340114
by Hakan
Replied by Hakan on topic Ethercat compatible Encoder board tentative STM32F4 + LAN9252
Good morning, I have looked at the code now. Clear out the whole loop() function and insert just this line
That should do it. You never called ecat_slv() in cyclous mode.
The danger of using someone else's code.
It meant it never used spi to query lan9252 for changes and updates to register etc etc.
There were a lot of diagnozing and trouble-shooting with the I2C so I wanted an easy way
to run the board as a normal aurduino without the ethercat things. It was required to define ECAT
during compile for it to be an ecat device. Now that is gone, so remove all of that.
void loop(void) {
ecat_slv();
}That should do it. You never called ecat_slv() in cyclous mode.
The danger of using someone else's code.
It meant it never used spi to query lan9252 for changes and updates to register etc etc.
There were a lot of diagnozing and trouble-shooting with the I2C so I wanted an easy way
to run the board as a normal aurduino without the ethercat things. It was required to define ECAT
during compile for it to be an ecat device. Now that is gone, so remove all of that.
Last edit: 15 Dec 2025 08:24 by Hakan.
Please Log in or Create an account to join the conversation.
- Hakan
- Offline
- Platinum Member
-
Less
More
- Posts: 1152
- Thank you received: 412
16 Dec 2025 12:24 #340188
by Hakan
Replied by Hakan on topic Ethercat compatible Encoder board tentative STM32F4 + LAN9252
I connected up the hardware in the same way as your system. It didn't want to go to PREOP.
It seems you have been editing a lot, at least some, in lib/soes and I would say that's a big no-no. Leave that as is.
I restored lib/soes from E7000, fixed settings for SPI, removed all SPI from main.cpp, modified loop() and the card is now up and running in PREOP.
You shouldn't need to make a lot of editing in lib/soes, only to get SPI running and I think it was fine the way you did it.
All editing for SDOs PDOs etc are done through the EEPROM_generator, no manual editing is needed.
It seems you have been editing a lot, at least some, in lib/soes and I would say that's a big no-no. Leave that as is.
I restored lib/soes from E7000, fixed settings for SPI, removed all SPI from main.cpp, modified loop() and the card is now up and running in PREOP.
You shouldn't need to make a lot of editing in lib/soes, only to get SPI running and I think it was fine the way you did it.
All editing for SDOs PDOs etc are done through the EEPROM_generator, no manual editing is needed.
Attachments:
The following user(s) said Thank You: besriworld
Please Log in or Create an account to join the conversation.
- vibram
- Offline
- Senior Member
-
Less
More
- Posts: 79
- Thank you received: 1
16 Dec 2025 13:12 #340189
by vibram
Replied by vibram on topic Ethercat compatible Encoder board tentative STM32F4 + LAN9252
Please Log in or Create an account to join the conversation.
- Hakan
- Offline
- Platinum Member
-
Less
More
- Posts: 1152
- Thank you received: 412
16 Dec 2025 20:29 - 16 Dec 2025 20:29 #340209
by Hakan
Replied by Hakan on topic Ethercat compatible Encoder board tentative STM32F4 + LAN9252
It's better I give you a hand in those situations. So you have a version you always can come back to that works.
And then you can be creative on top of that get lost from there.
But what you have described you want to do, you are more or less finished already.
There is of course the whole packaging story, Din-rail? box, other? external power supply, connectors, photo-diodes on encoder input?
Stacking of several units? Can you perhaps use the 16-bit counters and have several counters on board? Is there a MCU with several 32-bit encoders you can use/switch to. Just because it works doesn't mean it is finished. For sure it can be optimized.
Right now it runs in free-run mode, should probably go over to DC-sync mode and there is a bit of programming for that. Same HW though.
Microchip has come out with several schematics for their evaluation boards, here is one ww1.microchip.com/downloads/en/DeviceDoc...PIO16.Mode.Rev.A.pdf Here is another ww1.microchip.com/downloads/aemDocuments...DIG-IO-EVB-REV-B.pdf and you find schematics in my KiCaD files.
And then you can be creative on top of that
But what you have described you want to do, you are more or less finished already.
There is of course the whole packaging story, Din-rail? box, other? external power supply, connectors, photo-diodes on encoder input?
Stacking of several units? Can you perhaps use the 16-bit counters and have several counters on board? Is there a MCU with several 32-bit encoders you can use/switch to. Just because it works doesn't mean it is finished. For sure it can be optimized.
Right now it runs in free-run mode, should probably go over to DC-sync mode and there is a bit of programming for that. Same HW though.
Microchip has come out with several schematics for their evaluation boards, here is one ww1.microchip.com/downloads/en/DeviceDoc...PIO16.Mode.Rev.A.pdf Here is another ww1.microchip.com/downloads/aemDocuments...DIG-IO-EVB-REV-B.pdf and you find schematics in my KiCaD files.
Last edit: 16 Dec 2025 20:29 by Hakan.
The following user(s) said Thank You: besriworld
Please Log in or Create an account to join the conversation.
- Configuring LinuxCNC
- Advanced Configuration
- EtherCAT
- Ethercat compatible Encoder board tentative STM32F4 + LAN9252
Time to create page: 0.205 seconds