Work Light Aux 11 Toggle Code Help

All things related to the Centroid Acorn CNC Controller

Moderator: cnckeith

Post Reply
Threedj16
Posts: 224
Joined: Thu Feb 22, 2018 1:21 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: C8FD19F23AFF-0213180659
DC3IOB: No
CNC11: No
CPU10 or CPU7: No
Location: Augusta, Ga

Work Light Aux 11 Toggle Code Help

Post by Threedj16 »

I've read through TB300, and I'm not seeing how you turn on and off an Aux button (with the same button). Is there one already setup for the work light since it's on the pull down in wizard? I had to tie it to flood to get it to work. I don't plan on using flood, but when I go back to auto mode, the lights are going to go out. So wouldn't have lights running unless I called for mist and flood in the code. But then, they would shut off again with the program completed. Would be nice just to tie it to one Aux button.

I've also been reading the lathe_plc.src and PLC manual. It's just taking me a while to wrap my head around which names should be used where. Can the variable names be used out in a macro? I see but the first few if statements, apparently memory locations can be. I can follow along on some of the examples to see what is happening, but then a lot of them shoot over my head. I tried to look at flood and mist in the source, but due to the fact they introduced auto and manual modes, it made it way more complex to try and follow. So I thought turning on a work light would be easy....LOL....little did I know (or how little do I know apparently).

Would something like this work, since worklight is assigned to output 8?

;------------------------------------------------------------------------------
; Filename: Mfunc79
; Toggle Worklight Aux 11 macro
; Description: User Customizable Macro
; Notes:
; Requires: Machine home must be set prior to use.
; Please see TB300 for tips on writing custom macros.
;
;Turn on work light for Aux12 button - parameter 199 set to 7911
;------------------------------------------------------------------------------

IF #50010 ;Prevent lookahead from parsing past here
IF #4201 || #4202 THEN GOTO 1000 ;Skip macro if graphing or searching
IF #4120 == #90014 THEN GOTO 1000 ;Skip macro if already at position

N100 ;Insert your code between N100 and N1000


IF worklight==set then worklight==rst
else worklight==set

If Aux11LED==set then Aux11LED==rst
else AuxLED==set


N1000 ;End of Macro

Does a macro only run once when the Aux11 button is pushed? Or is this where a one shot should be used?
report_C8FD19F23AFF-0213180659_2018-04-16_20-09-55.zip
(210.58 KiB) Downloaded 151 times


Centroid_Tech
Posts: 286
Joined: Thu Mar 18, 2010 2:24 pm

Re: Work Light Aux 11 Toggle Code Help

Post by Centroid_Tech »

It appears that the default logic for the worklight was accidentally overlooked in the PLC program. That will be corrected and resolved in the next release. In the mean time, please add the following logic to the .src file, save it, and recompile it.

;--Worklight

IF Aux7Key THEN (Aux7PD)
IF (Aux7PD ^ Aux7LED) || OnAtPowerUp_M THEN (Aux7LED)
IF Aux7LED THEN (WorkLightOut)

Remember that if you run the wizard again after compiling the new PLC program, the wizard will overwrite all of the changes in this custom PLC program.

Of course, the code above is using the AUX7 button to turn the worklight on and off but you can change that to whatever AUX button you wish as the overlay for the VCP shows the AUX7 button as the Spin Brake button. You just need to modify the logic above for your desired AUX button.

You cannot use the same nomenclature in the custom macros as you are using in the .src file. Think of the custom macro more like a G-code program rather than a PLC program.

If you wanted to, there are default custom macros to turn outputs on and off as long as they are not defined as specific outputs. M6x macros are used to turn outputs on where x is the output number whereas M8x macros are used to turn outputs off. For example, let's say that you wanted the worklight to be on output 8 and you wished to have a macro associated with turning that output on and off. In the wizard, you would not define anything for that output. That means that output 8 is defined as Output8 and not anything else like worklight, spinFWD, etc. Issuing an M68 will turn output 8 on while issuing an M88 will turn output 8 off. If you wished to have an AUX button associated with those M6x and M8x macros, you could set parameters 188 thru 199 accordingly so that when that AUX button is pressed the associated custom macro is run.
When requesting support, please ALWAYS post a current report. Find out how to take a report from your Acorn, CNC11 or CNC10 system here: https://www.youtube.com/watch?v=Ecvg0VJp1oQ.

If your question is PLC, Macro or program related, please also post a copy of the program or macro as well.

Without the above information we may not be able to help and/or reply until the required information is posted..


Threedj16
Posts: 224
Joined: Thu Feb 22, 2018 1:21 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: C8FD19F23AFF-0213180659
DC3IOB: No
CNC11: No
CPU10 or CPU7: No
Location: Augusta, Ga

Re: Work Light Aux 11 Toggle Code Help

Post by Threedj16 »

Centroid_Tech wrote: Wed Apr 18, 2018 10:04 am It appears that the default logic for the worklight was accidentally overlooked in the PLC program. That will be corrected and resolved in the next release. In the mean time, please add the following logic to the .src file, save it, and recompile it.

;--Worklight

IF Aux7Key THEN (Aux7PD)
IF (Aux7PD ^ Aux7LED) || OnAtPowerUp_M THEN (Aux7LED)
IF Aux7LED THEN (WorkLightOut)

Remember that if you run the wizard again after compiling the new PLC program, the wizard will overwrite all of the changes in this custom PLC program.

Of course, the code above is using the AUX7 button to turn the worklight on and off but you can change that to whatever AUX button you wish as the overlay for the VCP shows the AUX7 button as the Spin Brake button. You just need to modify the logic above for your desired AUX button.

You cannot use the same nomenclature in the custom macros as you are using in the .src file. Think of the custom macro more like a G-code program rather than a PLC program.

If you wanted to, there are default custom macros to turn outputs on and off as long as they are not defined as specific outputs. M6x macros are used to turn outputs on where x is the output number whereas M8x macros are used to turn outputs off. For example, let's say that you wanted the worklight to be on output 8 and you wished to have a macro associated with turning that output on and off. In the wizard, you would not define anything for that output. That means that output 8 is defined as Output8 and not anything else like worklight, spinFWD, etc. Issuing an M68 will turn output 8 on while issuing an M88 will turn output 8 off. If you wished to have an AUX button associated with those M6x and M8x macros, you could set parameters 188 thru 199 accordingly so that when that AUX button is pressed the associated custom macro is run.
Thank you so much! I was wondering why I kept getting variable undefined errors, as I thought I was defining them via the wizard. It's slowly starting to get there.

I was also able to find most of the turret code I need in the lathe.plc.src file at the bottom under incremental. However it looks incomplete. The two statements are identical, except one does a +1 to the turret_count_w and the second does a -1 to the turret_count_w variable. But I was able to find that I could use toolturretposbit1 and toolturretsycbit and tie those to my input 6 and input 5 respectively along with rotatetoolturret and tie it to output 2.

So I will make all these changes, recompile my src again and then try to finish working out the logic on the turret next.

I'm also going to somehow have to account for the fact when the turret rotates forward, it passes over the optical switch for the tool it's on (causing a state change) before it gets to the tool that is next. This is due to the automatic reverse to lock into the pawl (the trip switch has to be slightly ahead, so it has room to reverse back into the pawl).

Current logic in the lathe.plc.src that seems to me, it just giving an end result of no increase:
AtcIncrementalStage
;------------------------------------------------------------------------------
;For incremental ATC's, ToolTurretPosBit1 is the tool counter and toggles each time the
;turret rotates to a tool position. If ToolTurretPosBit1 toggles while ReverseToolTurret is
;not on, then CurrentTurretPosition_W = CurrentTurretPosition_W + 1. If ToolTurretPosBit1
;toggles while ReverseToolTurret is on, then CurrentTurretPosition_W = CurrentTurretPosition_W -1.
IF ToolTurretPosBit1 && RotateToolTurret && !ReverseToolTurret
THEN CurrentTurretPosition_W = CurrentTurretPosition_W + 1

IF ToolTurretPosBit1 && RotateToolTurret && !ReverseToolTurret
THEN CurrentTurretPosition_W = CurrentTurretPosition_W - 1


Threedj16
Posts: 224
Joined: Thu Feb 22, 2018 1:21 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: C8FD19F23AFF-0213180659
DC3IOB: No
CNC11: No
CPU10 or CPU7: No
Location: Augusta, Ga

Re: Work Light Aux 11 Toggle Code Help

Post by Threedj16 »

Centroid_Tech wrote: Wed Apr 18, 2018 10:04 am It appears that the default logic for the worklight was accidentally overlooked in the PLC program. That will be corrected and resolved in the next release. In the mean time, please add the following logic to the .src file, save it, and recompile it.

;--Worklight

IF Aux7Key THEN (Aux7PD)
IF (Aux7PD ^ Aux7LED) || OnAtPowerUp_M THEN (Aux7LED)
IF Aux7LED THEN (WorkLightOut)

Remember that if you run the wizard again after compiling the new PLC program, the wizard will overwrite all of the changes in this custom PLC program.

Of course, the code above is using the AUX7 button to turn the worklight on and off but you can change that to whatever AUX button you wish as the overlay for the VCP shows the AUX7 button as the Spin Brake button. You just need to modify the logic above for your desired AUX button.

You cannot use the same nomenclature in the custom macros as you are using in the .src file. Think of the custom macro more like a G-code program rather than a PLC program.

If you wanted to, there are default custom macros to turn outputs on and off as long as they are not defined as specific outputs. M6x macros are used to turn outputs on where x is the output number whereas M8x macros are used to turn outputs off. For example, let's say that you wanted the worklight to be on output 8 and you wished to have a macro associated with turning that output on and off. In the wizard, you would not define anything for that output. That means that output 8 is defined as Output8 and not anything else like worklight, spinFWD, etc. Issuing an M68 will turn output 8 on while issuing an M88 will turn output 8 off. If you wished to have an AUX button associated with those M6x and M8x macros, you could set parameters 188 thru 199 accordingly so that when that AUX button is pressed the associated custom macro is run.
Well, I copied everything over and placed it right above the coolant section. Only thing I changed was worklight instead of worklightout which doesn't appear anywhere in the source code and gave me an error compiling. Once I changed that, compiled the program with no errors, restarted my acorn and no lights on machine or on aux button. I know the output 8 relay works, as I tied it to flood (earlier in the week). I also just tried using out8 in place of worklight, same thing. Was I supposed to turn on a parameter for the work light to to use aux7, as I assumed since it was defined in the source, that wouldn't be the case. Anyway, not sure what I am missing, but I get no errors on the code running nor on the compile.

report:
report_C8FD19F23AFF-0213180659_2018-04-18_18-22-25.zip
(181.55 KiB) Downloaded 156 times


Threedj16
Posts: 224
Joined: Thu Feb 22, 2018 1:21 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: C8FD19F23AFF-0213180659
DC3IOB: No
CNC11: No
CPU10 or CPU7: No
Location: Augusta, Ga

Re: Work Light Aux 11 Toggle Code Help

Post by Threedj16 »

I'm liking the PLC detective. I've used similar debugger programs when I used to build databases. But unfortunately it's telling me that none of the variables listed are turning on. So I played with a few additional, such as DoAux7key and it does give a 1 when I push the button. So how do I need to rearrange this in order to get this Aux7 button to get the worklight to turn on and off?

Thanks


Latest report as of today. I moved it to under the incremental turret stage near the bottom and added on some turret testing code (along with associated one shot and m6 function which was missing).
report_C8FD19F23AFF-0213180659_2018-04-19_22-43-03.zip
(182.61 KiB) Downloaded 130 times
Last edited by Threedj16 on Tue Nov 12, 2019 4:48 pm, edited 1 time in total.


Threedj16
Posts: 224
Joined: Thu Feb 22, 2018 1:21 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: C8FD19F23AFF-0213180659
DC3IOB: No
CNC11: No
CPU10 or CPU7: No
Location: Augusta, Ga

Re: Work Light Aux 11 Toggle Code Help

Post by Threedj16 »

Centroid_Tech wrote: Wed Apr 18, 2018 10:04 am It appears that the default logic for the worklight was accidentally overlooked in the PLC program. That will be corrected and resolved in the next release. In the mean time, please add the following logic to the .src file, save it, and recompile it.

;--Worklight

IF Aux7Key THEN (Aux7PD)
IF (Aux7PD ^ Aux7LED) || OnAtPowerUp_M THEN (Aux7LED)
IF Aux7LED THEN (WorkLightOut)

Remember that if you run the wizard again after compiling the new PLC program, the wizard will overwrite all of the changes in this custom PLC program.

Of course, the code above is using the AUX7 button to turn the worklight on and off but you can change that to whatever AUX button you wish as the overlay for the VCP shows the AUX7 button as the Spin Brake button. You just need to modify the logic above for your desired AUX button.

You cannot use the same nomenclature in the custom macros as you are using in the .src file. Think of the custom macro more like a G-code program rather than a PLC program.

If you wanted to, there are default custom macros to turn outputs on and off as long as they are not defined as specific outputs. M6x macros are used to turn outputs on where x is the output number whereas M8x macros are used to turn outputs off. For example, let's say that you wanted the worklight to be on output 8 and you wished to have a macro associated with turning that output on and off. In the wizard, you would not define anything for that output. That means that output 8 is defined as Output8 and not anything else like worklight, spinFWD, etc. Issuing an M68 will turn output 8 on while issuing an M88 will turn output 8 off. If you wished to have an AUX button associated with those M6x and M8x macros, you could set parameters 188 thru 199 accordingly so that when that AUX button is pressed the associated custom macro is run.
Any explanations as to why this code won't work (besides the wrong Worklight name)? Aux7Key never turns blue on the PLC detective when I push the Aux7 button.


Threedj16
Posts: 224
Joined: Thu Feb 22, 2018 1:21 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: C8FD19F23AFF-0213180659
DC3IOB: No
CNC11: No
CPU10 or CPU7: No
Location: Augusta, Ga

Re: Work Light Aux 11 Toggle Code Help

Post by Threedj16 »

Well, finally a step in the right direction. Sure I may have used too many test variables, but it works...so screw it. My work light is finally toggling on and off with Aux 10. I inserted it right above the coolant section, compiled and run. Though you will probably want to cycle your Acorn before running CNC12.

;WorkLight Toggle Aux10
IF (Aux10Key || KbAux10Key_M || SkinAux10_M) THEN (Aux10PD)
IF (!Aux10LED && Aux10PD) || OnAtPowerUp_M THEN Set Aux10LED
IF (Aux10LED && Aux10PD) THEN RST Aux10LED
IF Aux10LED THEN (WorkLight)


Post Reply