Machsupport Forum

Mach Discussion => Brains Development => Topic started by: Ivan_The_Red on April 18, 2012, 07:16:05 PM

Title: Whats wrong with this brain ???
Post by: Ivan_The_Red on April 18, 2012, 07:16:05 PM
My modbus device is sending a value that the brain can recognize ( which is 40 in this case  - see the picture ) but the brain doesnt continue calculating the value as i would expect.
Since the value of 40 is less than 32767 i would expect to see a value of .004" in the "formula" box as well as the tool dia output.

It seems so simple that I'm probably missing something stupid or i've missed some documentation somewhere, any advise or guidance would really be appreciated.


Thanks

Ivan
Title: Re: Whats wrong with this brain ???
Post by: poppabear on April 18, 2012, 08:45:53 PM
the problem is your "compare" block, if it is true it outputs a "1", if false a "0" that is why when it is true you getting that small value.
Title: Re: Whats wrong with this brain ???
Post by: Ivan_The_Red on April 18, 2012, 09:12:32 PM
thanks for the information, I did not know that a compare resulted in a '0' or '1' output. I thought that a comparison would either allow or stop a continuation in the processes
after the comparison, not an output of '0' or '1'. Another one of those things in life that make you go hhhhhhhmmmmmmmmmmm...
Title: Re: Whats wrong with this brain ???
Post by: BR549 on April 18, 2012, 11:17:00 PM
I think there is a serious flaw there(;-) How Else could you do a comparitor and have the previous value pass through. It should not have passed through the 0/1 that controls the gate???

Just a thought, (;-) TP
Title: Re: Whats wrong with this brain ???
Post by: stirling on April 19, 2012, 09:40:21 AM
I think there is a serious flaw there(;-) How Else could you do a comparitor and have the previous value pass through. It should not have passed through the 0/1 that controls the gate???
Can't agree Terry. A comparator's OUTPUT is BOOLEAN - that's it's job and definition. If you want it to output (pass through) it's input when it's comparison is TRUE - what do you want it to output if the comparison is false? (Hint: don't say zero because that COULD have been its input  ;)).

The OP's quest is to convert a 16bit twos complement number into a signed decimal - see his previous post and my answer. I've just done it with a brain. I'll leave you to have a go before I post  >:D.

Cheers

Ian
Title: Re: Whats wrong with this brain ???
Post by: BR549 on April 19, 2012, 10:09:18 AM
HIYA Ian, I went at it for a long time last night.  I agree IF we were tlaking about CB but Brains are suppose to be a ladder type logic and ladder does have pass through values as the comparitor is a gate so to speak.

I understand what you are saying about a comparitor output being boolean.  

Yes IF the gate was open you would get the pass through value, IF the gate was closed you would get NIL or zero.

I can get the value to be correct but not with using the comparitor

OR I could be wrong all together, (;-) I will work on it some more.

(;-) TP

Title: Re: Whats wrong with this brain ???
Post by: BR549 on April 19, 2012, 10:53:07 AM
I am not getting anywhere My brain is locked in the logic loop and is NOT coming out. I just repeat everthing I did last night over and over again.

(;-) TP
Title: Re: Whats wrong with this brain ???
Post by: stirling on April 19, 2012, 11:01:21 AM
Yes IF the gate was open you would get the pass through value, IF the gate was closed you would get NIL or zero.
See above for why I already dismissed that ;).

OK I'm gonna be a tease. Duplicate your input. Comparator the first one. Multiply the comparator output by the other input....

Ian
Title: Re: Whats wrong with this brain ???
Post by: BR549 on April 19, 2012, 11:27:28 AM
OK got it now.

Dro --> IF<100 = 0/1
Dro --> A * B =  *********   -->  output --> A/10000 -->  New DRO

I was close at one point last night BUT Iwould have never got the connection. SEEMS a long way around the block to cross the street  BUT I guess it is what it is (;-)

Thanks Ian, I owe you another pint(;-)

(;-) TP
Title: Re: Whats wrong with this brain ???
Post by: stirling on April 19, 2012, 01:08:01 PM
SEEMS a long way around the block to cross the street  BUT I guess it is what it is (;-)
I agree - but as you say - we work with what we have.

Of course there's always the macropump.

Ian
Title: Re: Whats wrong with this brain ???
Post by: BR549 on April 19, 2012, 01:13:08 PM
Macropumps are not a problem I have already been brainwashed in that area(;-) I did build the same thing there to test it hoping to find some BRAINS logic stashed away in CB.

Hopefully I learn something new every day.

(;-) TP

Title: Re: Whats wrong with this brain ???
Post by: Ivan_The_Red on April 19, 2012, 07:56:12 PM
Hey guys

View the image posted....

I tried building a brain based on the previous discussions and I dont understand why this brain is not using a 1 in the multiplication portion instead of 10 . I believe the logic
should be to take the "1" ( because the modbus value is less than the comparison  - which would return a 1 ) and multiply it by the other duplicate modbus value of 10
and calculate a value of 10 ..... not 100. Is this an error in my brain design or an error in Mach ?

or

If anybody  has a "pictoral" image of a brain that does work , could you please post it ?

As always thanks
Title: Re: Whats wrong with this brain ???
Post by: BR549 on April 19, 2012, 08:43:04 PM
SOunds like it is working RIGHT this time and passing through the MOD values.  Try setting the comparitor to  > rather than < to see IF it returns a Zero .

OR try taking out the second tier of values and see IF it runs with just the top layer thisw time.

(;-) TP
Title: Re: Whats wrong with this brain ???
Post by: BR549 on April 19, 2012, 08:50:14 PM
As a test I am in the .062 version AND the single line pass thru worked just fine, (;-)

I give up, (;-) TP
Title: Re: Whats wrong with this brain ???
Post by: Ivan_The_Red on April 19, 2012, 09:46:08 PM
I just changed the signs as was suggested and the characteristics of the multiplication process does not change, it still multiplies 10 by 10 ( the modbus inputs, not the results
of the boolean logic and one modbus value) .As for my Mach version, i am using 3.043.022.

Could you post a picture of the brain portion that works for you so I can duplicate what you have to eliminate version issues etc. ?

I am new to brains and I am getting the impression that they are buggy, is this an accurate assessment in your opinion ?
Its really unfortunate that somebody or a team of people wrote the functionality of brains but the available documentation
and lack of brain examples is ashamed it makes them almost a "learn by mistake" or "trial and error" process.
Title: Re: Whats wrong with this brain ???
Post by: BR549 on April 20, 2012, 11:05:50 AM
THe really strange part is it seems to flip flop as to IF it works or not WHEN I restart MACH3.  Some times it works some times it does NOT work.

Beats me, (;-) TP
Title: Re: Whats wrong with this brain ???
Post by: stirling on April 20, 2012, 11:18:42 AM
OK here's a pic of my demo twos complement "converter". Stable here on 3-43-22.

Ian
Title: Re: Whats wrong with this brain ???
Post by: BR549 on April 20, 2012, 03:15:56 PM
IT took a while but I found where the work right one time and opposite the next was coming from.

I THINK I had a second brain running that I forgot to turn off. So which ever brain ran last got control over the results.

DUM DUM, (;-) TP
Title: Re: Whats wrong with this brain ???
Post by: Ivan_The_Red on April 20, 2012, 06:05:09 PM
Thanks for the design help ....... but check out what the brain does on my machine - its the same Mach version that you have installed and my
formula does not calculate like yours did. I have no other brains running at this point.

Can you think of any other reasons for this ? my god this is weird

Thanks
Title: Re: Whats wrong with this brain ???
Post by: Ivan_The_Red on April 20, 2012, 07:56:33 PM
Well heres another weird thing, I created a separate brain based on what BR549 provided and it worked as expected. I dont
know if its possible to corrupt a brain or if there are other unknown bugs with the brain functionality , but at this
point I'll chalk it up as a victory .......

I cant say thanks enough , I dont think I would have figured this out without everyone's help.
a special thanks to BR549