Machsupport Forum

Mach Discussion => Brains Development => Topic started by: JasonEngbrecht on January 19, 2023, 06:34:34 PM

Title: Output on one condition off if not
Post by: JasonEngbrecht on January 19, 2023, 06:34:34 PM
Hello im trying to write a brain to activate an output  when a encoder dro and axis dro are the same.  This was simple, but the output then stays active.  I need it to switch off once the encoder dro and axis dro are no longer.  This is my first time using brains, and this has stumped me.  Attached is my sad non working attempt.  Can anyone help me out?

Thanks
Title: Re: Output on one condition off if not
Post by: TPS on January 22, 2023, 06:10:10 AM
think it is enough if the output is connected directly after the compare, without the And and OR behind it.
Title: Re: Output on one condition off if not
Post by: JasonEngbrecht on January 22, 2023, 09:04:48 AM
Thats how i originally had it, but the output stays active once the compare is true, and stays active after the compare becomes untrue. 
Title: Re: Output on one condition off if not
Post by: TPS on January 22, 2023, 10:18:56 AM
I need it to switch off once the encoder dro and axis dro are no longer. 

the encoder dro and axis dro are no longer, not longer what?

for the moment i can not get your off condition, so what should switch off the output exactly?
Title: Re: Output on one condition off if not
Post by: JasonEngbrecht on January 22, 2023, 10:31:32 AM
When they are no longer equal.  Once the compare A equals B becomes untrue, i need output to turn back off. 
Title: Re: Output on one condition off if not
Post by: TPS on January 22, 2023, 11:30:29 AM
OK, as mentoined, this should be enough
Title: Re: Output on one condition off if not
Post by: JasonEngbrecht on January 22, 2023, 11:34:24 AM
That is how i first wrote the brain, and the output is stuck on after  A equals B becomes untrue.   
Title: Re: Output on one condition off if not
Post by: TPS on January 22, 2023, 11:36:04 AM
this must work, something else maybe doing something with output5 ? macropump or some othe script?
Title: Re: Output on one condition off if not
Post by: TPS on January 22, 2023, 11:37:27 AM
try an other output, witch is defently not used just for test
Title: Re: Output on one condition off if not
Post by: JasonEngbrecht on January 22, 2023, 11:38:29 AM
Ill give that a shot.
Title: Re: Output on one condition off if not
Post by: Graham Waterworth on January 22, 2023, 07:50:34 PM
Outputs are latched under normal control so I would have thought Brains did the same.  I could be wrong as I do not use Brains much.
Title: Re: Output on one condition off if not
Post by: JasonEngbrecht on January 22, 2023, 07:59:09 PM
I take it latched means once turned on, it also needs turned off, because that seems fo be the issue i have ?
Title: Re: Output on one condition off if not
Post by: Graham Waterworth on January 23, 2023, 05:26:24 PM
Latched is locked into a fixed state until forced to change.  So my guess is you need to toggle the state in the brain or force a state to make sure you have the state you need.

Title: Re: Output on one condition off if not
Post by: JasonEngbrecht on January 23, 2023, 05:29:50 PM
Thats what i figured, and also what im having a hard time doing.  I will keep working at it.  I wrote some that i thought would work but they did not 🤔. 
Title: Re: Output on one condition off if not
Post by: Graham Waterworth on January 23, 2023, 05:52:11 PM
I am not an expert at Brains, not needed to use them much but this is what I think should work.

Title: Re: Output on one condition off if not
Post by: JasonEngbrecht on January 23, 2023, 07:11:52 PM
I tried one similar and it seemed to only use the greater than or less than condition, but ill give it another shot and see what happens, thanks for the suggestion.
Title: Re: Output on one condition off if not
Post by: JasonEngbrecht on January 29, 2023, 04:26:18 PM
I gave that a try, still no luck.  I would think such a small task would be simple.  Not sure what im missing. 
Title: Re: Output on one condition off if not
Post by: Graham Waterworth on January 29, 2023, 09:03:18 PM
It works for me, try my file.

Title: Re: Output on one condition off if not
Post by: JasonEngbrecht on January 30, 2023, 11:26:39 AM
i tried yours, but you used 143 encoder count 3.  I used 170 encoder count 0 I believe.
That was the dro input number I found to correspond with the z axis DRO in the mach 3 settings tab.   The brain I built is identical to yours other than that.  The less than or greater than statements work fine as i toggle the DRO above or below the Z position, but when the encoder count, and z position match, I do not get the Encoder Count = Z position to work.  Where in mach 3 does 143 encoder count 3 correspond to?