Hello Guest it is March 28, 2024, 11:55:30 AM

Author Topic: Modbus testing  (Read 4097 times)

0 Members and 1 Guest are viewing this topic.

Offline Bob49

*
  •  57 57
    • View Profile
Modbus testing
« on: August 16, 2014, 06:22:07 PM »
Hi,

Long time reader, first time poster.  Been running Mach for years using MSM screen set.  System is running well on Win7 32 bit.  Decided I wanted to introduce some hard wired switches to control Mach's functions from button pushes, so I bought a Cubloc Cubase64M modbus board.  And honestly, I'm not a computer guy, an electronics guy or a basic or ladder programming guy.  But I got the board working in ladder logic, tested with a toggle switch and an LED hard wired to the in and out pins, then tested in Cube Studio by changing switch styles to see the little led's on the board go on and off with my changes.  Feeling good at that point.  My settings that I downloaded to the board were com1, baud 115200, 8-n-1 or 8-1-n (however that goes), slave address 1, RTU.  All of this was from spending lots of time reading here and other places to get the knowledge to get that far. 

Using the same 1:1 cable I got with the Cubase board, I swapped the serial cable to the com1 port on the cubase board and launched Mach.  Made the settings in Gen Config for the serial port using the numbers from above, then in ports and pins selected use modbus and modbus plugin. Restarted Mach to let the changes take place and went to setup my modbus configuration.  Making the same settings as those I downloaded to the board, I get no error returned when selecting modbus run.  I setup two configs, one for outputs and one for inputs to get me started.  Applied the changes and went to test modbus.  This is where I get nowhere.  I open the com port and get no error message which seems like a good thing.  But I certainly can't seem to get any response by reading the registers, coils or any other selections there.  I've changed the startc and number of coils all over the place trying to get some response in that window.  I get a timeout message and that is all.  I can hit the digital format selection and get some numbers for the total number of coils I input in that box, but the never change with me using the toggle switch I've wired to the board and in my mind I should see a difference between on and off on that particular pin.  Maybe I'm wrong there though.

I've been through all the settings a couple dozen times now the past two days and get the same results in the test.  I've changed the timeout time up to 500ms and down to 100ms.  Never any change in the test window.  I've watched the videos and read a ton on this, and it seems like my settings are the same as what I've seen in them.  But my results aren't like what I witnessed on the videos.  I'm thinking I need to get some response in the test window before I can even worry about seeing if my brains will play with the setup I have on the cubase board.

So, I'm looking for some advise to get past the failing testing I think is happening.  I've been telling myself it's some little setting I've missed, but honestly, there aren't that many to make.  I've read of guys here who had the same problem and I followed the advise given them back then with no success.  One other thing that bothers me is the serial monitor function tells me my "serial is not enabled-go to ports and pins and enable it-then restart Mach".  Does that function even work?  Far as I know there is only two settings that need to be made there and I've made them...many times.  I've lost count how many times I've restarted the pc and Mach, but lots.  I tried the com0 port on the cubase board with the same end results, tried it with power on the board and with the power switch off.  No change which I thought odd.  Power, by the way, is from a 24v wall wart to the round power plug on the board.  Nothing I do seems to get any action other than a timeout on the test screen.  Feeling late today I'm wasting my time with it.  I certainly don't know if this is something incorrect in my Mach settings or something in my statements in Cube Studio, but I do think the pins are all active in ladder and Mach will return some data if I force it.  So I think Mach can read the data on the board.  It's like Mach doesn't even care to take a look at it. 

Thanks in advance for any advise anyone might have to offer.  Sorry for rambling, but I never learned to talk in shorthand.

Bob

Offline Bob49

*
  •  57 57
    • View Profile
Re: Modbus testing
« Reply #1 on: August 20, 2014, 01:54:05 PM »
I found the problem this morning after many hours of making changes in various places and scrutinizing the serial side of things for a day or so.  I started deleting statements in my program in the Basic side of Cube Studio until I got good test results, then ran Mach3 and modbus test worked as advertised.  I tried my only switch I have setup in brains to reset Mach and it works like it's supposed to.  The statement causing the problem was "set outonly on".  I had wondered about the need for it all along, but just didn't know enough to realize it was the cause.

Bob

Offline Bob49

*
  •  57 57
    • View Profile
Re: Modbus testing
« Reply #2 on: August 21, 2014, 05:14:41 PM »
To add more to the solution, I found my out put ports were not functioning after removing the "set outonly on" statement from my Cubase64M program.  Lots more reading trying to figure that out and quite a bit of experimenting in Cube Studio and CFTerm.  Finally found a jumper needs to be removed from the board in order to use the set outonly on statement and allow the RX to function.  It's the JP2: RS-485 TransEnable jumper.  I think it will keep from being able to add another board if more pins are needed, but I've got output pin functions and Mach3 communicating to the board at long last.  Now to figure out how to make it all do what I want it too.  That'll be a long journey I'm sure.

Bob