PWM on the PBX-BB to control spindle motor

166 views
Skip to first unread message

Stuart Childs

unread,
Jun 15, 2015, 9:59:54 AM6/15/15
to machi...@googlegroups.com

Hi all, after getting the BBB with PBX-BB set up and controlling XYZ nicely (thanks for the help, Charles) my attention has turned to getting PWM spindle control working.


Intended setup: connect A-axis STP/DIR/ENA to one of the spindle v5 DIYCNC spindle control boards: http://www.diycnc.co.uk/html/spindle_boards.html.


As far as I know this will allow me to use the A-axis output from PBX cape to control the v5 spindle board which in turn will turn the spindle drive board on/off using onboard relay and control spindle speed from step signals (converted to 0-10V which will control the spindle drive board, a Sprint 400 from existing control cabinet).


I am not currently using X/Y/Z enable pins but think I need to use A enable to trigger RUN on the v5 spindle board.


Looking at the linuxcnc config page this looks close to what I need to use:


http://linuxcnc.org/docs/html/examples/spindle.html#_pwm_spindle_speed


I am having some trouble working out how to implement this on the BBB/PBX.


- Do I need to use pwmgen rather than stepgen?


- Do I need to modify setup.sh to define the pins as anything other than 'low' ?


- Looking at the pinmux.ods from Charles, I'm not sure which pins I need to use (I think 811 / 812 / 813)


When I try to add something like 'setp hal_pru_generic.pwmgen.00.out.00.pin 813' to the hal file I get an error when trying to load linuxcnc that parameter or pin [aforementioned] not found


Current config files are here (without modifications for a axis spindle control):


https://github.com/abopen/cnc-configs/tree/master/Novamill



Can somebody please point me in the right direction / suggest a good place to start?


I appreciate that wiring / hardware is hard to diagnose from a distance but once I get a soft config working and can probe the HAL monitor etc I can work from there – I just can't get linuxcnc to start with anything that feels like I might have enabled or added spindle control to my configs.


Cheers

Stuart

Charles Steinkuehler

unread,
Jun 15, 2015, 10:54:55 AM6/15/15
to machi...@googlegroups.com
On 6/15/2015 8:59 AM, Stuart Childs wrote:
>
>
> Hi all, after getting the BBB with PBX-BB set up and controlling XYZ nicely
> (thanks for the help, Charles) my attention has turned to getting PWM
> spindle control working.
>
>
> Intended setup: connect A-axis STP/DIR/ENA to one of the spindle v5 DIYCNC
> spindle control boards: http://www.diycnc.co.uk/html/spindle_boards.html.
>
>
> As far as I know this will allow me to use the A-axis output from PBX cape
> to control the v5 spindle board which in turn will turn the spindle drive
> board on/off using onboard relay and control spindle speed from step
> signals (converted to 0-10V which will control the spindle drive board, a
> Sprint 400 from existing control cabinet).
>
>
> I am not currently using X/Y/Z enable pins but think I need to use A
> enable to trigger RUN on the v5 spindle board.
>
>
> Looking at the linuxcnc config page this looks close to what I need to use:
>
>
> http://linuxcnc.org/docs/html/examples/spindle.html#_pwm_spindle_speed
>
>
> I am having some trouble working out how to implement this on the BBB/PBX.
>
>
> - Do I need to use pwmgen rather than stepgen?

The board you linked to looks like it wants step/dir, so I wouldn't
recommend using pwm. But you do probably want to run the spindle
stepgen in velocity mode.

> - Do I need to modify setup.sh to define the pins as anything other than
> 'low' ?

You shouldn't. The main thing to get correct in the setup script is
the direction of the pin and maybe the initial state of the output pins.

> - Looking at the pinmux.ods from Charles, I'm not sure which pins I need
> to use (I think 811 / 812 / 813)

That seems likely. The pin functions depend on how you hook up the
PBX-BB, and if you're running with two Y motors. Look at the
schematic on the Probotix site if you're not sure which pins you want
to use.

> When I try to add something like 'setp
> hal_pru_generic.pwmgen.00.out.00.pin 813' to the hal file I get an error
> when trying to load linuxcnc that parameter or pin [aforementioned] not
> found

You've got two problems:

1) There won't be any pwmgen pins unless you configure some (ie: pass
num_pwmgen=<number> when you load the PRU driver). If you need any
pwm channels, modify the CONFIG string in your ini file:

https://github.com/abopen/cnc-configs/blob/master/Novamill/Novamill0.ini#L8

2) The hal_pru_generic prefix is deprecated (it caused HAL names that
were too long). The new default prefix is hpg, as set by the halname=
setting when loading the driver:

https://github.com/abopen/cnc-configs/blob/master/Novamill/Novamill0.hal#L16

--
Charles Steinkuehler
cha...@steinkuehler.net

Stuart Childs

unread,
Jun 16, 2015, 9:08:21 AM6/16/15
to machi...@googlegroups.com
Hi Charles,

Understood re: hpg rather than hal_pru_generic! After having that problem before I might have spotted it.

I found the documentation on the HAL here very useful:

https://github.com/machinekit/machinekit-docs/blob/master/machinekit-documentation/index-HAL.asciidoc

I now have ini and hal files that allow control of spindle speed with stepgen and spindle on/off from gpio as planned. Great!

Some work still to do regarding scale of speed of spindle, I am not convinced I have this configured correctly yet.

Also not convinced about having two lines (https://github.com/abopen/cnc-configs/blob/master/Novamill/Novamill0.hal#L125   +126 ) needed for spindle on/off control, but found that commenting out one or the other stops me being able to control from EMC.

I have tidied up the files and pushed to Github here:

https://github.com/abopen/cnc-configs/tree/master/Novamill

Going to take another break from it and have a look in a day or two. For me fresh eyes often helps.

Cheers again for the help!

Stuart
Reply all
Reply to author
Forward
0 new messages