Welcome, Guest. Please login or register.
Did you miss your activation email?
May 23, 2012, 08:15:59 PM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  Brains Development
| | |-+  Trying to make dro positive
Pages: 1   Go Down
Print
Author Topic: Trying to make dro positive  (Read 1438 times)
0 Members and 1 Guest are viewing this topic.
lukejs
Active Member

Offline Offline

Posts: 6


View Profile
« on: February 01, 2009, 08:21:18 AM »

Hello,

I'm trying to use a brain to test whether the z DRO is negative, and if so multiply it by -1  (i.e. make it positive) before sending it to a modbus device. As you can see in the brainview screen shot attached, it's giving me an output of 0 rather than (in this case) 10.9079. If I make the z-axis DRO positive I get the same output (0). Surely this should work. Can anyone tell me what I'm doing wrong?

Any help is gratefully received.

Thanks,

Luke


* positivebrain.jpg (22.65 KB, 947x145 - viewed 148 times.)
Logged
poppabear
S S SYSTEMS, LLC
Global Moderator
*
Offline Offline

Posts: 1,707


Briceville, TN, USA


View Profile WWW
« Reply #1 on: February 01, 2009, 09:18:44 PM »

All you need is a single liine bring your Z axis dro in, then go through a formula, in that formula put Abs(A), then out to yoru modbus output

ZDro in ->Formula "Abs(A)"->your modbus address out.

scott
Logged

Commercial Mach3: Screens (regular and flash), Wizards, Plug-ins, Brains, PLCs, Macros, ATC's, machine build, retrofit and Prototyping
http://sites.google.com/site/volunteerfablab/
lukejs
Active Member

Offline Offline

Posts: 6


View Profile
« Reply #2 on: February 02, 2009, 07:38:55 AM »

Hi Scott,

That's great, thanks. Perhaps you can enlighten me on something else. What I'm actually trying to do is get a dro value to a modbus device. Now, if I use this formula in a brain I get the fractional part of the DRO: (A-Int(A))*10000. But it seems that DROs are actually stored to greater than 4 decimal places. So if for instance if the DRO actual value is 0.71539, what's displayed in mach3 is 0.7154, but what gets sent to my device is 7153 (i.e. the digits after the 4th dp get truncated rather than rounded). (This is all a supposition based on what's displayed in Brainview). I'm not clear which math operators I can use - for instance I would have thought Round() would be the solution but it doesn't seem to work. Do you know what math operators are available (I hadn't realised Abs worked until you suggested it), or alternatively another way to do what I'm trying to accomplish?

Thanks again,
Luke
Logged
ger21
Global Moderator
*
Offline Offline

Posts: 2,612



View Profile WWW
« Reply #3 on: February 02, 2009, 11:20:09 AM »

Try Format, pages 71-81 here. http://www.machsupport.com/MachCustomizeWiki/pdfs/VB-Script-Commands.pdf
Logged

lukejs
Active Member

Offline Offline

Posts: 6


View Profile
« Reply #4 on: February 02, 2009, 01:59:35 PM »

Surely that won't work as Format() returns a string?

Or will it automatically be converted back to a integer?
Logged
poppabear
S S SYSTEMS, LLC
Global Moderator
*
Offline Offline

Posts: 1,707


Briceville, TN, USA


View Profile WWW
« Reply #5 on: February 02, 2009, 02:13:07 PM »

you will have to change the Formatting of your DROs in you screen set to display more decimal places, read the customizing manual on how to do this.

scott
Logged

Commercial Mach3: Screens (regular and flash), Wizards, Plug-ins, Brains, PLCs, Macros, ATC's, machine build, retrofit and Prototyping
http://sites.google.com/site/volunteerfablab/
ger21
Global Moderator
*
Offline Offline

Posts: 2,612



View Profile WWW
« Reply #6 on: February 02, 2009, 07:48:17 PM »

Surely that won't work as Format() returns a string?

Or will it automatically be converted back to a integer?

I think your right. I was in a hurry and didn't look closely enough. I was looking for Formatnumber, but didn't see it.
Logged

poppabear
S S SYSTEMS, LLC
Global Moderator
*
Offline Offline

Posts: 1,707


Briceville, TN, USA


View Profile WWW
« Reply #7 on: February 03, 2009, 10:33:26 AM »

The "Registers" in Brains are Integer only and 16 bit.  If you want to seperate out for a "Float" or "Double" use the Modulo "%" function in your formulas.

the way I do it, is I will seperate my Double at the PLC with a modulo operator and send the interger across on register and the remainder across another, then I use
a Formula to combine them and drop that value in a DRO.  To send out a Float, I split it in Mach first then send it out, on two and recombine at the PLC........

DRO Displays:  You will have to set your DRO displays in Screen designer for how many decimal places it will show. BUT, if memory serves (and it may not), I think you are limited to a Max of 5 or 6 digits behind the decimal point.

So in desginer if you wanted to display a number like:  *********X.*********xx  you would put: 4.5f in the Format of the DRO type in designer.

scott
Logged

Commercial Mach3: Screens (regular and flash), Wizards, Plug-ins, Brains, PLCs, Macros, ATC's, machine build, retrofit and Prototyping
http://sites.google.com/site/volunteerfablab/
Pages: 1   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!