linuxcnc-esp32 Software Stepping over Ethernet Using ESP32

More
28 May 2021 07:45 #210494 by BeagleBrainz
Configs and hal are here:
github.com/dlhenke/linuxcnc-esp32/tree/main/my-mill


The ino files doesn't actually setup any pins for I/O accept for the pins used for DIR & encoder.
I think the hal pins are for for future use.

The more I look at the 2 repos the more the code seems just for proof of concept. Seems there is some work required to get a production setup out of it. Not a lot mind.

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

More
28 May 2021 14:58 #210534 by tjtr33
more work on linuxcnc esp32 step generators
github.com/dlhenke/linuxcnc-esp32

i was begining to edit a /ini and .hal usimg deotti's udp.comp and linuxinterface.ino
and i saw this 'branck' ( sortof)
it has a config dir (mymill) with the usual hal and ini and more

I'm still chewing on 'set your eth0 to 192.168.1.10' how?

i will be looking into it and may test drive it soon
just fyi

tomp

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

More
28 May 2021 15:11 - 28 May 2021 15:17 #210537 by BeagleBrainz
If your ethxx has a static address you can change the address in the sketch and comp to be on the same network.

Eg if your eth1 is 10.10.10.10 just change the comp and sketch to, say, 10.10.10.101.

For testing I had mine connected thru a 1gb switch.

One of the things I’m working is being able to set the address when loading the comp to match the esp32 board. Similar to how you would for a Mesa card & setting the scale thru a parameter.

I got distracted by actually making an attempt to finish the chip tray for the mill so the new control cabinet can get hooked up. Unfortunately it’s slow going as the temp has dropped to the low twenties to high teens. Tho I guess it is autumn. It really annoys me that paint needs time to dry.
Last edit: 28 May 2021 15:17 by BeagleBrainz.

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

More
29 May 2021 15:05 #210627 by tjtr33
Hello,
I used the config files from github.com/dlhenke/linuxcnc-esp32 as a start point, but simplified them

Theres a lot about networking that i do not know :-)

I do know the desktop I work on has only 1 ethernet port and it is named eth0
sudo ifconfig
,,,
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.7  netmask 255.255.255.0  broadcast 192.168.1.255

I know the sketch talks about 192.168.1.177
byte mac[] = {   0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 177);
IPAddress sub(255, 255, 255, 0); 
unsigned int localPort = 27181;

I know the comp also talks about 192.168.1.177
server = gethostbyname("192.168.1.177");

I know I can ping 192.168.1.177 after programming the esp32 and connecting the w5500 and cat 5 cale to router.

There is only 1 ethernet connected to the esp's w5500
it has no 'eth' enumeration and does not appear with 'sudo ifconfig'
and it responds to pings to 192.168.1.177
and fails to respond if I remove the cat5 from it to the router
( this action requires the ESP32 to be reset before further pinging )

And with this and the attached configs,
I cannot jog at any axis without "joint <pickanaxisanyaxis> following error"

So Thats what I do know.
so i try to reply to your points...
If your ethxx has a static address you can change the address in the sketch and comp to be on the same network.

my eth0 has dhcp generated ip addr 192.168.1.7
my eth0 is not connected to the w5500,
it is connetcted to my router

the address mentioned in sketch and comp are both 192.168.1.177
all of these ( .1.177, .1.7) are on same (local) network.
Eg if your eth1 is 10.10.10.10 just change the comp and sketch to, say, 10.10.10.101.

hmm my only enumerated eth is eth0
it has been given 192.168.1.7 by dhcp
and the comp and the sketch were using 192.168.1.177
and i could not jog w/o followinf errors ( not 1micron at 10mm/min )
so,

I just edited udp.comp to use 192.168.1.7 and compiled and installed it into the ~/linuxcnc-dev/rtlib/ directory
i also edited the sketch to use 192.168.1.7 and programmed the esp32 with that
now eth0 comp and sketch alll use 192.168.1.7
and same result,-cannot jog w/o f-errors

if you meant to make sure comp and sketch were same as eth0, then it did not work
if you meant to make comp and sketch same as each other yet different from eth0, then it it didnt work

what am i doing wrong?

also, i dont see any ster or direction pins,
how can a stepgen be used without step and direction signals to step and direction drivers?
What was hooked up to that scope in the video?

thanks tomp

( the .ino file had to be renamed .ino.txt for the attachment rules of this forum)
Attachments:

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

More
29 May 2021 19:54 - 29 May 2021 20:25 #210647 by BeagleBrainz
The esp32 and your computer can not have the same address.
Whilst the first 3 numbers, the network, must be the same, the 4th number must be unique to every device on the network.
In the theoretic example I gave using an interface called eth1 and a 10.10.10 network this is clearly shown.

The step and direction pins can be worked out by following the code for esp32.

The step/pulse pins are seen in the rmt initialisation section.

The direction pins are later in the code, which isn’t exactly correct for multiple axis.

To progress Further:
  1. Do some research regarding basic Linux networking and learn to set a static address
  2. Ensure the ESP32 and Linuxcnc donot have the same IP Address
  3. Connect the ESP32 & Computer via a cat5 cable only, do not connect via a switc\router
  4. Uncomment the 7 lines in you HAL file you commented out, by doing so you have done the following:
    • Stopped Linuxcnc from updating the comp with new values
    • Removed the end point for Linuxcnc to send the commanded positions to
    • Removed the ability for linuxcnc to know how many steps the ESP32 has issued ie feedback
    • In effect removed all functionality of the comp
    • The "motion-control" stanzas will need to added back in

I was able to use the supplied HAL & INI files as presented without any modifications.
One question, not that it is an issue, why did you change the Port Number ?
Last edit: 29 May 2021 20:25 by BeagleBrainz.

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

More
30 May 2021 05:09 #210656 by tjtr33
Thanks
1) will do

2) They do not in mosts tests, I made same after dys of failures
and made them different again after that failed

3) WOW _no where_ was it said or illustrated to connect the cat 5 to the computer and the w5500, _no where_, and to me it seemed thge UDP message would travel around the LAN looking for the delivery address. silly me, see point 1 i suppose

I did say that I only have 1 ethernet port on my computer,
so will get another soon.
That explains my confusion when you talked about ETH1, and you disbelief becasue it was so simple.

It was just __>>unsaid.<<___.

5) the convention for UDP is to use 27181
DLHENKE used 5000, i will make sure all code uses 27181

Thanks, This explains the result see.
Thanks for reading it all and tipping me off to the topology.

I am off to find a pci ethernet board that is compatible with my needs.

TomP

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

More
30 May 2021 05:34 - 30 May 2021 05:55 #210658 by BeagleBrainz
With UDP or even TCP/IP there is convention with port numbers.

Even tho http uses port 80, if both the server and client agree to use 5666 there is no issue.

I think just for the sake of keeping everything easy to begin with keeping the developers choice of 5000 should be kept.

If you do install a 2nd NIC do not give it an IP address on the same network as your primary one.

Eg
If eth0 is 192.168.1 ( remember the first 3 numbers are the network and the 4 is the host)
Put eth1 on a different network. 192.168.2 will be fine, but your ESP32 should be on this one as well.

Now remember to record the MAC of your original NIC as the kernel may decide that your add in NIC is eth0. The MAC is unique to the physical card, no 2 cards ever made should have the same MAC.

Oh yes to complicate matters, the MAC you give your ESP32 should not be the same as any other on your network.

Yes it may seem confusing, but a bit of further reading will make sense of it all.

Maybe this analogy may help.

The MAC is equivalent to your vehicle's chassis number or VIN, this comes from the manufacturer. And is unique to all NICs produced.

The name eg eth0 is equivalent to your rego plate number, given out by the Motor Registry (the kernel). When you turn the computer off it is like deregistering your vehicle and handing the rego plate back. Turning it back on is similar to re-registering your vehicle and getting the plate back. Luckily with your computer it keeps the same name (rego plate), unless a new card is put in and get to the counter before the original one.

The IP address (network part & host part) is what your refer to the car yourself. Dad's car, mum's car etc.

The network part & host part don't have an equivalence in the above. Unless Dad has a blue & a red car, then Dad could be the network part and the colour could be the host part. eg Dad's red car, Dad's blue car. Then if Mum also had a red & blue car they would be Mum's blue car & Mum's red car. But each red car would be a separate car as each blue car is.
Last edit: 30 May 2021 05:55 by BeagleBrainz.

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

More
30 May 2021 13:03 #210671 by tjtr33
I will order pci nic online, not available here in stores.

Do you get "Unexpected RealTime Delay" on startup of linuxcnc?
(using dlhenke's ini and hal )

Thanks Tomp

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

More
30 May 2021 13:59 #210676 by BeagleBrainz
No.

Does your machine pass the latency test ?

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

More
30 May 2021 16:49 - 31 May 2021 01:15 #210692 by tjtr33
yes
latency-histogram tests were done --base 40000 --servo 1000000
with 4 glxgears
booted on dual core pentium with isolcpus=1 idle=poll
ran overnight
i'd have to dig up the screen shots
or just wait till next morning here
i'll run another now

i can run other configs ( parport and mesa 5i10 w/o errs )

thx tomp
Attachments:
Last edit: 31 May 2021 01:15 by tjtr33. Reason: added screenshot

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

Time to create page: 0.194 seconds
Powered by Kunena Forum