Machsupport Forum

Mach Discussion => Brains Development => Topic started by: Bob49 on March 06, 2015, 01:40:18 PM

Title: Brains writing wrong values to DRO's
Post by: Bob49 on March 06, 2015, 01:40:18 PM
Hi,

I've been working on getting a new mill console connected and talking to Mach3 through a CubeLoc modbus card.  Everything through the modbus works as it should and all the different signals all get fed to my brain files.  The rotary switches I used are binary, that is to say they have single or multiple pins being contacted at the different switch positions.  It took me some time to figure out how to deal with the binary values moving from the switch, to the modbus, to Mach and finally to the individual brain files.  But I got there eventually.  All the binary is dealt with directly in my brain files, the rest of the system just sees it as the individual pins are either on or off.  And for the most part it all works like it should.

But I got one or two small problems I can't seem to understand what's happening.  In my feed rate override brain, I had to keep each brain file to only four switch positions each brain.  So I ended up with 5 individual brains for the 21 positions of my switch.  The spindle speed override is similar, but I was able to have five switch positions in each brain for a total of 3 brain files for that function.  That took some time to figure out what the problem was, but in the end the brains were just too long.

Some more history first, I got both of those switches working along with the rapid override switch some days ago, only to find that the correct percentage number would only get dropped into the corresponding dro while the switch was being turned to increment the value.  If the switches were turned to decrement or decrease the values, the values would be whatever the lowest switch setting reflected or a zero.  I could stop decreasing the switch positions wherever I wanted and go the other directions and the correct values would be displayed again.  I corrected that problem this morning by adding an "or" gate or lobe as shown in the brain pics I've attached.

But now that I have most values being dropped into the dro's correctly, I find that a few won't display the correct value in the dro's.  The brain shows the correct value, but the dro will just show a 0.  The ones I'm finding fault with are either the first or last switch position in each brain, but not across the board.  In brain #1, all four positions work correctly no matter the direction the switch is being turned, in brain #2, the top (63%) won't display anything other than a 0 while the switch is being incremented but works correctly while being decremented.  And in the same brain file, the bottom position (100%) will display a 0 while the switch is being decremented, bt works correctly when it's incremented.  In brain #3, the bottom position (150%) displays a 0 while the switch is being decremented but is fine with it being incremented.  Brain #4 works correctly at all switch positions just like brain #1.  Brain #5 has a problem with the top position (212%) with the switch being incremented, again displaying a 0.  But if decremented, the correct values is displayed.  These are all feed rate override brains and that's what the pictures reflect.

On the spindle speed override brains, I have two that display incorrectly with the switch being decremented and those two are bottom rungs in the individual brains.  All of them work correctly while the switch is being incremented.

Then one other brain is really throwing me for a loop.  It's the rapid override brain.  It only has 4 positions in it and all work correctly except the one that should reflect 75%.  The brain is made similar to the feed rate brains and the brain actually displays the correct percentage at 75%.  But what gets dropped into the dro was 91, not 75.  So I messed with this some this morning and only got more puzzled by it.  It seems I can change the 75 to 60 and it will display correctly in the dro,  61, 62 and 63 likewise.  But if I change it to 64, it will start to display oddly and show 89%.  I got no idea what to think about that problem.

So, I thought I'd ask the experts for some advise to see if anyone had any thoughts on how to correct these small problems.  I can use like it is, but I'd rather they work as they should.   Pics below.

Thanks for looking
Bob
Title: Re: Brains writing wrong values to DRO's
Post by: Bob49 on March 06, 2015, 01:41:25 PM
One more pic.
Title: Re: Brains writing wrong values to DRO's
Post by: TPS on March 07, 2015, 04:14:34 AM
hi Bob,

i am realy not familar with brains, but i wold try to do this in one brain.

Thomas
Title: Re: Brains writing wrong values to DRO's
Post by: Bob49 on March 07, 2015, 10:23:25 AM
Thanks for the response Thomas,

Couldn't wait to get out there and give that a try this morning.   But as you show it, it just keeps sending the value 250 to the feed override dro.  So I removed the 2 lines that start with V0 and terminate in V0 and it works.  Awesome!  I knew if I could get the whole thing into one working brain file it would work, but I'm very new to this brain thing.  Simple, I seem to be able to do.  These feed and speed overrides weren't that simple to me.  I had no clue about the local variables or what they could be used for, thanks for that tip.

This worked so well that I'll be rewriting my rapid override and spindle speed override brains too.  Maybe that will fix the incorrect value I keep getting in the rapid override.

Thanks a million,
Bob
Title: Re: Brains writing wrong values to DRO's
Post by: Bob49 on March 07, 2015, 08:27:35 PM
Well, I got the rapid override working perfectly in the same format as Thomas came up with for the feed rate override, other than the two lines I mentioned above.  But the spindle speed override is giving me some trouble using that format.  There's a big difference between the feed rate and spindle speed in that the bottom of the feed rate was zero with the top being 250.  The spindle speed bottom value needs to be 40 with the top being 250.  And done in 15 steps instead of the 20 or 21 the feed rate had.  This makes the math different for every switch position, complicating it a lot.  At least I've not seen a common denominator in it.  And there's only 4 pins with values of 1, 4, 8 and 2.

One other thing I found out was either the individual math formulas I was using or the V2 termination I used was causing Mach3 to lock up at the brain control.  I fought that a big part of the day, coming to the conclusion it was the spindle speed override brain that was the problem.

Bob
Title: Re: Brains writing wrong values to DRO's
Post by: TPS on March 08, 2015, 05:28:22 AM
Hi Bob,


for the spindle should something like this work.(modbus adresses must be different)
not sure why you had to delete the two lines with V0

the first one should protect the value to get less than 0
the second one should protect the value to get greather than 250
are you sure your compare was "greater than" and not "less than".

Thomas
Title: Re: Brains writing wrong values to DRO's
Post by: TPS on March 08, 2015, 07:02:36 AM
Hi Bob,

ok forget about this V0 thing, played a little bit around,
it's not working. the values seam to be only updated
at the end of a brain.

think the protection for under- and oversizing the values need
to be done in macropump macro.

Thomas
Title: Re: Brains writing wrong values to DRO's
Post by: Bob49 on March 08, 2015, 05:30:12 PM
Hi Thomas,

Thanks for the response,  My Feed rate override brain file looks just like the last one you did.  The problem was the value sent to the feed rate override dro stayed at 250.  And I reasoned yesterday that i probably didn't need the V0 if all I was doing was dropping off the value somewhere, so I went back to the Feed Ovrd DRO. 

That change was after having the brain control lock up on whenever I tried to enable a brain that had a local var other than V0.  V0 worked in the feed rate brain, but V1 or V2 wouldn't work in the rapid override or in the spindle override.  I spent a good part of the day rebooting my PC due to that problem.  So now I don't have any local vars in any brain files. 

I've been playing with the spindle override most of yesterday and all of today.  I had some ideas, but they all mostly involved having multiple brain files for the spindle override.  That does not work, comes close, but it was never 100% correct.  Some of the funky stuff I went through was due to the brain being too long, or being spread out over multiples.  Today, after talking to a machinist friend, I dropped the bottom value to 10 and the top value to 150 and made steps of 10's and have a 100% working brain for the first time on the spindle override.  That just makes my panel graphics wrong, but that's an easy fix with a decal if I stay with those values.

But lets talk about that spindle override brain you posted.  I messed with it and it works well.  I changed the 40 in yours to 30 and am nearly hitting my original steps well enough I think I can live with it.  How did you arrive at that formula?  I kept thinking that I should be able to add something to a base number and increase the values with each switch position.  Or to use a percentage in the formula's.  But I couldn't come up with anything. And I've done enough changing of brains the last few weeks to make me not want to experiment for the sake of experimentation.  That's just pretty cool.  I think I'll keep it active and try it out for a while to see if the steps are too big.  But it's pretty much where I was trying to go originally, so why not run with it.

I've only started to get involved in macro's and my first attempt works, but reports errors upon completion.  Lots more to learn on that subject.

Thanks again Thomas, you've been a big help.
Bob
Title: Re: Brains writing wrong values to DRO's
Post by: TPS on March 09, 2015, 03:23:11 AM
Hi Bob,

you asked:
--->How did you arrive at that formula?

ok i try to explain in my bad english:

we have the value from the knob, witch is 0->15
we want a outgoing value from 40->250, so we have a range
of 210.

210/15 = 14, so we multiply the origal value by 14 and add
the 40 for the beginning value, thats it.

Regards Thomas

Title: Re: Brains writing wrong values to DRO's
Post by: stirling on March 10, 2015, 07:04:23 AM
Just a thought but why don't you just send your 5 bits in ONE register rather than a separate register for each bit? (currently you're using 5 * 16 = 80 bits to send 5 bits of info)

If you did that your Brain would reduce to just one rung i.e.  Modbus reg -> formula (A*12.5) -> feed override.

Ian
Title: Re: Brains writing wrong values to DRO's
Post by: Bob49 on March 10, 2015, 10:42:24 AM
Hi Ian,

Not sure I can adequately answer that, but I'll try.  I'll be honest, I pondered for some time where those bits would be coming from, but I knew it wouldn't be the switches themselves.  I finally realized I had to create them in one or the other locations.  From the modbus, I'm just sending the state of the switches or of the individual switch pins.  In my cubloc board I merely used some basic statements to turn inputs and outputs on, that kept me from having create any ladder logic.  Ladder logic is where I think the bits would have to be created in order to send Mach brains those values.  After reading up on each, I decided that brains seemed the simpler of the two, so thats where this whole thing started.  And since I've used every input pin for connecting those switches, I wasn't sure how to get the values out to mach although I'm pretty sure there's a way. 

When I started down this road, even basic was greek to me, let alone ladder logic.  So I jumped on the first one that started to make sense.  Today, it's looking like I'm going to have to rely on some ladder logic in the modbus board to finish the functionality of the remaining switches.  I still have a couple switches for coolant that aren't wired in yet that need to be dual position for auto or manual and some keypad buttons I got no clue how to deal with.

So the real answer is I think I took the easy way.  And that may not turn out to be the best way.  After I get my feet wet in ladder logic for what's left, I may feel like experimenting with the logic for the other switches.  But I'm betting that I'll just be wanting to get it all done so I can do something else.  I'm certainly not an knowledgable electronics or programming guy, so this all has been a bit rough for me.  I've had to dig and learn every step of the way.  But I got to say I'm enjoying the ride a bit now that I'm seeing results.  I actually got my first mach3 macro to work yesterday to finish out all of the switches that are currently wired.

Bob
Title: Re: Brains writing wrong values to DRO's
Post by: stirling on March 10, 2015, 10:58:53 AM
Completely understand Bob. So far you seem to be doing a good job.

Ian
Title: Re: Brains writing wrong values to DRO's
Post by: Bob49 on March 10, 2015, 11:56:04 AM
Thanks Ian,

I appreciate the kind words.  I used this forum a lot in my research and found way more examples of how to do what I needed (or close) in brain files than I did in modbus ladder logic to do the same.  Since I'm so inept in electronics and logic programming, I learn by absorption.  See and read what others have done and try to adapt it to my needs.  I'm not afraid of either ladder logic, basic programming, VB or brain files as if I make a mistake, it's only words, lobes or something that I messed up.  I didn't really break anything, just got something that won't work, as with my first attempt at a macro.  I always have the e-stop.

You'll never see posts from me advising anyone to do anything in any of these languages, lol.  Unless it's to say here's what I did, it worked and I'm stupid.  So how hard can it be, go ahead and jump in.  But I do appreciate the help given by guys like you and Thomas, even if it wasn't directed at me.  I wish I had just some of the knowledge you guys have on this subject, I wouldn't have spent so many months fumbling my way through it.  But in my life, it's not necessarily the destination, but the journey.

Bob
Title: Re: Brains writing wrong values to DRO's
Post by: TPS on March 10, 2015, 04:27:15 PM
Hi Bob,

But I do appreciate the help given by guys like you and Thomas, even if it wasn't directed at me.  I wish I had just some of the knowledge you guys have on this subject, I wouldn't have spent so many months fumbling my way through it.

all of the knowlege, i have got of this system (ok sometimes it's not very much), i got on the same route you do for the moment.


it was all try and error.

Thomas
Title: Re: Brains writing wrong values to DRO's
Post by: Bob49 on March 10, 2015, 07:34:44 PM
Hi Thomas,

I'd say you're getting a good grip on it.  It's these kinds of things that usually make my eyes gloss over and then I tend do drag my feet getting into.  Things I don't really understand and haven't done before.  But I know all things are that way and some I'm really up for the challenge.  This one was just one that I knew going in that I'd have lots of learning to do before I could succeed.  I may be reaching out for more help in the future to get the remaining switches all working, but the only things left is the keypad and coolant switches.

As for your command of the english language, it may be better than my midwest slang of it.

Thanks again for your help
Bob