Hello Guest it is March 28, 2024, 08:07:19 PM

Author Topic: Anyone using an Arduino to receive up to 32 inputs?  (Read 1353 times)

0 Members and 1 Guest are viewing this topic.

Anyone using an Arduino to receive up to 32 inputs?
« on: January 25, 2020, 04:26:42 AM »
1. An arduino Mega takes care of all other inputs than the ones (4 only) you absolutely need to use to run Mach3 (if you are using the parallel port)
2. The arduino sends a 32-bits binary stream of the inputs status , and sends also an output when Mach3 needs to look at this stream
3. The MacroPump macro, which runs continuously, checks the input which says 'Hi, there has been a change on your inputs'
4. If no change, the Macropump macro does nothing.
5. If change, the Macropump reads the stream, runs through the actual status of every input, and changes them accordingly.

This does affect the speed of Mach3, and slows it down & few millisecs.

Anyone?

Offline Tweakie.CNC

*
  • *
  •  9,196 9,196
  • Super Kitty
    • View Profile
Re: Anyone using an Arduino to receive up to 32 inputs?
« Reply #1 on: January 25, 2020, 04:51:23 AM »
Sounds very interesting.

Tweakie.
PEACE
Re: Anyone using an Arduino to receive up to 32 inputs?
« Reply #2 on: January 25, 2020, 06:17:47 AM »
Yes, also possible with the USB controller, or what ever other controller you use. You only need to have a Com port. Most computers still have them, if not brought to the outside, it's on the main board. If not, then use a usb2serial adapter. Serial is available on every Arduino, the cheapest one being the Arduino Nano which supports 14 digital I/O's and costs a few bucks.

Anyone already done that? If so, please share, if not, I will make it and share it, if anyone is interested.

Offline TPS

*
  •  2,501 2,501
    • View Profile
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Anyone using an Arduino to receive up to 32 inputs?
« Reply #4 on: January 30, 2020, 02:44:03 PM »
Great, this closes the topic. It has already been done. Thanks!
Re: Anyone using an Arduino to receive up to 32 inputs?
« Reply #5 on: January 31, 2020, 08:31:19 AM »
Most simple way would probably be to use Serial.print in the Arduino. Use it to send all the states of the inputs. Then connect the USB of the Arduino to the Mach4 Computer and create a lua script that does read from the COM port. Here is an example of reading data from the Arduino using c++ and Windows API:

https://playground.arduino.cc/Interfacing/CPPWindows/

You would just have to port it to lua. Just import the necessary API functions like here, parse it and use mcSignalSetState() to assign the states to the user signals of Mach4.

I wish one could add I/O Devices too, so they would appear in the Configure > Controls > Input/Putput Signals Tabs as Devices. Allowing you to assign the pins of the arduino to the various inputs/outputs in these tabs. But this is not possible as Mach4 only allows to do that via plugins. Only OEMs can have access to the Plugins and Devices API of Mach4.
« Last Edit: January 31, 2020, 08:34:45 AM by brandonb »