Arduino IO Expansion

More
10 Jan 2025 02:33 #318602 by blazini36
Replied by blazini36 on topic Arduino IO Expansion
So an interesting thing happened last night......

I was watching something on Youtube and someone mentioned ChatGPT, which reminded me how I joke with a friend that his code sometimes looks like ChatGPT wrote it.

So then It dawned on me that I should peg ChatGPT about adding the I2C IO to Arduino Connector. I'd never used ChatGPT before but I figured why not......

A couple hours later I have  the MCP23017s all working as inputs/outputs within Arduino Connector......

I was pretty blown away by how that turned out.
The following user(s) said Thank You: tommylight, besriworld, AlexMagToast

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

  • AlexMagToast
  • AlexMagToast's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
17 Jan 2025 12:42 - 17 Jan 2025 12:44 #319177 by AlexMagToast
Replied by AlexMagToast on topic Arduino IO Expansion
Hello my guys, I am very surprised of how much conversation I have missed, somehow I was not notified of new posts in this thread.
@cornholio and @blazini36 honestly between your "discussion" I was not able to understand what exactly you suggest.
I have been in several discussions in the direction "USB -> bad :( " where we explored other connection possibilitys, for example Ethernet TCP and UDP connections.

Personally I feel like USB offers a good ratio between ease of use and speed good enough.
However I do see the benefit of offering a faster Option for those that need it. But at the end we have to see that Arduino-connector offers a cheap alternative to Mesa Cards, but it will always have its limits and at some point the user should consider just using a Mesa card instead.
As I am not a very experienced Programmer I am always very happy for advice, so please continue to share your knowledge.

Currently I am reworking the Codebase to implement 2 basic but drastic changes.
1. The Configuration will change to a single YAML Config file, inspired by Klipper and ESPHome. This will allow to copy/ paste Feature specific configs more easily. Also a lot of Emails I get are related to little configuration mistakes. I hope this change will help people get it right more easily. 

2. The old Serial connection sends Pin states encoded in a string. The new version will send everything directly in a bitstream, so for example 8 Input Pins can be transferred in a single byte. The cost of that change is that the user looses the possibility to communicate with the Arduino manually for testing. I expect the communcation to speed up quite a bit from this change - pun intended.

Additionally I have collected a lot of feature requests to support more Hardware and offer more logic for existing features, which if i find the time i am willing to implement in the future.
Hopefully I will be notified again in the future so I can answer more quickly in this thread.

Cheers from Germany!
Alex
Last edit: 17 Jan 2025 12:44 by AlexMagToast.
The following user(s) said Thank You: besriworld

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

  • Cant do this anymore bye all
  • Cant do this anymore bye all's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
More
17 Jan 2025 15:12 #319184 by Cant do this anymore bye all
Replied by Cant do this anymore bye all on topic Arduino IO Expansion
I wouldn’t be of the opinion USB = bad. I think it can be let down at the physical layer by less than great cables.
Whilst not the greatest fan of Arduino, it does allow for projects like yours and sharing is quite easy. Developers such as yourself should be thanked, as there is a lot of behind the scenes frustrations, hopefully you didn’t pull too much hair out. Keep up the great work.

Just another thought, Ethernet would add a bit of extra cost, and could mean a 2nd Ethernet card for the pc and such. And complexity for some setting it up. USB\Serial keeps it easy.

All the best from Down Under
Rob

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

More
17 Jan 2025 19:00 #319208 by blazini36
Replied by blazini36 on topic Arduino IO Expansion
An Arduino is just a board with a microcontroller on it, there's nothing wrong with the Arduino itself. Plus the fact that you can get into much faster microcontrollers with the same Arduino framework makes it alot easier to deal with.

The problem with USB isn't the speed, it's the fact that it has to run in userspace. A USB serial port isn't using a fraction of the speed of USB anyway and the 10/100 ethernet that Mesa uses isn't exactly fast either. USB is always mentioned with this but realistically it could be any serial port. That's where the more productive part of the conversation was going, the fact that a serial port technically can be made to run on the real-time layer. Nobody has ever bothered to make the LinuxCNC component for real-time serial which baffles me since LinuxCNC loves legacy interfaces.

The PC side of this is written in Python anyway, it can't even be real-time from that angle. It'd have to be reworked into a C component. Alex mentioned the Mesa card but a Mesa card for something like this wouldn't be doing anything special that an Arduino can't. The only draw for the Mesa card is the fact that it has a ready to go real-time environment already setup. The Mesa cards intended for use with a control panel aren't even FPGA cards, I believe they run a PIC MCU so hardware wise they aren't really special other than just being well designed.

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

  • Cant do this anymore bye all
  • Cant do this anymore bye all's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
More
17 Jan 2025 22:11 #319223 by Cant do this anymore bye all
Replied by Cant do this anymore bye all on topic Arduino IO Expansion
Well said. Especially like the comment about python.

Just a note, the 7i90, FPGA (not having a go but there is always some that breaks the rules) can be used as smart serial device. Just digital i/o and 3 mpgs, but the firmware that runs on the softcore can be modded for 4
Mpgs. Tho it was a little frustrating to do at first.

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

  • AlexMagToast
  • AlexMagToast's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
17 Jan 2025 22:47 #319227 by AlexMagToast
Replied by AlexMagToast on topic Arduino IO Expansion
Good that you mention Python. A couple weeks ago I learned how to build custom .comp components and I was thinking about moving the communication and logic Part into one.
But I am not sure how much this would improve anything. I guess the Bottleneck is the USB Serial anyway? What do you guys think?

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

More
18 Jan 2025 01:48 #319242 by blazini36
Replied by blazini36 on topic Arduino IO Expansion

Good that you mention Python. A couple weeks ago I learned how to build custom .comp components and I was thinking about moving the communication and logic Part into one.
But I am not sure how much this would improve anything. I guess the Bottleneck is the USB Serial anyway? What do you guys think?
 

Yeah, problem there is you can only access a serial port from userspace otherwise it would be good. USB you would probably have to throw out the window, but if someone wrote an actual real-time serial port driver it'd probably be great.

I'll probably fork your repo and push my changes for the I2C IO expanders if you want to take a look at that. Could use some work around the ifdef's for enabling the I2C IO aside from the normal Arduino IO but on my Mega setup it's working great.

Unfortunately I didn't have enough interrupt pins when I made that board and I figured they probably wouldn't be necessary for just knob type encoders but that was a mistake. My MPG uses both interrupts and it works fine, my other encoders work terrible. Now I'm trying to resurrect the board I made for a Teensy 4.1 since they are all interrupt pins. Having a bit of trouble with the I2C on that one for some reason.

Just a note, the 7i90, FPGA (not having a go but there is always some that breaks the rules) can be used as smart serial device. Just digital i/o and 3 mpgs, but the firmware that runs on the softcore can be modded for 4
Mpgs. Tho it was a little frustrating to do at first. 

Yeah, you could use those cards for whatever you want but there's no analog IO on the 7i90/7i92 so you can't really call it a control panel card unless it can do a basic potentiometer reading.

I don't have any pots so I was thinking about using a 7i92 I have laying around. The smart serial cards don't work out well for my case cuz they run off the host card. So I'd be mounting PC inside the control panel  and the ethernet host card in the machine cabinet. So ethernet from the control panel to the machine cabinet and smart serial back to the control panel. That's kind of messy and the control panel can't work standalone.

With a 7i92 I'll just tie up the 2nd ethernet port on my mini-pc, but that's probably not a big deal. I've already used modified 7i92's on custom daughtercards so I already have the PCB footprints and schematic symbols made.....

 

Problem there is there's no I2C module for hm2 that I'm aware of so I'd have to remake my key panel again to use spi IO expanders then BSPI is a bit tough to deal with. I got BSPI almost working for the board in the pic because it has 2 small microcontrollers that communicate with the 7i92, one is actually just for reading analog inputs. I got busy and left that project on the shelf too.

I'll probably just stick with the Arduino-connector setup once I get my Teensy 4.1 version working right for now. The mini-PCs I use have the Intel UARTs so if there's ever a real-time serial port solution I can just migrate over to that.
Attachments:
The following user(s) said Thank You: besriworld

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

  • Cant do this anymore bye all
  • Cant do this anymore bye all's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
More
18 Jan 2025 09:28 #319261 by Cant do this anymore bye all
Replied by Cant do this anymore bye all on topic Arduino IO Expansion
Nice setup old chap, puts my merger efforts at PCB design to shame.

I remember there was a thread about the BSPI thing, tried searching but couldn't find it.

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

  • AlexMagToast
  • AlexMagToast's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
18 Jan 2025 20:55 #319314 by AlexMagToast
Replied by AlexMagToast on topic Arduino IO Expansion

I'll probably fork your repo and push my changes for the I2C IO expanders if you want to take a look at that. Could use some work around the ifdef's for enabling the I2C IO aside from the normal Arduino IO but on my Mega setup it's working great.

I like the I2C IO expansion Idea. I don't have these chips here yet. As I am working on the next Version of Arduino Connector I would implement it in the newer version as it will improve on all the Issues learned from the current version, as it will also get rid of the #defines etc for the user.
Also I forgot to mention that the new Version already supports the connection to multiple Arduinos simultaneously.

If you would like to peek into it you can see it on Github in the dev branch, but keep in mind currently it doesn't work.
Here is a preview of how the new Yaml configuration looks like: github.com/AlexmagToast/LinuxCNC_Arduino...lob/dev/config2.yaml

 

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

More
19 Jan 2025 06:17 #319347 by blazini36
Replied by blazini36 on topic Arduino IO Expansion

I like the I2C IO expansion Idea. I don't have these chips here yet. As I am working on the next Version of Arduino Connector I would implement it in the newer version as it will improve on all the Issues learned from the current version, as it will also get rid of the #defines etc for the user.
Also I forgot to mention that the new Version already supports the connection to multiple Arduinos simultaneously.

If you would like to peek into it you can see it on Github in the dev branch, but keep in mind currently it doesn't work.
Here is a preview of how the new Yaml configuration looks like: github.com/AlexmagToast/LinuxCNC_Arduino...lob/dev/config2.yaml


 

Yeah I've seen the v2 but never tried it because it's mentioned in the repo that it doesn't currently work.

I got my Teensy 4.1 break out board working and that handles the encoders much better than the Arduino Mega. The Teensy doesn't have that many IO pins so I have an I2C expander right on the break out board in addition to the 4 expanders on the keypad, I've got that working too.

I'm using MCP23017 expanders on these but I've used PCF857x on other boards, they aren't pin compatible but the libraries are similar.

Right now I'm just looking at how Arduino-connector handles connection states. It seems that even the normal outputs don't reset when LinuxCNC is closed so things that were previously on (like LEDs) stay on. The same happens with the I2C outputs so I suppose it's expected.  Not sure if that's the intended behavior but I've trying to figure out how to reset all outputs (pull low) on disconnect. It's a bit hard to debug since there's only 1 serial connection referenced and it's taken over when LinuxCNC connects, but I have another serial port I can direct debug prints to.

Other than that it all seems to work pretty good, I found a blocking delay in the comalive function that was creating a bit of delay. I replaced that with a timer and it works much better. That plus the tweaks mentioned in the git issues, it's pretty responsive now.

Once I get done putzing around, I'll clean up my code a bit and upload it somewhere.

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

Time to create page: 0.125 seconds
Powered by Kunena Forum