Machsupport Forum

Mach Discussion => Brains Development => Topic started by: Vince Endter on April 05, 2008, 12:06:25 PM

Title: Cubloc, brains and ModIO
Post by: Vince Endter on April 05, 2008, 12:06:25 PM
I am going to try to use a Cubloc to control the tool turret on a CHNC lathe.  I would like to know how I can sent the tool requested information from Mach to the Cubloc via ModIO.  I guess a brain would work, but how does one get the tool number from mach to modio?

Thanks

Vince
Title: Re: Cubloc, brains and ModIO
Post by: poppabear on April 07, 2008, 10:38:31 AM
If you want to send Tool infomation via brains, then one option is to use a "User DRO", put the tool number into the
DRO and drop that number into Cubelogic. Have your ladder or Basic program look at the number and then equate that number to a rotation degree that represents where that tool is in your caracell.

scott
Title: Re: Cubloc, brains and ModIO
Post by: Vince Endter on April 07, 2008, 11:03:37 AM
OK, the questions should be, how do I get the tool number to a user DRO? and How can I send that to the Cubloc?  I know how to comunicate with the Cubloc through ModIO. 

Vince
Title: Re: Cubloc, brains and ModIO
Post by: poppabear on April 07, 2008, 12:07:29 PM
Ok,
   
   I have attached a Brain as an example. What it assumes is your using the Serial Plugin enabled, and using configuration 0 as your output config, and that your passing your tool number through Modbus address 0.

It will need to map Modbus Output 0, through the Serial plugin modbus config to the address you want to drop that DRO's information in your Cublogic.

scott
Title: Re: Cubloc, brains and ModIO
Post by: Vince Endter on April 07, 2008, 03:13:52 PM
Thanks Scott, I will work on it over the next couple of days.  Your example should be enough for me to modify to fit my application.

Vince
Title: Re: Cubloc, brains and ModIO
Post by: Vince Endter on April 17, 2008, 10:22:21 PM
I am just trying to get the brain to talk to my Cubloc.  I can communicate with the cubloc when I am in the Test Modbus screen.  I can turn on and off outputs and read inputs.  Below is my serial modbus set up and the brain file.  When I either click on the coolant button in Mach Lathe or send an M8 code via the MDI screen, I am not getting any output on my address 32 on my Cubloc.   On the cubloc, the address are P1 though P65.

Any suggestion would be helpful.

Vince
Title: Re: Cubloc, brains and ModIO
Post by: poppabear on April 18, 2008, 09:13:48 AM
Vince,

   I dont use a Cubelogic, BUT, I notice a few things:

1). first the serial protocol in mach is 8-N-2
2). Your Delay time outs are way high, is that due to your serial to USB converter?
3). I noticed you have several config files, is there any way to have sequential Block of input, and Block of output registers in the cubelogic.
4). Change your output type and input type to Input and Output holding repectivley and when that register comes into the cubelogic use Bit of Word or what ever your equivelent is to get the discreate bit. You can pass your holding registers as your control registers in the Cubelogic.
5). Your Modbus Run box is not checked, perhaps you need to, or forgot about it.
6). Make sure your Flood LED actually Turns ON, when you hit the M code.

Scott
Title: Re: Cubloc, brains and ModIO
Post by: Vince Endter on April 18, 2008, 06:57:50 PM
Thanks for the help.

"1). first the serial protocol in mach is 8-N-2"

I changed the protocol to 8-N-2, still did not work

"2). Your Delay time outs are way high, is that due to your serial to USB converter?"

No converter, I was just copying someone else’s code.  I set them for 25ms

"3). I noticed you have several config files, is there any way to have sequential Block of input, and Block of output registers in the cubelogic."

Yes, the Cubloc can have sequential block of inputs, but not with the board I am using.

"4). Change your output type and input type to Input and Output holding respectively and when that register comes into the cubelogic use Bit of Word or what ever your equivalent is to get the discrete bit. You can pass your holding registers as your control registers in the Cubelogic."

I don't know how to do that in the Cubloc.  I have sent them an email asking how.

"5). Your Modbus Run box is not checked, perhaps you need to, or forgot about it."

Oops, I forgot that.

"6). Make sure your Flood LED actually Turns ON, when you hit the M code."

Another Oops, they were not enabled.  I changed that and verified that they are working.  In the Cubloc, the IO has to be set up in Basic to allow communications for either Basic programs, or Ladder programs.  I am missing something in the Basic program setup.  Hopefully they will get back to me soon and I can get this running.  Once this simple communication thing is fixed, I think I can get most of what I want to do finished.

Thanks again, I'll post when I get the answers from Cubloc.

Vince
Title: Re: Cubloc, brains and ModIO
Post by: jimmybondi on April 18, 2008, 07:18:19 PM
Hi Vince,

everything you have to know you find in CubLoc-Manual.
I'm running 3 of them (CB280) and everything works fine

show me your code and maybe i can help you

Regards Frank
Title: Re: Cubloc, brains and ModIO
Post by: Vince Endter on April 18, 2008, 07:28:59 PM
Hi Vince,

everything you have to know you find in CubLoc-Manual.
I'm running 3 of them (CB280) and everything works fine

show me your code and maybe i can help you

Regards Frank

If you mean the cubloctoughmanual.pdf, I have read through that and am completely lost.  What I have been able to do I just cut and pasted from someone else's program.  I don't have much code and that is on my work computer which I will not have access to until Monday.  For now, all I want to do is turn on an output on the Cubloc from a Brain.  The second thing I want to do is pass a tool number from 1 to 8 from Mach to the Cubloc.  I will then have a ladder program get the tool based on that number.  I am using the 405 module.  Is that enough information?

Thanks

Vince
Title: Re: Cubloc, brains and ModIO
Post by: jimmybondi on April 18, 2008, 09:49:28 PM
vince,

lets give a try :-)

i paste a code snippet of my CB280 - you have to change serveral things like portnumbers
lines i change are *-marked

Const Device = CB405 *changed
 
 Opencom 1,115200,3,80,80   'Open COM1 for MODBUS communication.
 Set Modbus 1,1,1      'Mode=RTU, Slave Adress=1, Return Adress=1

 Usepin 4,In
 Usepin 5,In
 
 Usepin 20,Out
 Usepin 21,Out

 Set Ladder On

 Dim d As Integer
 Dim e As Integer
 ...

Do

LadderScan
_D(12) = Adin(2)

.... your basic code here ...

Loop

**************

small explanaition:

the register _D(12) contains a value betwenn 0 and 1023 - depending of the voltage at ADIn(2) (Pin27 on CB405)
this register can be read as modbus adress 28684 (see pg. 308 on CB-manual - H7000 = D28672

UsePin 4,in = pin 4 is input and readable in Modbus config at adress 4
Usepin 20,out = pin 20 is output and writeable at adress 20

now - lets take output20 of the cubloc for flood coolant as example

in modbus conf write any cfg: (i use 5 in example)

Cfg #5: Enabled
Comment: P20
port/address: 1
Slave: 1
Refresh: 25
modbus address: 20
nr of reg.: 1
direction: output

now go to brain editor - write a brian - name it whatever you want
in it: add an input - select LEDs - and there your choice is 13 - Flood On
activate this LED and add a lobe - in this case: do nothing (no operation) - ok
activate this lobe and press the terminate-button
choose ModBus - in it set address to 0, as output and Serial plugin enabled #cfg 5

save - load - and enjoy

the rest is only a little bit reading (or listen any video which i don't understand)
and a lot of write'n'click

regards Frank

BTW: i don't post my code - nor here neither pn - its a lot of work and i'm really not able to understand the videos ...
i've taken 1 week for learning by doing
Title: Re: Cubloc, brains and ModIO
Post by: Vince Endter on April 18, 2008, 10:08:13 PM
That's almost exactly what I have, except for the Dim and LadderScan statement.  My Brain setup and Modbus setup are the same, see my screen shots above.  It does not work.  In your example, you lost me at the Dime d, Dim e and Ladderscan statements.  Do these have anything to do with the Coolant Brain?  I can't try it on my machine computer until Monday.   Thanks for the help.

Vince
Title: Re: Cubloc, brains and ModIO
Post by: jimmybondi on April 18, 2008, 10:32:33 PM
have you tested the communication between Mach3 and CubLoc ?
both directions ?

thats really elementary

Frank
Title: Re: Cubloc, brains and ModIO
Post by: Vince Endter on April 18, 2008, 11:13:34 PM
have you tested the communication between Mach3 and CubLoc ?
both directions ?

thats really elementary

Frank


Yes, using the test modbus screen, I can read and write to all my inputs and outputs.  I can close the mechanical relays on the Cubloc board from the test screen.  Monday I will try your code exactly and see if it works.  I am thinking I have some simple setting wrong that I don't readily notice.

Vince
Title: Re: Cubloc, brains and ModIO
Post by: Vince Endter on April 21, 2008, 09:20:33 AM
It's working!!!  Thank you Scott and Frank.  The problem was I was using the command input and output instead of usepin in and usepin out. 

Vince
Title: Re: Cubloc, brains and ModIO
Post by: Vince Endter on April 26, 2008, 10:27:01 PM
After 3 days of working on it and reading the sparse manual, I was able to write a Cubloc ladder program that will index the CHNC turret to the proper tool (see the attachment).  The only thing left to do is have the Cubloc get the tool number from Mach and substitute it for the (Tool#) in the ladder program.  It would be nice if the usepin aliases could include a variable that would be linked to an address.  Has anyone done this?

Thanks

Vince
Title: Re: Cubloc, brains and ModIO
Post by: poppabear on April 27, 2008, 09:28:59 AM
Drop your Tool number into a "Pointer" if your cube allows that, then compare the Pointer to your rungs and when it is equal to that tool slot, that rung will run and index to that slot.
Your pointer will act like a "Variable" register.

scott
Title: Re: Cubloc, brains and ModIO
Post by: Vince Endter on April 27, 2008, 08:09:12 PM
Thanks Scott, I will go through the manual and see if there is that type of function.

Vince
Title: Re: Cubloc, brains and ModIO
Post by: Vince Endter on April 29, 2008, 02:32:39 PM
Thanks to all who helped.  I now have the tool turret working under Mach control.  I had Mach send the tool number to an address in the Cubloc, and then I compared the address to the numbers 1 through 8.  If the compare was true, it would execute a subroutine to get that tool position.   Here is a video of it working.

http://video.google.com/videoplay?docid=6834017345329403743&hl=en

Vince
Title: Re: Cubloc, brains and ModIO
Post by: jeep534 on July 24, 2008, 08:48:37 AM
WoW  too cool

archie =) =) =)
Title: Re: Cubloc, brains and ModIO
Post by: pdl on August 26, 2008, 06:40:25 AM
hi guys

ca i use a MPG on cubloc?

thanks

Pete