Hello Guest it is September 21, 2019, 05:57:04 AM

Author Topic: compare immediate not working  (Read 8724 times)

0 Members and 1 Guest are viewing this topic.

compare immediate not working
« on: June 16, 2015, 08:19:47 AM »
Hi Guys

This is my first attempt at a brain so the solution to my problem may be human error and immediately obvious to someone. I hope!!!

I am working on my lathes 8 station tool turret which has 4 optical switches used to detect the current tool.

It's logic uses the following truth table


tool position       1     2     3     4     5     6     7     8

switch    1          1     1     1     1     1     1     1     1
switch    2          1     1     1     0     0     0     1     1
switch    3          1     0     0     0     1     1     1     1
switch    4          0     0     1     1     1     1     1     0

The switches are connected via a pokeys and are referenced to INPUT #1 , INPUT #2, INPUT #3,  INPUT #4

when I rotate the turret the switch signals seem to follow the truth table pattern ok.

These signals are reflected accurately in both the first column of the brain program

(ie input colours  blue/ green  change  to reflect truth table)

the pokeys status page and the mach3 diagnostics page so (I think) the input signals are fine.


(What I want to do is use a brain program (for speed) to set the current tool position then use a

simpler macro to control tool changes.)


The structure for the program is straight forward and I have attached a photo of my layout.

The problem is the second column of the program does not respond to the changes of the inputs.

ie the immediate compare isn't comparing.


More often than not the immediate compare boxes just retain there initial startup value ( ie blue or green)

very occasionally some will change but with an incorrect result.


I am not entirely convinced than my logic is correct

ie  IF   input 1  AND   input     AND   input  3    And   input 4   are correct   then enter tool number into current tool DRO

I am not sure if changing the value in the dro changes the current tool value. I have the feeling that

SetCurrentTool ()  should be employed somewhere  but to simplify the matter and to test the compare function

I have also done a version that removed the last two columns of the program and took out all reference

to current tool and changed it with a simple output 1 .......output8 

this would also have benefit of letting me check the results on the  diagnostics page

but result was just the same.

Any help would be greatly appreciated as I don't know what to try next.

cheers George


ps I don't know if this is normal or not but if I go into program edit then click on the comparison box

the compare immediate is highlighted  but none of the other  3 options are highlighted

ie greater than ,  less than ,  or equal to 

even though the comparison box shows the equal sign  !!!



Offline TPS

*
  •  1,388 1,388
    • View Profile
Re: compare immediate not working
« Reply #1 on: June 16, 2015, 09:41:51 AM »
Hi,

please have a look for your truth table

Tool Position 1+8 have the same pattern
Tool Position 5+6 as well.

Thomas
anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: compare immediate not working
« Reply #2 on: June 16, 2015, 11:17:44 AM »
Sorry about that just a typo. Should read.

tool position     1     2     3     4     5     6     7     8

switch 1           1     1     1     1     1     0     0     0
switch 2           1     1     1     0     0     0     1     1
switch 3           1     0     0     0     1     1     1     1
switch 4           0     0     1     1     1     1     1     0


cheers George   

Offline TPS

*
  •  1,388 1,388
    • View Profile
Re: compare immediate not working
« Reply #3 on: June 17, 2015, 04:57:40 AM »
Hi George,

tryed to find the code of your truth table.
it is not binary and not gray code.

anyway i would start with a simple brain, only 2 or 3 numbers,
and also not use the compare instruction.

attached a small sample i would start with.

Thomas
anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: compare immediate not working
« Reply #4 on: June 17, 2015, 12:04:09 PM »
Thanks Thomas that approach works great.

I would never have thought of that myself.    Just  brilliant.

However there is still a couple of problems with the program.

1)  It doesn't seem to like my method of changing the current tool number


ie add   FORMULAE    (tool number)     then terminate    with  TOOL CURRENT  DRO

any thoughts?  and

2) As the turret is rotated the program works totally as expected up to tool number 6

at this point the     AND     block lights up for both 6 7 and 8 ( see attached photo)

the only thing I can think of is maybe it is at this point where I had to use the screen scroll

when writing the program and may be this is causing a glitch.

 I have tried editing the program and then totally writing and new one but the result is the same.

One point I did notice. Input 4 on both blocks tool 7 and tool 8 were very difficult to deselect

ie to get rid of the input 4 green highlight to allow me to highlight the next 4,  column 2  blocks

so I could add the appropriate  AND   function.   (hope that makes sense !!)


cheers George
Re: compare immediate not working
« Reply #5 on: June 17, 2015, 01:27:35 PM »
Thomas

Just in case you think there may be an issue with my set up.

This is what I've got. The lathe is an emcoturn 120.

Unfortunately I smoked the original emco board so I have tried

to make a replacement. It is just 4 optical switches with a Schmitt

trigger to try to give digital output. ( see photo 1)

The turret internal shaft has a vane trigger to work the switches (see photo 2)

The truth table came from the emco paperwork ( see photo 3)

just in case it helps

cheers George

Offline TPS

*
  •  1,388 1,388
    • View Profile
Re: compare immediate not working
« Reply #6 on: June 17, 2015, 04:55:01 PM »
Hi George,


for the moment i am on the road, that the (single) brain is to long.
so i would prevere to split this brain into two brains.
brain one for tool 1-4
brain two for tool 5-8

in my very back reminds there is soomething about
to "long" brains.

Thomas
anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: compare immediate not working
« Reply #7 on: June 18, 2015, 05:54:49 AM »
Hi Thomas

You are right again.

When I split it into two programs it follows the truth table exactly through 1 to 8.

But unfortunately only up to the formulae blocks it still doesn't

actually change the current tool value.

I think I may need to use SetCurrentTool () somewhere. I have been looking

at past threads and it seems possible to call a macro from a brain.

what if I wrote 8 short macros to be called by the brain as required?

Seems a very long winded approach!!!!  What do you think?

Cheers George

ps just for your information

I also tried to rewrite the two brains 1-4  and 5-8  in

my original format ie using immediate compares just

to see if it worked.  But it didn't, it was just the same.

Not to worry we are older and wiser. Well older.

Offline TPS

*
  •  1,388 1,388
    • View Profile
Re: compare immediate not working
« Reply #8 on: June 18, 2015, 11:22:17 AM »
Hi,

i am not sure how it is done in brain.
i only know in VB script it is

SetCurrentTool( ToolNew )

Regards Thomas
anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: compare immediate not working
« Reply #9 on: June 18, 2015, 01:11:28 PM »
Hi Thomas

Many thanks for all your help and support it really is greatly appreciated.  cheers.


I must admit I am a little disappointed with my first foray into the world of brains.

They seem way more fragile and unpredictable than I thought.

Maybe I need to think again.


Anyway thanks again for all your help

cheers George