Hello Guest it is December 06, 2019, 06:45:56 PM

Author Topic: How to Address Modbus Outputs if you have more than 20  (Read 14896 times)

0 Members and 1 Guest are viewing this topic.

Re: How to Address Modbus Outputs if you have more than 20
« Reply #10 on: May 01, 2014, 09:19:30 PM »
Thanks Scott! Didn't realize there were so many ways to do this. Much appreciated!

Sam

Offline LGF

*
  •  37 37
  • can't sit still
    • View Profile
Re: How to Address Modbus Outputs if you have more than 20
« Reply #11 on: August 31, 2014, 06:48:36 AM »
Stirling

I see you seem to have some experience with Modbus and arduino in Mach3 and since I am struggling to get any answers here on the forum I thought I'd ask you directly.

Using the Arduino mega 2560 I have serious amounts of pins that I can use, however I have an LCDKeypad shield that plugs onto the headers of the mega and virtually leaves me with the pin header containing 22-53 to use for my stepper drivers (step and dir)
The specs of the DIY cnc Mill I have built is somewhere here on the forum but I could post it here if it would have any bearing on the issue I am struggling with.

What I am struggling with is confirming if I define the motor outputs in the Mach config "ports and pins/motor outputs" to say X step = 22, X dir = 23, Y step = 24, Y dir= 25 etc etc would I be able to get the motors running. The Modbus I am using is the one on the forum by a guys called Schilling and defines registers as follow:


//############  REGISTER DEFINES ############# // Each Register is 16bit
#define Digital_IO_Register 0
#define PWM_Register        10
#define AN_Register         30
#define Timer_Register      50
#define IO_Config_Register  60
#define Kill_IO_Register    70
#define PWMIOMap_Register   80
#define ANIOMap_Register    81
#define General_Config      90
#define Error_Register      91
#define Digital_IO_Pins     64   //Total number of Digital IO pins, Limits update scanner pin count
#define Number_Of_Registers 100
//############ GLOBAL VARIABLES ##############
unsigned char Data[256];                                         // All received data ends up in here, also used as output buffer
unsigned short Index = 0;                                        // Current Location in Data
unsigned short Register[Number_Of_Registers];                    // Where all user data, Coils/Registers are kept
ModBusSlave ModBus(Slave_Address,Register,Number_Of_Registers);  // Initialize a new ModBus Slave, Again, you must have my Arduino ModBusSlave Library
unsigned long Last_Time=0;
unsigned long Time = 0;
unsigned long LongBreakTime;                                            //Time for 3.5 characters to be RX
//################## Setup ###################
// Takes:   Nothing
// Returns: Nothing
// Effect:  Opens Serial port 1 at defined Baudrate
//          Configures all Pins
//          Initiallized Timer 1
void setup()
{
  //################ Initialize IO #################     // 0 => Output, 1 => Input, opposite of normal Arduino, but my habit from other platforms, 0 looks like an O and 1 looks like an I
  Register[IO_Config_Register]    = 0b0000000000000000;  // UNO and MEGA  PIN 00-15
  Register[IO_Config_Register+1]  = 0b0000000000000000;  // MEGA          PIN 16-31
  Register[IO_Config_Register+2]  = 0b0000000000000000;  // MEGA          PIN 32-47
  Register[IO_Config_Register+3]  = 0b0000000000000000;  // MEGA          PIN 48-64
  Register[IO_Config_Register+4]  = 0b1111111111111111;  // AN Digital    PIN A0-A16

  //################ Kill IO Register #################  // 0 => Leave, 1 => Kill
  Register[Kill_IO_Register]    = 0b1111111111111111;    // UNO and MEGA  PIN 00-15
  Register[Kill_IO_Register+1]  = 0b1111111111111111;    // MEGA          PIN 16-31
  Register[Kill_IO_Register+2]  = 0b1111111111111111;    // MEGA          PIN 32-47
  Register[Kill_IO_Register+3]  = 0b1111111111111111;    // MEGA          PIN 48-64
  Register[Kill_IO_Register+4]  = 0b1111111111111111;    // AN Digital    PIN A0-A16

  //################ PWM IO Register #################   // 0 => Normal I/O, 1 => PWM I/O
  Register[PWMIOMap_Register]   = 0b0000111001101000;    // UNO and MEGA  PWM 01-16

  //################ AN IO Register #################    // 0 => Digital, 1=> Analog
  Register[ANIOMap_Register]    = 0b1111111111111111;    // UNO and MEGA

  Config_IO();


Thanx in advance for any help.
When I die, will someone please dress up as the Grim Reaper and attend my funeral. No need to do or say anything, just attend and stand a short distance away? PLEASE???

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: How to Address Modbus Outputs if you have more than 20
« Reply #12 on: September 02, 2014, 04:08:22 AM »
I think you misunderstand what Modbus is for. It is for non-time-critical I/O expansion - you can't drive axis motion via Modbus.

With Mach you either use the Parallel port driver OR you use an external motion controller.

Arduino can be used with Mach for all sorts of things - but NOT for driving the axis (unless I suppose you write your own plugin which is non-trivial. Even then I'd argue an 8 bit processor is a poor choice for motion control).

Offline LGF

*
  •  37 37
  • can't sit still
    • View Profile
Re: How to Address Modbus Outputs if you have more than 20
« Reply #13 on: September 02, 2014, 04:32:51 AM »
Thank you so much for the reply, really appreciate it. It's just that I thought I was lost the last week or so trying to figure out what to do, until now, now I know I cannot get any more lost than what I am now.

I have 4 Nema 2r 3NM steppers with Wantai DQ542MA stepper driverd, a manual switch controlled flood system and a manual controlled router I post full specs if required, but please then advise on the way forward?

I am getting two old LPT PC's today and hopefully I can make one working from the two, that said do I need to still have an external controller with the modbus on it or do I just use the Arduino Mega for something else?

Really lost now
When I die, will someone please dress up as the Grim Reaper and attend my funeral. No need to do or say anything, just attend and stand a short distance away? PLEASE???

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: How to Address Modbus Outputs if you have more than 20
« Reply #14 on: September 02, 2014, 06:10:39 AM »
First step, just get your axes moving: All you need is Mach3 on a 32 bit windoze PC -> parallel port -> (optional BOB) -> drivers -> motors (plus a power supply of course). See http://www.machsupport.com/help-learning manuals, videos etc.

(I've said BOB is optional but probably advisable unless you know exactly what you're doing).

Offline LGF

*
  •  37 37
  • can't sit still
    • View Profile
Re: How to Address Modbus Outputs if you have more than 20
« Reply #15 on: September 02, 2014, 06:34:56 AM »
Thanx, so which Break Out would be appropriate? Not too sure of my knowledge regarding the LPT capabilities with regards to pulsing the stepper drivers (they require 5v pulses)

Steppers draw around 4.2A

PS: downloaded and read through all the doc's, watched all the vids even the ones that is not on Artsoft, and perhaps thats what messed me up so much as I was looking for info regarding the setting up and config using the Arduino and Modbus.

PS2: Got the motors tested with Accelstepper (Arduino sketch that was uploaded and replaced with modbusslave) some time back and they were fucntioning, but will see if I can get them working without the slave just using LPT, this is however not my system preffered method as I would have loved to use a laptop for drafting, scanning and Mach operation all in one. With this I will have to do the drafting on the laptop or Macbook (perhaps the 3d scanning part too) then process them and physically transfer them to the desktop that will have the LPT port (that is if I am able to get one machine from the two, combining parts, working this afternoon.)
When I die, will someone please dress up as the Grim Reaper and attend my funeral. No need to do or say anything, just attend and stand a short distance away? PLEASE???

Offline LGF

*
  •  37 37
  • can't sit still
    • View Profile
Re: How to Address Modbus Outputs if you have more than 20
« Reply #16 on: September 02, 2014, 07:00:16 AM »
Stirling

The machine is built, wired and checked manually and electronically too all seems to be in order, have movement on the lead screws when turning them manually (also with a previous test with the Arduino) backlash is virtually so little and might require some tuning on the backlash nuts I made on the lathe, but thats about it. Oh and getting the machine a soul, NOT A GHOST hopefully.

Anyhow here's the specs I can recall off the top of my head so far:

The enite machine (framework) is constructed of 10mm thick aluminium plate with variations of width between 70-100mm's and one or two pieces that has 400x350 and 200x120 dimensions.
M12 (1.75 pitch) high tensile threaded rod leadscrews, very well made anti-backlash nuts, stepper leadscrew couplers commercial units, no play or slipping etc.
4-Axis (standard X, Y Z with rotational B slave mounted in a linear manner on Y)
X, Y, Z fitted with NEMA23 3N/M 1.8* steppers whilst B = NEMA23 1N/M 1.8* stepper (all works out with 200steps /rev)
4 x Wantai DQ542MA Stepper drivers with Enb, Step and Dir signal inputs, a separate 48V input for stepper power
Power supply delivers 5v, 12v 1nd 48v with @ 20A max (Main source is 220-240)
Spindle is a 500W industrial router with toggle switch (later to be altered to be controlled by Mach including MPG)
Flood system fitted with manual switch (also to be included in above alt for Mach)
LCDKeypad shield for Arduino Mega (now redundant)
2 channel 5v relay system for power control for end of job and e stop functions (also to be added)
E stop fitted but is manual.

As for physical dimensions, have not measured the exact travel distances yet but these are roughly as follow:
between the max and min of X roughly around 380mm, Y around 240mm, Z has a travel of around 210mm.

Giving you this info so that perhaps you have a better idea of what I have to do to get this frankenstein to come to life>

Thank you so much for your very helpfull replies, I now have hope again!!!! and will most probably leave work (sneak out) early to go get busy with it today still.
When I die, will someone please dress up as the Grim Reaper and attend my funeral. No need to do or say anything, just attend and stand a short distance away? PLEASE???

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: How to Address Modbus Outputs if you have more than 20
« Reply #17 on: September 02, 2014, 07:13:38 AM »
BOBs are plentiful - might want to ask on the general forum - I don't use them so can't offer suggestions.

If you want to use a laptop with Mach then your only real option is to use external motion control - again there are several - might want to google or ask on the general forum. Don't use one so I can't advise.

Personally I wouldn't use threaded rod for "lead screws". Apart from not being very accurate, the pitch is way too low for a router.

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: How to Address Modbus Outputs if you have more than 20
« Reply #19 on: September 12, 2014, 04:31:21 AM »
Never tried using a laptop for Mach3 - officially, use of the parallel port driver with laptops is not supported. You may want to do a search of the forum - it's been discussed many times. Here's one example. http://www.machsupport.com/forum/index.php?topic=5981.0