QtDragon how to save gearchange in position.txt

More
01 Nov 2021 08:40 #224856 by myval
Hi,
is there any way I can save position of two gear change actuators in position.txt in qtdragon?
I have been scratching my noggin over this for a while I have actuators with only one proxy switch in low gear the switch is opened in middle/ neutral position switch is on and in high gear is again open.
So the logic I am trying to implement is to have it in neutral while the machine is not running. When I turn it on it will be in known middle position but in case of some sort of failure if the machine stopes dies crashes ... in any gear position. I would love to know on bootup what state it was in last time as a fall back .

Please Log in or Create an account to join the conversation.

More
01 Nov 2021 17:24 #224894 by cmorley
Firstly, if it's possible to add a second sensor that would be the fool-proof and most direct way.

Do you use a gcode command to change gears? I'm thinking that you could use a parameter in that case.

Qtvcp can be made to remember stuff, but it requires using custom files, after that which makes updating harder. Also then you probably need some type of initialization procedure.

Can you give more detail of how you you think this should work?

Please Log in or Create an account to join the conversation.

More
01 Nov 2021 20:49 #224914 by myval
Yeah adding a second sensor would be sweet but not possible on the second actuator there is no room for it the first one would be possible to add a second sensor but i feel that would be twice the development. Still would have to come up with a solution for the second actuator.
I change the gears based on the spindle speed.

Well how I thought it should work is that when I drive the actuator lets say to high speed it would write it in position.txt like qtdragon does (I assume for the joints) and when I need I could get the position back from the file and that way I know which way to drive actuator.

I have spent lovely day on python today and how I got it going is that the actuator lets say needs to move to high speed, I drive it in high direction until the sensor opens then back it of until it closes again. Edge finding procedure. If I need to drive it to high speed for some reason again it just jumps of the edge and returns, basically stays on the edge.

I am not sure if I explained it well enough. If I kept the position of the actuator in the file that would limit the unnecessary forth and back movement.

Please Log in or Create an account to join the conversation.

More
02 Nov 2021 05:53 #224954 by cmorley
So the actual changing of gears is done all in HAL code?
Then recording HAL pin states at shutdown would be enough?

Please Log in or Create an account to join the conversation.

More
02 Nov 2021 11:26 #224978 by myval
it is actually a python code and recording something like 0 = neutral, 1=low gear, 2 = high gear would be more then enough (I think it would be but time and testing will tell)

Please Log in or Create an account to join the conversation.

More
02 Nov 2021 22:01 #225046 by cmorley
if you are already using python code to change the gears, why don't you use the same code to record to a file?

Please Log in or Create an account to join the conversation.

More
04 Nov 2021 11:41 #225231 by myval
Well, this is bit embarrassing I can write some stuff but I am not a programmer and I do struggle a lot with it. Reading and writing into a file is something I can not get my head around.
My thought was that if qtdragon already saves positions in a file I could tap into it with some pin/ variable in qtdragon.

Please Log in or Create an account to join the conversation.

More
05 Nov 2021 00:04 #225308 by JohnnyCNC
I searched the qtdragon_handler.py file and found this example. You could use this as a example of how to save the data that you want to save.  The last two lines do all  the work to actually write the file.

def btn_save_status_clicked(self):
text = self.w.machinelog.toPlainText()
filename = self.w.lbl_clock.text().encode('utf-8')
filename = 'status_' + filename.replace(' ','_') + '.txt'
self.add_status("Saving Status file to {}".format(filename))
with open(filename, 'w') as f:
f.write(text)

See  this  for how to read a file in Python.
 

Please Log in or Create an account to join the conversation.

More
05 Nov 2021 08:05 #225374 by myval
Sweet, I will give it a go.
Thank you

Please Log in or Create an account to join the conversation.

Moderators: cmorley
Time to create page: 0.084 seconds
Powered by Kunena Forum