Mesa 5i25/6i25 my own component: how to begin?

More
30 Oct 2015 20:54 #64522 by andypugh
I have never used it, but it looks about right.
You need to setp sampler.0.enable 1 too, to start sampling. Or net it to amp-enable, or something.
The following user(s) said Thank You: sirop

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

More
03 Nov 2015 18:14 #64678 by sirop
So I wrote only a HAL script so far:
loadrt hostmot2
loadrt hm2_pci
loadrt threads name1=main_thread period1=100000 # name2=sample_thread period2=100000
# Unsure if periodN is optimal
loadrt sampler depth=500  cfg=FF
# Unsure if FIFO depth is optimal
addf hm2_5i25.0.read main_thread
#addf hm2_5i25.0.write main_thread
addf sampler.0 main_thread
net encPosition sampler.0.pin.0 hm2_5i25.0.encoder.00.position
net encVelocity sampler.0.pin.1 hm2_5i25.0.encoder.00.velocity
setp sampler.0.enable 1
loadusr halsampler -t # ~/halsample.out
start

Is is smart to use only one thread for both hm2_5i25.0.read and sampler.0 ?

If I run each of these commands from halrun interface, the data output never stops,
unless I interrupt it with Ctrl+C.

If I run this script as a file with halrun -f halsample.hal ,
then the data output stops by itself depedent on the period of the main_thread as I found out by trial and error.
I do not know why this happens as I do not see any hm2/hm2_5i25.0: Watchdog has bit!
in /var/log/linuxcnc.log .

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

More
03 Nov 2015 18:31 #64681 by ArcEye
If it helps, this is an extract from an alternative latency-test I wrote, which gives logging to file as well as a display widget
loadrt threads name1=fast period1=25000 name2=slow period2=1000000
loadrt timedelta count=2
addf timedelta.0 fast
addf timedelta.1 slow
start
loadusr -Wn lat pyvcp lat.xml
net sl timedelta.1.max => lat.sl
net sj timedelta.1.jitter => lat.sj
net st timedelta.1.out => lat.st
net sv timedelta.1.avgerr => lat.sv
net bl timedelta.0.max => lat.bl
net bj timedelta.0.jitter => lat.bj
net bt timedelta.0.out => lat.bt
net bv timedelta.0.avgerr => lat.bv
net reset lat.reset => timedelta.0.reset timedelta.1.reset

loadrt sampler depth=1000 cfg=ssssssss
addf sampler.0 slow
net sl sampler.0.pin.0
net st sampler.0.pin.1
net sj sampler.0.pin.2
net sv sampler.0.pin.3
net bl sampler.0.pin.4
net bt sampler.0.pin.5
net bj sampler.0.pin.6
net bv sampler.0.pin.7

loadusr hallatencysampler -c 0 -t $LOGFILE
waitusr -i  hallatencysampler

waitusr lat

The pyVCP panel widget bits aside, it shows the connections, thread speeds, depths etc that work.

This process is halted via the quit for the widget, you need to engineer something in to stop sampling

regards
The following user(s) said Thank You: sirop

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

More
03 Nov 2015 18:32 #64682 by andypugh

So I wrote only a HAL script so far:
loadrt threads name1=main_thread period1=100000 # name2=sample_thread period2=100000


You seem to have two threads both running at 100uS. (And you are only using one of them)
That's unusually fast for a 5i25.read / write thread.

Is is smart to use only one thread for both hm2_5i25.0.read and sampler.0 ?

As the hm2 data is only updated after a .read there is no point sampling any faster.

If I run this script as a file with halrun -f halsample.hal ,
then the data output stops by itself depedent on the period of the main_thread as I found out by trial and error..

This might be a side-effect of the fast sampling, does it stop the same way with a 1000uS thread time?
The following user(s) said Thank You: sirop

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

More
03 Nov 2015 19:00 #64686 by sirop

So I wrote only a HAL script so far:
loadrt threads name1=main_thread period1=100000 # name2=sample_thread period2=100000


You seem to have two threads both running at 100uS. (And you are only using one of them)

No, I use only one thread as there is a comment sign "#" before name2:
halcmd: loadrt threads name1=main_thread period1=100000 # name2=sample_thread period2=100000
halcmd: show thread
Realtime Threads (flavor: xenomai) :
     Period  FP     Name               (     Time, Max-Time ) flags
     100000  YES           main_thread (        0,        0 )

That's unusually fast for a 5i25.read / write thread.

"Unusually fast" means unnecessarily fast? Probably, you right.
I just wanted to test out out how far I can go with my Intel NUC, 4 Celeron cores.

If I run this script as a file with halrun -f halsample.hal ,
then the data output stops by itself depedent on the period of the main_thread as I found out by trial and error..

This might be a side-effect of the fast sampling, does it stop the same way with a 1000uS thread time?

I hope I understand you correctly and you mean thread period saying thread time.
So with thread period of 100uS the output stops after 2419 entries if I run this script as a file.
With thread period of 1000uS the output stops after 242 entries if I run this script as a file.

As said already, if I run this script interactively line by line from the halrun cmd, the data output never stops.

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

More
03 Nov 2015 21:41 - 03 Nov 2015 21:42 #64699 by andypugh

So with thread period of 100uS the output stops after 2419 entries if I run this script as a file.
With thread period of 1000uS the output stops after 242 entries if I run this script as a file.


That looks like a constant time (2.5 seconds).

What happens with halcmd -kf ?
You might even need halcmd -Ikf to keep the halcmd session open after the script completes.

www.linuxcnc.org/docs/html/man/man1/halcmd.1.html
Last edit: 03 Nov 2015 21:42 by andypugh.
The following user(s) said Thank You: sirop

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

More
03 Nov 2015 22:19 #64700 by sirop

So with thread period of 100uS the output stops after 2419 entries if I run this script as a file.
With thread period of 1000uS the output stops after 242 entries if I run this script as a file.


That looks like a constant time (2.5 seconds).

What happens with halcmd -kf ?
You might even need halcmd -Ikf to keep the halcmd session open after the script completes.

www.linuxcnc.org/docs/html/man/man1/halcmd.1.html


Yes, this was good advice.

With halrun -Ikf halsample.hal the script yields 741538 output lines if the thread period is 100uS, and then everything "freezes"
as it seems from my ssh connection, and I have to restart my Debian wheezy.
/var/log/linuxcnc.log did not show any errors.

With the thread period of 1000uS it lasts longer, I am still waiting to see if the output stops somewhere.
More than 1000000 output lines are already there.

But anyway that was just a starting point for me as I wanted to do all these things in C.

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

More
03 Nov 2015 22:27 #64701 by andypugh

/var/log/linuxcnc.log did not show any errors.


Realtime modules can only write to /var/log/kernel.log (which you can also view with dmesg).

I have seen freezes like you mention when accidentally outputting far too much data to the kernel log, so it might be worth a look in there.
(Though, looking at the sampler.c code I don't see any rtapi_print commands in the realtime loop.)
The following user(s) said Thank You: sirop

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

More
03 Nov 2015 22:41 #64704 by sirop

/var/log/linuxcnc.log did not show any errors.


Realtime modules can only write to /var/log/kernel.log (which you can also view with dmesg).

I have seen freezes like you mention when accidentally outputting far too much data to the kernel log, so it might be worth a look in there.
(Though, looking at the sampler.c code I don't see any rtapi_print commands in the realtime loop.)


There is definetely not too much of Linuxcnc messages in /var/log/kern.log .

The nearest thing I found that could give me some hint about performance are these lines:
Nov  3 07:56:14 debian-cml2 kernel: [    1.273344] Xenomai: SMI-enabled chipset found, but SMI workaround disabled
Nov  3 07:56:14 debian-cml2 kernel: [    1.273344]          (see xeno_hal.smi parameter). You may encounter
Nov  3 07:56:14 debian-cml2 kernel: [    1.273344]          high interrupt latencies!

Indeed I have not yet properly checked all possible latency issues.

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

More
03 Nov 2015 22:58 #64706 by andypugh
Ah, Xenomai? I assume then that you are using Machinekit? You might have to ask the Machinekit chaps for help with this particular wierdness, the interaction between the realtime and userspace modules may be different there.

In that case, forget what I said about the kernel log too, that only applies to LinuxCNC.
The following user(s) said Thank You: sirop

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

Time to create page: 0.243 seconds
Powered by Kunena Forum