Threads

More
06 Oct 2011 13:05 #13701 by fma
Threads was created by fma
Hi,

I would like to add a custom thread, very slow (100ms), in order to use the sampler with slow processes (temperature recording).

How and where to do that?

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

More
06 Oct 2011 13:10 #13702 by BigJohnT
Replied by BigJohnT on topic Re:Threads
I would just use the servo-thread, adding another thread has to be a multiple or something like that of the base thread.

www.linuxcnc.org/docview/html/config_ini_config.html#sub:[EMCMOT]-section

John

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

More
06 Oct 2011 13:23 #13704 by fma
Replied by fma on topic Re:Threads
The problem is that I get far too much values, as sampler will sample every servo-thread period, leading to a huge file. I only need 5-10 samples per second...

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

More
06 Oct 2011 14:33 #13708 by BigJohnT
Replied by BigJohnT on topic Re:Threads
Just a debounce to get the sample rate you want.

www.linuxcnc.org/docview/html/man/man9/debounce.9.html

John

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

More
06 Oct 2011 15:15 #13709 by fma
Replied by fma on topic Re:Threads
Ok, but how to I connect the deboucner to the sampler? AFAIK, the sampler samples each time its function is called by the thread...

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

More
06 Oct 2011 17:12 #13711 by BigJohnT
Replied by BigJohnT on topic Re:Threads
Which component is the sampler?

John

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

More
06 Oct 2011 21:07 #13717 by fma

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

More
06 Oct 2011 23:44 #13718 by BigJohnT
Replied by BigJohnT on topic Re:Threads
Cool, you might try debounce connected to the enable pin on sampler... I've never used it before.

John

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

More
07 Oct 2011 06:24 #13733 by fma
Replied by fma on topic Re:Threads
Ah, yes, that's a good idea! Thank!

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

More
07 Oct 2011 09:29 - 07 Oct 2011 09:30 #13736 by fma
Replied by fma on topic Re:Threads
In order to work, the sampler enable pin needs to be true only during 1 clock cycle, otherwise it will generate several samples. The debouncer does not allow that, does it?

So, I think I will have to write a special component, which will generate that single pulse. Something like:
component divider "Divide the 'clock' signal of the thread by some amount";
pin in bit enable=TRUE "enable divider";
pin out bit pulse=FALSE "pulse output";
param u32 divider=10000 "divider value";

variable u32 counter = 0;

function _;

license "GPL";
author "fma";

;;

FUNCTION(_)
{
    if (enable) {
        counter += 1;
        if counter == divider {
            pulse = TRUE;
            counter = 0;
        }
        else {
            pulse = FALSE;
        }
    }
}
What do you think?
Last edit: 07 Oct 2011 09:30 by fma.

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

Time to create page: 0.077 seconds
Powered by Kunena Forum