On 2/17/2019 8:31 AM, Damien Dando wrote:
> Hi,
> 
> Background:
> I'm building a CNC Lathe (see video here <https://youtu.be/bn6DsqG35MU>), I 
> use ClearPath motors to control Z&X axis and the spindle. Those motors can 
> be configured to give torque feedback by outputting a PWM signal. I want to 
> be able to read the torque info within Machinekit in real time so I could 
> display it but also take actions like trigger emergency stop if the torque 
> goes above certain threshold.
> 
> I have started digging in the machinekit PRU code to develop some module to 
> read a PWM signal.
> I'm not stuck and I'm confident I will eventually manage to do all what I 
> want but if some have already work with the PRU they might have some answer 
> to those question that would save me quite some time:
> 
>    - Is there some (simple) way to test the PRU binary (pru_generic.bin) 
>    separately before&without doing the integration in Machinekit? (like some 
>    script that configure the PRU/RAM shared memory the same way as 
>    the hal_pru_generic driver does?)

Just start a HAL instance and manually (or use a small HAL file or
script) load the hal_pru_generic driver with "disabled=1".  This will
load the driver and create all the HAL pins, but the PRU will be left
in the reset state.  Make sure you also specify the correct path to
your (modified) PRU binary file (prucode=<path>):

www.machinekit.io/docs/man/man9/hal_pru_generic/

Then you can use your favorite PRU debugging tool.  The only one I've
used is the HAL based "debugger" Michael Haberler whipped up in
python.  It will single-step and allow start/stop of the PRU, but
there's no support for breakpoints.  It's been enough for my needs,
since the PRU code isn't that complex:

https://github.com/machinekit/machinekit/tree/master/configs/ARM/PRU-Debugger

...but I think there are now some others available.

>    - Is there some (simple) way to build&test the hal_pru_generic driver 
>    only without (re)compiling the all machinekit?

Just tell make which file(s) you want (re)built.  You may also find it
helpful to review the Submakefile in the hal_pru_generic source tree:

https://github.com/machinekit/machinekit/blob/master/src/hal/drivers/hal_pru_generic/Submakefile

You may also want to look at the timer/capture modules, both in the
ARM system (with Linux drivers) and there's one module within the PRU
domain.  You can use these to time pulses and you will get several
orders of magnitude better accuracy (~10 nS) vs. trying to monitor the
signal with PRU software (~1-10 uS), but that may or may not be
important depending on the PWM frequency range.

-- 
Charles Steinkuehler
[email protected]

-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to