Machsupport Forum
Mach Discussion => Brains Development => Topic started by: BIGWING 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 !!!
-
Hi,
please have a look for your truth table
Tool Position 1+8 have the same pattern
Tool Position 5+6 as well.
Thomas
-
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
-
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
-
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
-
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
-
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
-
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.
-
Hi,
i am not sure how it is done in brain.
i only know in VB script it is
SetCurrentTool( ToolNew )
Regards Thomas
-
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
-
Hi George,
i will be offline for a couple of day's.
if after this "day's" nobody got a brain
"solution" we will try to get this working
in VB.
Thomas
-
Hi Thomas
That's brilliant thanks for that. I need all the help I can get
I have made a bit of progress on the brains
Two things
First I have noticed that It doesn't appear to like the formulae output
just as an integer. Instead it seems to prefer it in terms of the inputs ABCD
so for each formulae I picked an input that had a 1 value then multiplied it
by the required tool number ie for tool 4 A*4 rather than just 4 etc etc
Second I came across some guide notes written by poppabear and he states
• You cant have the same object as an output, follow as an input further down in the same brain and expect it to change condition on a single scan. Brains only does ONE state change per object per scan. (at least that is what I have found). It is hit or miss if your doing it across several Brains then it will depend on execution position and last state wins…….. The only exception to this is Local Vars which appear for all intents and purposes to update locally at that scan, again that is also hit or miss, I have seen it work like that and NOT work like that………go figure……. Keep to the reusing the Output only once as an input in the same brain and you should do OK for the most part.
So I took out the repeated use of current tool dro tied all the lobes together with an OR command and terminated to a single current tool dro
I did this for both brains ie tools 1 - 4 and tools 5 - 8 and I thought it worked but just as poppabear predicted both brains are competeing with each
other for priority sometimes it will work perfectly sometimes it will output 0 for 4 tools. !!#*@*@*#*!!
Anyway my next train of thought was to change the two termination values for each brain to V1 and V2
ie Current Tool DRO to local var V1 and local var V2
then write a third brain
local var Formulae Termination
V1 no operation
ADD A + B Current Tool DRO
V2 no operation
ie at any time either A or B will equal 0
but when running this my computer locks up so it doesn't like something!!!!
So still some work to do.
Hopefully someone else from the forum will jump in with the answer.
Anyway thanks again and enjoy your weekend
cheers George
-
Hi Guys
I have since read that you can't use local variables as inputs or the system locks up (been there)
so I have now tried
input1 no operation Formulae termination
input2 no operation
(A*B*C*D) +v1 + v2 Current Tool DRO
input3 no operation
input4 no operation
where (A*B*C*D) will always be 0 and either v1 or v2 will be zero depending upon turret position
This has not worked either. I can't get the new brain to recognise the local variables V1 and V2
it just outputs 0. How can I transfer variables from one brain to another?
Can anyone shed some light on this?
cheers George
-
Hi Guys
Just a quick note to say I think I've cracked it.
I didn't manage to get two brains to swap variables
but I did manage to shorten the program so it stopped throwing up errors
basically in my first attempt I was using 4 inputs to define each tool station
if fact I just needed 3 and in some case 2
ie input2 = 0 AND input3 = 0 uniquely describes tool station 4 etc etc
if I get a chance over the weekend I will do a quick summary of my findings
just in case anyone else is wanting to do anything similar.
cheers George
-
Hi George,
back again.
in VB it would be easy, am i am sure that it will work
like this.
' tool position 1
If (IsActive(INPUT1) And IsActive(INPUT2) And IsActive(INPUT3) And Not IsActive(INPUT4)) Then
SetCurrentTool( 1 )
End If
Thomas
-
Hi Thomas
Hope you had a good weekend.
Thanks for that I will keep it in mind.
I managed to get the brain program working eventually. It hasn't failed
yet but I am still keeping a close eye on it for the moment. I still get the feeling
brains contains bugs but hopefully they only expose themselves during the programming
phase. If the brain proves to be unreliable I will make use of your suggestion of script.
The reason I wanted a brain to monitor the tool position is just for speed.
I thought it would mean that I could use a much shorter tool change macro.
That is my next project.
Just for information in case anyone else is looking to write a similar brain I have attached
a photo of the final program and one of it in action.
My observations/recommendations are as follows
(the observations may or may not be correct but may allow you to spot a common trend and hence identify a bug)
1) Read poppabears user guide to brains first. (forum user documents) Wish I had found it earlier.
2) Although I could not see a reason why it should not work. The immediate compare function did
not seem to work for me. Luckily Thomas showed me a workaround.
3) The formulae box did not like straight forward integer values. Instead they needed to be in terms of an input.
4) Could not get local variables ie V0 V1 to pass from one brain to another. If they can only stay within one brain they
must be of very limited use.
5) Only use a particular output once within a brain. It might even confuse it if two or more brains are trying to output
to the same location I don't know but worth checking if you are having problems.
6) The length of the brain seems to be an issue. For me any program over 20 line the scroll feature would kick in and incorrect results achieved.
When reading poppabears notes I think he said 50 lines was the max but he normally stopped at 40. Maybe screen size
can have an influence !!. If this is the case maybe temporarily changing the screen resolution may be a workaround.
7) If you are still struggling and needs to post for help hopefully Thomas or one of the other regular contributors will answer your call.
I don't know where we would be without them.
Thanks Guys
George
-
Hi George,
7) If you are still struggling and needs to post for help hopefully Thomas or one of the other regular contributors will answer your call.
I don't know where we would be without them.
Thanks Guys
George
Thank You
Thomas
-
Just so you know teh Sampling rate for the I/O with brains is NO faster than the Macropump BOTH run at 10hzs ( 10 samples per sec).
Just a thought, (;-) TP