Programming a 'custom' button
- beltramidave
- Offline
- Elite Member
- Posts: 174
- Thank you received: 4
As I said before, I know nothing of programing with C. Could you elaborate more on what I need to to with that code (patch comp). Sorry for being so dense, but I actually am trying to learn from what you are putting out there.
Please Log in or Create an account to join the conversation.
If you are using 10.04, you don't need to do anything with the code, there is a compiled module in the zip.
Copy it to /usr/bin
Try out the sim, then look at the .xml and custom.hal files for how to load the module and connect up the pins to pyVCP panel etc in your own config
regards
Please Log in or Create an account to join the conversation.
- beltramidave
- Offline
- Elite Member
- Posts: 174
- Thank you received: 4
Please Log in or Create an account to join the conversation.
I have not been able to get permissions for /usr/bin to copy points to it. Can you tell me what I need to do. I am the administrator and only user on this computer.
Either use sudo before each command or su root (if you have root set up, Ubuntu disables it by default, but the scripts you ran should have enabled it)
From the directory with points in, try
sudo chmod 777 points to set the permissions on it wide open
then
sudo cp points /usr/bin/points
regards
Please Log in or Create an account to join the conversation.
- beltramidave
- Offline
- Elite Member
- Posts: 174
- Thank you received: 4
www.linuxcnc.org/docs/html/gcode/overview.html#sec:parameters
Program button calls MDI sub, #5161=#5420 / #5162=#5421
Recall button calls MDI sub G0 X#5161 Y#5162
Andy,
I can't seem to figure out how to "program" more than 1 button using this method. I'm sure there is a simple fix, but I can't figure it out.
Please Log in or Create an account to join the conversation.
What part of it isn't working?I can't seem to figure out how to "program" more than 1 button using this method. I'm sure there is a simple fix, but I can't figure it out.
(And how are you doing it?)
Please Log in or Create an account to join the conversation.
- beltramidave
- Offline
- Elite Member
- Posts: 174
- Thank you received: 4
Basically, I only have 3 buttons created at the moment, 'Program', 'Custom1', and 'Custom2'.
'Program' records the current position by calling a subroutine with #5161=#5420 & #5162=#5421.
'Custom1' calls a subroutine with G0 X#5161 Y#5162.
'Custom2' calls a subroutine with G0 X#5163 Y#5164.
'Custom1' works great! I know why 'Custom2' doesn't work as I haven't moved any values into 5163 & 5164. Without having a seperate 'Program' button for each 'Custom' button, I am not sure how to do this.
Please Log in or Create an account to join the conversation.
I think a separate "program" for each "apply" is probably the way to go, to be honest.'Custom1' works great! I know why 'Custom2' doesn't work as I haven't moved any values into 5163 & 5164. Without having a seperate 'Program' button for each 'Custom' button, I am not sure how to do this.
Laid out next to each other, with number boxes to show the current status, it should look quite tidy.
Please Log in or Create an account to join the conversation.
- beltramidave
- Offline
- Elite Member
- Posts: 174
- Thank you received: 4
I had thought about making the 'program' button a set/reset button, then looking to see if it was set and then by pushing 'custom1', it would send current coordinates to #5161 & #5162 or by pushing 'custom2', send coordinates to #5163 & #5164 and so forth. Then If the 'program' button wasn't set, just run the sub with the loaded coordinates.
I am a plc guy and I am pretty confident I could do it with plc logic, but not so sure with this programming. Thanks again for your help.
Please Log in or Create an account to join the conversation.
Ah, well, in that case:I am a plc guy and I am pretty confident I could do it with plc logic
www.linuxcnc.org/docs/html/ladder/classic_ladder.html
Though I am fairly sure that you could do what you want in the G-code subroutines.
O<program1> sub
#5161=#5420
#5162=#5421
O<program1> endsub
O<custom1> sub
O100 if [#5161 ne 9999]
G0 X#5161 Y#5162
#5161 = 9999
#5162 = 9999
O100 else
#5161 = #5420
#5162 =# 5421
O100 endif
O<custom1> endsub
And so on. I don't think this does what you want, but I am not entirely clear what you want. I am just demonstrating the use of the G-code "if" statement and a "magic number" stored in the parameters as a way to set behaviour.
Please Log in or Create an account to join the conversation.