Machsupport Forum

Mach Discussion => Brains Development => Topic started by: abacus on January 08, 2008, 06:52:50 AM

Title: Howto send DRO Axis information?
Post by: abacus on January 08, 2008, 06:52:50 AM
Hi @all,

I've just startet using brains but my MPG allready works. Now I want to send the current axis position to my Modbus device but I don't know how.

My test brain uses Mach3 DRO's "842-X Position" as input, a no operation lobe and a Modbus serial plugin enables output terminator. But waht kind of data I get if I get any data?

Thanks, G.
Title: Re: Howto send DRO Axis information?
Post by: poppabear on January 08, 2008, 03:42:49 PM
Here is a screen shot of what you need.
Your X Axis DRO as input, goes though a NOP, then to the Serial Plugin Modbus terminator at configuration 0, address 0 (this will send a 16 bit value out).
In the Serial modbus config set the settings for output holding register and do what ever address translation you need to to drop the value into your PLC or what ever.

scott
Title: Re: Howto send DRO Axis information?
Post by: sams_n on January 08, 2008, 05:31:52 PM
Hi Scot ,

i just made a test
in a 16 bit value i can send 2 caracters (ascii) but not , such as  "+123,456".
I alsofound the sendstring terminator , but there I only can send text but not a value of a dro.

Best regards
from Austria
Gerhard

Title: Re: Howto send DRO Axis information?
Post by: abacus on January 09, 2008, 04:37:45 AM
Hi,

Quote
in a 16 bit value i can send 2 caracters (ascii)

This is exact the problem I have. The register contains only the places before the decimal point and it is also limited to 65535 because of the width 16bit registers.

Where is the rest?

Thanks, G.
Title: Re: Howto send DRO Axis information?
Post by: poppabear on January 09, 2008, 08:19:59 AM
The Brain works here, the Terminator shows the DRO value. (click view brain to watch it update).
The value transfer problem may be in how your handeling the date at the Device side.
Define what device your sending to, and data types your using (and what it supports), also if you have to use certian types i.e. holding, register, etc.
BTW: If you are sending to a PLC then remember that you are recieving a DOUBLE.

scott
Title: Re: Howto send DRO Axis information?
Post by: abacus on January 09, 2008, 09:19:15 AM
Hi scott,

Quote
The value transfer problem may be in how your handeling the date at the Device side.

the transfer is device independent. In Modbus configuration dialog Cfg #0 I set Slave #: 2, Adress: 0, # of Registers: 1, Direction: Output-Holding with a refreshrate of 100ms. Mach3 sends only one 16 bit register over Modbus.

Example:

Mach3 X-Axis DRO shows +9.9750 and send "02 06 00 00 00 09 49 FF" over Modbus.

X-Axis DRO = 65535.0000 -> Modbus "02 06 00 00 FF FF 88 49"

X-Axis DRO = 65536.0000 -> Modbus "02 06 00 00 00 00 89 F9"


Thanks, G.
Title: Re: Howto send DRO Axis information?
Post by: poppabear on January 09, 2008, 09:30:28 AM
yes that is the modbus protocol you are seeing.

I am assuming PLC since you havent said what your sending to. ON the PLC side on your com port tick off Hex values not ascii.
In your PLC Drop the number into a register then if from that point you need to change its type do so there. I.e. Load it out, change it to Binary, real, or whatever and then send that value to the display. If you display requires Ascii you may need to change the register value trough an Ascii filter, then to your display.

If your using Peters board, then ask Peter.

scott
Title: Re: Howto send DRO Axis information?
Post by: sams_n on January 09, 2008, 10:42:29 AM
Hi Scott,

in your BrainControl example , mach3 sends 2 Bytes over the modbus using the modbus function 06.
This is very good to see in the examples of abacus.
In older mach3 versions , when we havn't BrainControl , I made the output with a macro in my macropump.

Example:
 '*******X-Dro Value to modbus
 Display = ""
SVal = Right(" " & Format(GetDro(0), strFmt),9)
Display = "X" & SVal
SetModIOString (1,0,0, Display)

That sends many Bytes (1Byte for 1character) to the modbus , using the modbus function 16.
When I use in BrainControl the sendstring terminator also can send text to the modbus , but I can't
find a way to send a value of a dro using the sendstring terminator.

Thanks, Gerhard





Title: Re: Howto send DRO Axis information?
Post by: abacus on January 09, 2008, 10:45:57 AM
I fear you do not understand what I mean.

The DROs content is a floting point value , and you need more than one 16bit register to represent this value. But Mach3 sends only one 16bit register.

Forget about HEX, ASCII, Real or Binary - this is the step that folows after Mach3 has transmit the value to the PLC. I can not handle with a value that will not completely transmited.

Thanks, G.
Title: Re: Howto send DRO Axis information?
Post by: Peter Homann on January 11, 2008, 12:46:27 AM
yes that is the modbus protocol you are seeing.

I am assuming PLC since you havent said what your sending to. ON the PLC side on your com port tick off Hex values not ascii.
In your PLC Drop the number into a register then if from that point you need to change its type do so there. I.e. Load it out, change it to Binary, real, The or whatever and then send that value to the display. If you display requires Ascii you may need to change the register value trough an Ascii filter, then to your display.

If your using Peters board, then ask Peter.

scott

Scott,


The line;
Quote
X-Axis DRO = 65535.0000 -> Modbus "02 06 00 00 FF FF 88 49"
is a dump of the Modbus data leaving the PC. The slave device has nothing to do with this yet.
The line is showing what is being sent out of the PC. It shows that the Brain is converting 65535.0000 to the integer 65536 (FFFF hex). and is writing it to address 0000. The problem is that this is not what is wanted.


The line
Quote
Mach3 X-Axis DRO shows +9.9750 and send "02 06 00 00 00 09 49 FF" over Modbus
.
Shows that reals are being converted to integers as the decimal part is being truncated.

The line,
Quote
X-Axis DRO = 65536.0000 -> Modbus "02 06 00 00 00 00 89 F9"
Shows that brains can only handle 16 bit integers as 65536 equates to 10000 hex and as such the leading 1 is lost. This is not such an issue as 16 bits is the standard integer size.


Either the brain needs to convert the value to a floating point number that the Modbus slave understands, or the brain needs to convert it to ascii characters that the slave can display. This is what the ModIO would require.

It really comes down to the functionality that Brains can provide. The macropump scripting had a function to convert a string and sent it out via Modbus. Very useful for displaying DRO etc.

I don't think that Brains has anything like this. At this stage the functionality of Brains is very primitive compared to what the MacroPump could do.

To do the ascii conversion in Brains would require a lot of runs just to conver a single DRO.


Cheers,

Peter.

Cheers,

Peter.





Title: Re: Howto send DRO Axis information?
Post by: poppabear on January 11, 2008, 01:55:35 PM
Peter,

    Yes, I understand what he was wanting, I was trying to find a way to use the Modulus function in the VB macro pump so I could seperate the Whole number and the remainder number and put them each in thier own register. Then send those two values out to two seperate user registers, then combine them back with a "Addition" block at the target device.

   I just have been to buzy latley to really spend the time trying to get his numbers seperated and sent out.
BTW: Thanks for you most excellent explaination of the Modbus info.

scott
Title: Re: Howto send DRO Axis information?
Post by: poppabear on January 11, 2008, 01:57:03 PM
Another option you may be able to Use Bit masking techniques to sperate out the two parts as well, then send them sepratly also.

scott
Title: Re: Howto send DRO Axis information?
Post by: jimmybondi on January 24, 2008, 04:37:58 AM
Hi,

it takes only a few minutes to show the DRO on LCD via modbus.
But what you see is only a screenshot of the LCD-Simu because i'm not able to program
SPI on my PLC :-(

in the background Mach3 and foreground my notebook with simulated LCD of the PLC:
Title: Re: Howto send DRO Axis information?
Post by: DennisCNC on January 24, 2008, 05:10:48 PM
^^ Could you share the cubloc code to do that?
Title: Re: Howto send DRO Axis information?
Post by: manmeran on October 19, 2010, 05:13:47 PM
i sent DRO position via macropump and serial port on Lcd.
but i decide use Modbus ,similar "jimmybondi"
Please explain .this thread remained without conclusion.


Amir
Title: Re: Howto send DRO Axis information?
Post by: manmeran on October 20, 2010, 11:31:49 AM
this is solution.
we can send each axis via modbus with 4 register(4 byte)
2 byte for int and 2 byte decimal
up 65536.65536
i think is enough ;D

Amir
Title: Re: Howto send DRO Axis information?
Post by: poppabear on October 22, 2010, 09:41:57 PM
Quote
Another option you may be able to Use Bit masking techniques to sperate out the two parts as well, then send them sepratly also.

scott
Title: Re: Howto send DRO Axis information?
Post by: ahmed01280 on March 12, 2015, 01:45:31 PM
i need ti know in brain editor what represent dir & step