1
Modbus / Re: Modbus and Arduino Question
« on: October 16, 2016, 11:00:14 AM »
Thank you!
Erik
Erik
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.
// This is for a CNC Pendant to interact with my heavily modified 1000mm x 1000mm Inventables X-Carve using Mach 3 to control the machine.
// I am using the Arduino Due for the brains of the pendant. All Communication with Mach3 is accomplished
// through the serial protocol modbus. In Mach3 I have set up brains to handle the input and output to
// the arduino. One brain to handle output to the Pendant and two to handle button presses. I have also configured
// several OEMtriggers to handle the execution of macros in the M1000.m1s file. The macro can execute the Probe Zero
// Z Axis, probe Zero All Axes, Got to Zero on X, Y, Z or A axis as well as user defined macros.
//
// I have the following hardware attached to the Arduino Due:
// 5" GLCD display and LCD Shield with a 800 x 480 resolution from SainSmart (using the UTFT libraries)
// 16 button keypad attched as an analog keypad using only 1 analog pin on the Arduino as well as ground and 5v.
// 2 joysticks, each attached to 2 analog pins and 1 digital pin for the center button.
//
// Current keypad button functions are defined as:
//
// 1: Reset 2: Cycle Start 3: Cycle Pause 4: Cycle Stop
// 5: Home All 6: Rewind Program 7: Edit G-Code 8: Close G-Code
// 9: Probe Z Axis 10: Spindle On/Off 11: Jog On/Off 12: Toolpath On/Off
// 13: Select X Axis 14: Select Y Axis 15: Select Z Axis 16: Select A Axis
//
//
// Here is a list of all the send and receive bits and what they are set for. These are set within the Mach3
// brain files.
//
// bitSet(rcd[0],0) RefAll bitSet(rcd[1],0) Cycle Start bitSet(rcd[2],0) Jog Increment Cycle
// bitSet(rcd[0],1) Rewind File bitSet(rcd[1],1) Cycle Stop bitSet(rcd[2],1) Jog STEP
// bitSet(rcd[0],2) Edit File bitSet(rcd[1],2) Reset bitSet(rcd[2],2) Jog CONT
// bitSet(rcd[0],3) Jog X-Positive bitSet(rcd[1],3) Zero All bitSet(rcd[2],3) Probe Zero Z (OEMtrigger1)
// bitSet(rcd[0],4) Jog X-Negative bitSet(rcd[1],4) Zero X bitSet(rcd[2],4) Goto X Zero (OEMtrigger2)
// bitSet(rcd[0],5) Jog Y-Positive bitSet(rcd[1],5) Zero Y bitSet(rcd[2],5) Goto Y Zero (OEMtrigger3)
// bitSet(rcd[0],6) Jog Y-Negative bitSet(rcd[1],6) Zero Z bitSet(rcd[2],6) Goto Z Zero (OEMtrigger4)
// bitSet(rcd[0],7) Jog Z-Positive bitSet(rcd[1],7) Zero A bitSet(rcd[2],7) Goto A Zero (OEMtrigger5)
// bitSet(rcd[0],8) Jog Z-Negative bitSet(rcd[1],8) Jog Z-Right/Off bitSet(rcd[2],8) Zero X Axis
// bitSet(rcd[0],9) Jog A-Positive bitSet(rcd[1],9) Jog Z-Left/Off bitSet(rcd[2],9) Zero y Axis
// bitSet(rcd[0],10) Jog A-Negative bitSet(rcd[1],10) Jog A-Right/Off bitSet(rcd[2],10) Zero Z Axis
// bitSet(rcd[0],11) Jog Y-Right/Off bitSet(rcd[1],11) Jog A-Left/Off bitSet(rcd[2],11) Zero A Axis
// bitSet(rcd[0],12) Jog Y-Left/Off bitSet(rcd[1],12) Feedhold bitSet(rcd[2],12)
// bitSet(rcd[0],13) Jog X-Right/Off bitSet(rcd[1],13) Jog Off/On bitSet(rcd[2],13)
// bitSet(rcd[0],14) Jog X-Left/Off bitSet(rcd[1],14) Toolpath On/Off bitSet(rcd[2],14)
// bitSet(rcd[0],15) Close File bitSet(rcd[1],15) Spindle On/Off bitSet(rcd[2],15)
//
// bits rcd[3-12], 0-15 are currently unused...there are a ton of unused bits still available.
//
// Variables received from Mach3:
//
// mcd[0] + mcd[1] X-Axis location - receiving one side of the decimal point in each data element. Each one is
// mcd[2] + mcd[3] Y-Axis location converted to a signed float and displayed on the GLCD
// mcd[4] + mcd[5] Z-Axis location
// mcd[6] + mcd[7] A-Axis location
// mcd[8] + mcd[9] Jog Increment
// mcd[10],0 Reset Status - A simple toggle bit
// mcd[10],1 Jog Mode - A simple toggle bit
// mcd[10],2-15 are currently unused
// mcd[11] Feedrate Overide - An integer
// mcd[12] Feedrate - An integer
//
// Currently there are 13 x 16 bit data elements to send and receive from Mach 3. I am using all of the data
// elements received from Mach 3 to update the DROs and Reset, Jog, Feedrate Overide and Feedrate. If I want to
// receive more information I will need to add more data elements. to add Spindle Speed, I will need one more data
// element as it will simply be an integer.