Hello Guest it is September 23, 2023, 08:12:48 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - mrprecise44

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 »
Modbus / Re: Arduino Modbus, Complete, Documented and free
« on: February 27, 2013, 02:32:02 PM »
Hi Wayne:

The ModBus program that runs on an Arduino does not utilize Ports and Pins in Mach3. It is a totally separate operation.

1. The ModBus program uses registers, beginning with 0 up to I believe 48.
2. These registers are scanned by the Serial ModBus Configuration in Mach3.
3. You verify the register is being read by the "Test" window in the Serial ModBud Config page;
4. When the action is working i.e., seeing the pot value change, or a button push change from a 0 to a 1,
5. You can then write a "Brain" which reads the register, which activates a Mach3 OEM code, i.e. Cycle Start, FeedHold etc.

Zafar posted a PDF file, showing how to setup (2) potentiometers for Feedrate ovr., and Spindle %.

The ModBus program uses the Arduino language format to set pins as input, output, or analog read/write, in void(setup).

Each Arduino pin has a corresponding ModBus "register", in the void(loop).

You need to use the Arduino format to setup the ModBus program. Log onto the Arduino site, and study the examples.

On the Arduino board, pins 0 and 1 are Serial Rx, and Tx. Pins 2 through 12 are digital I/O, and pins A0 through A5 are analog I/O.
The Mega has (4) Serial ports, 15 analog pins, and 42 digital I/O.

Modbus / Re: Arduino Modbus, Complete, Documented and free
« on: February 27, 2013, 12:26:07 AM »
Hello Wayne:

Zafar's post regarding the ModBus program for Arduino is:


He also wrote a PDF cookbook showing how to set up two analog inputs.

Personally, I really like the Cubloc stuff. I have a Cubloc board on one of my 4-Axis milling machines. They have a very good range of ModBus capable boards, and the Cubloc Studio program makes it even better. Ladder logic, plus CuBasic is pretty powerful. Cuboc makes their many peripherals virtually "plug and play" with all the various types of I/O. Plus, the manual is very detailed, with lots of examples. Perhaps the real plus for Cubloc is 24v, which is the commercial standard for noise immunity. On the con side, the Cubloc needs 2 connections to the computer, and you are dealing with more than one voltage. The other problem is using their tiny connectors. It took me quite a bit of time getting the crimp tool to make up a good connector. I must have made 30 bad ones before I got one right.

However, the Arduino platform is a low cost alternative, and can do much of the typical I/O, like LED's, pushbutton activation of functions, and Feed rate, Spindle % override; an excellent addition to the Parallel port driven Mach3 setup.

Modbus / Re: Arduino Modbus, Complete, Documented and free
« on: February 26, 2013, 03:16:25 PM »
I got it working on I/O D2 thru D12, and analog 0 >5, but found it too cryptic, and it doesn't use the typical Arduino modified C language. Also, the author never responded to questions. There are some who managed better than I did, and those various posts are here in the Modbus section.

The Modbus program posted by Zafar Salam in another Modbus post, works with no problems and will allow all the pins on the Mega to function. This version was created by an Arduino programming whiz, JP Mozeta,  and is also found on the SourceForge website. Also, there is some  discussion how to get an MPG working properly.

The Arduino Mega is an excellent platform for Modbus and the Mach3, due to it's wealth of code on the Arduino site, and the huge number of I/O, including (4)serial ports, and of course low cost when compared to the commecial PLC's.

Modbus / Re: Mach3, Arduino, Modbus and MPG
« on: February 10, 2013, 02:25:19 PM »
Hello Zafar:

I have not yet done anything with the LCD/serial display output on the Mega, connected with Mach3.

That is next; however have done a lot of Arduino stuff, using the LCD. One project was a Marine Autopilot, displaying compass bearings with a Compass module, and also putting out GPS coordinates, by parsing the Mag compass outputs, and the GPS output stream. That project used a serial backpack module with a 20X4 LCD, combined with a power converter board from Polulu, which can take a pin signal, and drive a 300+ watt DC motor, which in turn moved the ships wheel with hydraulic steering. Worked just like the commercial units.

Want display the jog status, current step value, jog %  setting, etc., since these are not so easily seen on the Mach screen.

Just takes time to sit down and work with it. Of course, there are bits and pieces scattered about on the Forum how to do lots of obscure tricks.


Modbus / Re: Mach3, Arduino, Modbus and MPG
« on: February 09, 2013, 02:21:49 PM »
Hello Zafar:

I have not yet connected an MPG through the ModBus, but have all the I/O pins on the Arduino Mega, pin #2 through #53 digital, and all of the Analog inputs tested, working just fine.

However, as I understand the ModBus functionality in Mach3, in the Serial ModBus Setup screen, there is a column for the millisecond pause for each Cfg.#, and that is a time period the scan will pause at each register waiting for an input. and another millisecond time in the upper right corner, for the "timeout" period. This seems to me, that there cannot be instantaneous response to an input in ModBus, due to the accumulated milliseconds during a scan. The Cfg# time period can be as small as 25 or 50, but it still adds up to some given period of time. I believe this is the cause of the delay in MPG response you mention.

Since the Arduino Mega has so many I/O pins, but the common parallel port has limited inputs, I think the MPG should be wired directly to the Breakout board. The BB itself can be 12 outputs, and 5 inputs, or vice versa. There are only a few kinds of inputs that need to be instant, i.e., the probe signal, the MPG, and perhaps an optical home switch, and an optical sensor spindle index.

On one of my Cubloc plc, there are the standard I/O, and then there are a couple of "High Speed" I/O pins, which are for an MPG.

I am not claiming to be a ModBus expert, and might have some some points wrong, but this seems a reasonable understanding. There is not a lot of info in the inner workings of the Serial ModBus Setup. Also the baud rate might have a different effect, say from 9600 bps, to higher settings. ModBus works perfectly fine for I/O that are not super time critical, like limit switches, spindle on/off
LED's, FRO, etc.


You want your limit switches to be fast as well.

Edited...... Brett

FAQs / Re: a FAQ that doesnt seem to have been asked...
« on: January 29, 2013, 11:49:03 PM »
I understand you question to mean you would like a small PC to play with Mach3, and some programming software like CamBam, and  such.

I just did a search for Tablet PC's, and Best Buy has a bunch of 10.1", touch screen tablets running Win 7, and Win8. Considering the huge market evolving with all the Android tablets, the PC tablets are slightly more $$.  

Best Buy has one however, that sells for $413.00, and is a real PC, not an Android oversized phone. I am sure that these size devices have optional keyboards for number and letter entry. Sounds like a pretty cool little computer.

Here is the specs from their website.

Dell Latitude 10.1" Net-tablet PC - Wi-Fi - Intel Atom Z670 1.50 GHz - LED Backlight - Multi-touch Screen 1280 x 800 WXGA Display - 2 GB RAM - 32 GB SSD - Intel Graphics Media Accelerator 600 Graphics - Bluetooth - Genuine Windows 7 Professional (English) - HDMI


Processor Manufacturer: Intel
Processor Type: Atom
Processor Model: Z670
Processor Speed: 1.50 GHz
Processor Core: Single-core (1 Core)
vPro Technology: No
Cache: 512 KB
Standard Memory: 2 GB
Maximum Memory: 2 GB
Memory Technology: DDR2 SDRAM
Memory Standard: DDR2-800/PC2-6400
Memory Card Reader: Yes
Solid State Drive Capacity: 32 GB
Optical Drive Type: No
Screen Size: 10.1"
Screen Mode: WXGA
Display Screen Type: Active Matrix TFT Color LCD
Aspect Ratio: 16:10
Screen Resolution: 1280 x 800
Backlight Technology: LED
Touchscreen: Yes
Multi-touch Screen: Yes
Graphics Controller Manufacturer: Intel
Graphics Controller Model: Graphics Media Accelerator 600
Graphics Memory Accessibility: Shared
Wi-Fi: Yes
Wi-Fi Standard: IEEE 802.11a/b/g/n
Bluetooth: Yes
Bluetooth Standard: Bluetooth 4.0
Front Camera/Webcam: Yes
Finger Print Reader: No
Operating System Platform: Windows
Operating System: Genuine Windows 7 Professional (English)
Operating System Architecture: 32-bit
Number of Cells: 4-cell
Form Factor: Slate
Height: 0.6"
Width: 10.6"
Depth: 7.3"
Weight (Approximate): 1.80 lb
Limited Warranty: 3 Year

Add me to the list. ++++
Thank you Klaus for all you have contributed to the Mach3 community.
I just recently did a tweak on the 2010 screen by Ger, adding a little color on the G-code screen, so I could see where the
current line was, in contrast to the background.

Your screen program is indiscernible from "Magic."



General Mach Discussion / Re: Getting started near Huntington WV
« on: January 27, 2013, 06:18:44 PM »
Hi Archie:

Pretty impressive collection. You have enough stuff to keep a guy busy for years. I am in southern California, and the low 50"s seems pretty cold to me, but 19 sounds more like living in the Antarctic with the penguins!

I have been doing 4-axis CNC since the early 1980's, and would be glad to offer any info down the line. There is a lot of amazing stuff available for making those machines do "magic tricks."
My current attitude is, "simple is better."
We are on sort of the same track, as I have posted over my desk a note for my next CNC project for my Micro-Mill;
NewEgg - 189.00
Shuttle XS35V3 Intel Atom D2700
.... and all the pertinent specs
Size- 9.9" X 6.38" X 1.5"
And, on my wish list is a Touch screen to mount the Shuttle on the back side.
Just takes money. ;)

Favorite CAD/CAM software:
DraftSight, free from SolidWorks parent Company, Dassault Systemes, France. Simply superb!
CamBam; continuously being upgraded by the writer, Andy, and a great forum of users.
CutViewer Mill; watch my programs with a virtual cutter chewing away through a virtual material, showing the whole shebang, even crashes in 3-D.



Modbus / Re: Help Arduino Modbus RTU
« on: January 27, 2013, 05:42:02 PM »
Much of the modbus code writing is not "intuitive". It takes some time to get it all correct. For instance, in this modbus program, the entries into the Serial Modbus screen, under the "Function Cfg's" , the type of input in the right side column labeled, Direction, must be "Input-Holding."

I tried using the "Input-reg", which works with my CubLoc PLC, and it was a no-go.

I will try to put together a step by step on the strange way (strange to me anyhow) the brains have to be written. You should use the test box in the Serial Modbus screen to make sure your pushbuttons, and/or analog potentiometers are working before trying to get a brain to communicate with Mach3. For pushbuttons, you will see a list of zeros, one for each input, change from a zero to a (1) as you click on the "read" button, as you push the buttons on your panel, or proto board. With the analog inputs, you will see the numbers change from 0 to 1023 as you turn the pot, and click on the read button.

If it works correctly, you know the register# under the "address" column heading is correct, and the communication is working.

The modbus program for Arduino does work well, and with the Arduino Mega, you have a really large number of I/O possible, including using the serial I/O for an LCD, and the PWM for spindle control. It is a very powerful program, however it takes time to get all the bits correct.

The parts of my coding I posted all work correctly. There should be enough of the code to get a picture of how to write your own variety of this modbus program. The potential for 40 individual I/O's, analog, digital, PWM, Serial,  is certainly not a trivial program to add to the Mach3 control.

I am not an Arduino guru programmer, and do not claim to fully understand how this modbus program works; however, it is a masterpiece of software engineering, and does allow the Arduino standard code, which is fairly straight forward, and simple to understand to work within the main program.

This code, generously placed in the public domain can do more than many commercial PLC's costing hundreds of dollars.


Modbus / Re: Help Arduino Modbus RTU
« on: January 27, 2013, 05:48:18 AM »
Hello dotn:

I have a short tutorial to help you get started. It would be helpful to print it out as a reference as
you start writing the code into the framework of the modbus program from Zafar. It ends up getting
fairly long. You might just start with making a "Cycle Start" button, and then add more stuff after you
get that part working.

If you have a working knowledge of Arduino I/O codeing, this is the standard Arduino
sketch code sections of: declaration, setup, and "void" loop sections of the modbus program.


This part is the declaration of pins and variables. After the beginning where the code
has: int t1,t2,t3; (this is the same as A0, A1, A2 for the analog pins.

plus the declaration for input pins;

int inPin2 = 2; //This is digital pin D2
int inPin3 = 3; // this is digital pin D3  etc.
int inPin4 = 4; // ........

The Mega has lots of pins. You can do this up to inPin 25 or 30 if you want.
Save some pins for Outputs in the declaration;

int outPin1 = 13; // D13, this is the built in led pin. You can make it blink on as an output.
int outPin2 = 25; // D25, this is Mega digital pin 25
int outPin3 = 26; // D26
int outPin4 = 27; .....etc.

int buttonState1 = 0;  // you will need the declaration of "buttonState" for reading the input state of pins in the "void" section.
int buttonState2 = 0;
int buttonState3 = 0;


Then in the next area : (this is copied directly from the program to show location)

/* Modbus RTU common parameters, the Master MUST use the same parameters */
enum {
  MB_SLAVE = 1,   /* modbus slave id */
/* slave registers example */
enum {   
  MB_REG0,  // analog pin 0
  MB_REG1,  // analog pin 1
  MB_REG2,  // analog pin 2
  MB_REG3,  // digital pin 2
  MB_REG4,  // digital pin 3
  MB_REG5,  // digital pin 4 

These are the modbus registers listed by number. The program allows up to 40 registers.
You have to label the inputs (as above shown), and the outputs in the same list.
It is not necessary to  go all the way to 40 registers, but you can if needs be.
Every comma, underline, semi-colon is absolutely necessary. The program will not
compile is so much as one comma is out of place.

The double slash, // is to precede any comments you want to add for keeping track of what
the program lists are all about.

Now is the "setup" section of the program: The following lines are copied from the program to show
location, and some of my own code, i.e., Cycle Start.......

int regs[MB_REGS];    /* this is the slave's modbus data map */

void setup()

  pinMode(inPin2, INPUT);  // D2, Cycle Start  (connect your pushbutton to pin D2.)
  pinMode(inPin3, INPUT);  // D3, Feed Hold
  pinMode(inPin4, INPUT);  // D4, Stop
  pinMode(inPin5, INPUT);  // D5, Reset
  pinMode(inPin6, INPUT);  // D6, Spindle on/off

This is the standard Arduino sketch pinMode listing for INPUT and OUTPUT

  pinMode(outPin1, OUTPUT); // D13, Led pin 13 output
  pinMode(outPin2, OUTPUT); // D36,
  pinMode(outPin3, OUTPUT); // D37,
  pinMode(outPin4, OUTPUT); // D38,

This listing will include all the inputs and outputs you need.


Now comes the real deal. This is the "void" loop. All your program tasks happen here.

void loop()
  /* This is all for the Modbus slave */
  update_mb_slave(MB_SLAVE, regs, MB_REGS) ;

  // analog input pins ----------
  regs[0]=analogRead(A0);  // this is the area reading the analog inputs.
  // ----------------------------
  regs[3]=digitalRead(inPin2);  // this is the area reading the digital input pins.

Every digital input and output, and every analog input must have it's own register;  regs[16] etc.

Here is a short code to turn on a green LED in combination with the Cycle Start button, and turn off the yellow, and red
led's that match the Feedhold and Stop buttons.

This is at the end section of the "void" loop, and before the loop closing bracket.

// Read "Cycle Start" button; if activated, turn on green LED
  buttonState1 = digitalRead(inPin2);
  if(buttonState1 == HIGH) {
    digitalWrite(outPin2, HIGH);
    digitalWrite(outPin3, LOW);
    digitalWrite(outPin4, LOW);

As you can see, I connect a green led to "outPin2"
a yellow led to "outPin3"
and a red led to "outPin4"

You can write similar code yourself, to turn on/off various led's to match the
buttons pushed. 

All the stuff in the "void" loop must be inside of loop starting bracket....

void setup()

and the ending bracket in the program....



Now you need to write the brains to implement the input buttons. Zafar made sample brains for that already.

Do just a section at a time when you start writing it all in the program. Do a "compile" to find any mistakes before you have
too much code written down.


Have fun.


Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 »