Create thread with a period other than 1KHz w/MESA

More
19 Dec 2015 20:18 - 19 Dec 2015 21:26 #67158 by photomankc
Is it possible to create any threads in the .HAL file from PNCCONF on a Mesa based config. I need a charge pump signal that is greater than 500Hz but every attempt to create a thread in my HAL file is met with LinuxCNC puking out an error that it can't load threads.ko "Unknown Symbol in Module".

I'm trying to create a 5KHz signal at least, but even 1KHz would work. 500Hz will not.


adding this to WMD30.hal is blowing it up:
loadrt threads name1=cp_thread period=100000
...
charge_pump cp_thread
Last edit: 19 Dec 2015 21:26 by photomankc.

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

More
19 Dec 2015 21:25 - 19 Dec 2015 21:25 #67160 by photomankc
I love when it's something dumb. So I was missing the "1" on "period=". It was supposed to be "period1=".
loadrt threads name1=cp_thread period1=100000

That got the thread running but then the charge pump signal went away. I noticed that the read and write tasks to the 7i43 were in servo-thread so obviously I can't output a signal faster than that. Putting the read/write tasks into the cp_thread resulted in real-time errors at startup.

Looks like the best I can do is lower the servo thread to 500,000ns netting me a 1KHz ooutput rate that seems to holding up. That gives the Microcontroller handling the CP, EStop and Control Panel LCD at least 50 counts per update to look at and enough margin to create a reasonable +/- percentage on the actual count.

Hopefully the PC can handle the 2KHz servo thread. I tried creating a 2KHz thread just for the Charge Pump and Read/Write and leaving servo at 1KHz but that was still creating RT delays. This seems to be the best I'm going to be able to do.
Last edit: 19 Dec 2015 21:25 by photomankc.

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

More
19 Dec 2015 21:41 #67162 by PCW
Another way to do this is to use a free Step generator or PWM generator to generate the chargepump signal
Then a 1 KHz servo thread is fine since its not determining the output frequency. The EPP interface method is not the
fastest and 2 KHz may be close to the limits.

This does depend on the FPGA watchdog to stop the output pulse stream if not accessed by LinuxCNC
within the watchdog timeout period, but this has been shown to be reliable for many years.

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

More
19 Dec 2015 22:29 #67163 by photomankc
Yeah, I can see that this is cutting it close to the max, the jitter is very obvious on the bench scope. I can look at the microcontroller code and see if I can change the math a bit so that the floor is below 1KHz. I would still have have 25 edges to count and +/-10 would fall within a 40% allowable deviation with the 50ms I/O loop it's using. This would likely not be an issue were I using a PCI version of the MESA card. I was not considering the need to feed the card over the parallel port which was a major "duh" moment.

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

Time to create page: 0.064 seconds
Powered by Kunena Forum