Halsampler, sampler and FIFO not cleared

More
28 Jul 2017 04:07 #96606 by Nico2017
Hi,

I am trying to record in an automated way the different positions and parameters (connected to PINs) that were used when my linuxCNC have been running a Gcode. I have got a hal file called in my [HAL] section in the .ini file which manage to sample data to a specific datahalsampler.txt file. Depending if I am running a Gcode file, the sampler to this datahalsampler.txt file is enabled.

Because I want to record the data separatly for each Gcode files I am running, I enable the sampling only when the halui.program.is-running is true. I managed to add a short python script which at the end of a Gcode file, copies the containt of datahalsampler.txt to a file named after the runned Gcode file (let's say my_axis_data.txt when running my_axis.ngc), then erases the datahalsampler.txt once the Gcode is finished.

However when I enable again the sampler when running a new Gcode file, it seems it kept the former value of the FIFO associated to the previous Gcode sampler recording. So my new file datahalsampler.txt contains the actual and former sampled data even if I erased it between the two runs. My question is, is there a way to reboot the halsampler? In other words, I think this is equivalent to clear the FIFO that the sampler is looking into before enabling again the same sampler.

Thank you for your answer.

Cheers,

Nicolas

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

More
29 Jul 2017 22:09 #96663 by andypugh

is there a way to reboot the halsampler?


I haven't used sampler, and this isn't an elegant solution, even if it works. But you could try unloading the sampler and reloading it in your script if it is the realtime half that needs to be reset.

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

More
30 Jul 2017 20:08 #96696 by Nico2017
Hi,

I am quite new at linuxCNC, so what would be an elegant solution? I have explored many options so far:
-halscope features are great when you use it manually but it cannot record in an automated way without been launched and some user interaction. However it does provide a reliable time stamped information.
-there is a datalogger which provides information about position but again require user interaction and needs to be adapted to record other informations (forum.linuxcnc.org/21-axis/30986-axis-position-logger)
-there is a Gstat feature which can get the status message from linuxcnc: linuxcnc.org/docs/devel/html/gui/GStat.html . However the sampling frequency seems to be limited at 10Hz
-halsampler seems to work with sampler. The only thing is I am not sure about the time stamping reliability. I am able to record the time associated to the thread as the sampling frequency is the thread frequency, using the halsampler -t option providing the sample index. It can rapidly generates a lot of data and can record any pin status.

But again with the halsampler, the sampler file contain all the data it has been recording even if I erase it and I enable the sampling towards it a second time. How would it be possible to unload the sampler and reloading it in the script, especially if I want Linuxcnc to keep running. Are hal components not supposed to stay loaded once the thread has started?

Thank you,

Nicolas

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

More
30 Jul 2017 20:54 #96699 by rodw
Try adding a pin to enable/disable the sampler per the docs. Disable sampling, exit halsampler and then run it again with no file logging to clear the FIFO buffer.

I forgot it was running yesterday and found i had captured about 8 gb of plasma torch voltage data even with it set up to only log when the torch was on..

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

More
30 Jul 2017 21:04 #96700 by Nico2017
Hi,

Thank you for your answer. I have a pin which already enable the sampler. I have net SignalEnable halui.program.is-running => sampler.N.enable

However I am not sure about how to exit the halsampler and reloading it while the thread is running, especially from a user component python file. And if I run the halsampler without text file to clear the FIFO, it means that I have then to stop it again and reload it again a second time to sample the new cleared FIFO to the text file, is that correct?

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

More
30 Jul 2017 21:11 #96701 by rodw
I just run it from the command line and hit Control-C to quit in another terminal window. You may need to set the rip-environment in this window if you use run in place.. ie the compiled development version from the command line.

Maybe you can use a signal that gives you finer control. Surely you don't need to log everything when a program is running for the full program run time?
The following user(s) said Thank You: Nico2017

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

More
30 Jul 2017 21:25 #96703 by Nico2017
The idea would be to record data for the whole file so yes I am interested but I might choose a more appropriate signal. For example recording the following error along the whole file gives me precious indication about how far I am in position compared to the initial Gcode along the trajectory.

So are you able to laucnh a sampler independantly from LinuxCNC that can be loaded and reloaded using some halcmd instructions from a cmd line and a hal file? Because so far, I was able use the sampler only if it has been loaded at the same time than the other real time elements to be able to link the enabling signal for instance.

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

More
30 Jul 2017 21:30 #96705 by rodw

So are you able to laucnh a sampler independantly from LinuxCNC that can be loaded and reloaded using some halcmd instructions from a cmd line and a hal file?


Yes thats how I do it. I start Linuxcnc from the command line in one terminal window and run hal sampler in another.

Try opening a terminal window and type "linuxcnc"

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

More
30 Jul 2017 21:48 #96706 by Nico2017
Thank you for the idea, just realised that is also the one initially suggested by andypugh. I will dig in this direction trying to unload then loadrt the sampler component from an independant hal file that hopefully would still be able to interact with the linuxcnc hal while it is running. I guess that the signal linking has to be redone after loading again the real time component?

More tricky question: can the sampler be then set on a low frequency thread but still be connected to the servo-thread high frequency components pins. This way I would like to sample at a lower frequency than the servo thread and decrease the amount of data recorded.

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

More
30 Jul 2017 21:53 #96707 by andypugh
If you have LinuxCNC running then you can connect to that running realtime environment with "halcmd -kf"

You can unload a realtime component at any time with "unloadrt"

If you then reload it, don't forget that you need to also add it to a realtime thread.
The following user(s) said Thank You: Nico2017

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

Time to create page: 0.130 seconds
Powered by Kunena Forum