PDA

View Full Version : PWM output on CNC BOB



jolyonjenkins
23-04-2021, 02:13 PM
Hi

I have a cheap generic Chinese breakout board - like this https://www.ebay.co.uk/itm/333905827471
but it has no documentation and the listing is obscure.

It has a pin marked 0-10V PWM output, which is good - my CNC spindle controller board wants a variable DC voltage to control the spindle speed. However, I'm not at all clear how that variable voltage is produced. I'm using LinuxCNC, and the setting for the parallel port is that pin 16 is PWM output. I presume that LinuxCNC produces a high frequency square wave on pin 16, but I can't get my head round how the BOB knows that pin 16 is the one that controls the voltage on the PWM output. If if does ...

Clive S
23-04-2021, 03:04 PM
Hi

I have a cheap generic Chinese breakout board - like this https://www.ebay.co.uk/itm/333905827471
but it has no documentation and the listing is obscure.

It has a pin marked 0-10V PWM output, which is good - my CNC spindle controller board wants a variable DC voltage to control the spindle speed. However, I'm not at all clear how that variable voltage is produced. I'm using LinuxCNC, and the setting for the parallel port is that pin 16 is PWM output. I presume that LinuxCNC produces a high frequency square wave on pin 16, but I can't get my head round how the BOB knows that pin 16 is the one that controls the voltage on the PWM output. If if does ...

For the bob you are using you will have to put 12-24V on the centre two terminals ( near the relay) in order to get the 0-10V out as well. It also need the 12-24v for the inputs to work

I know this is not the same bob but it might give you a clue


# SPINDLE S
#*******************

setp pid.s.Pgain [SPINDLE_9]P
setp pid.s.Igain [SPINDLE_9]I
setp pid.s.Dgain [SPINDLE_9]D
setp pid.s.bias [SPINDLE_9]BIAS
setp pid.s.FF0 [SPINDLE_9]FF0
setp pid.s.FF1 [SPINDLE_9]FF1
setp pid.s.FF2 [SPINDLE_9]FF2
setp pid.s.deadband [SPINDLE_9]DEADBAND
setp pid.s.maxoutput [SPINDLE_9]MAX_OUTPUT
setp pid.s.error-previous-target true

net spindle-index-enable <=> pid.s.index-enable
net spindle-enable => pid.s.enable
net spindle-vel-cmd-rpm => pid.s.command
net spindle-vel-fb-rpm => pid.s.feedback
net spindle-output <= pid.s.output

# ---setup spindle control signals---

net spindle-vel-cmd-rps <= motion.spindle-speed-out-rps
net spindle-vel-cmd-rps-abs <= motion.spindle-speed-out-rps-abs
#net spindle-vel-cmd-rpm <= motion.spindle-speed-out
#net spindle-vel-cmd-rpm-abs <= motion.spindle-speed-out-abs
net spindle-enable <= motion.spindle-on
net spindle-cw <= motion.spindle-forward
net spindle-ccw <= motion.spindle-reverse
net spindle-brake <= motion.spindle-brake
net spindle-revs => motion.spindle-revs
net spindle-at-speed => motion.spindle-at-speed
net spindle-vel-fb-rps => motion.spindle-speed-in
net spindle-index-enable <=> motion.spindle-index-enable

# ---Setup spindle at speed signals--- on bob relay pin DB 17

setp hm2_7i92.0.gpio.024.is_output 1

net spindle-enable hm2_7i92.0.gpio.024.out
sets spindle-at-speed true

#Below sets position of relay contacts on power up
setp hm2_7i92.0.gpio.024.invert_output true

#PWM Generator signal/setup

setp hm2_7i92.0.pwmgen.pwm_frequency 1500

setp hm2_7i92.0.pwmgen.00.output-type 1
setp hm2_7i92.0.pwmgen.00.scale 5000
setp hm2_7i92.0.pwmgen.00.enable true

net spindle-speed motion.spindle-speed-out-abs hm2_7i92.0.pwmgen.00.value

############

It might be easier to make another stepconf junk config then copy from that junk hal file the bits you need.

jolyonjenkins
23-04-2021, 03:13 PM
Thanks.
But I don't think I've explained my confusion.
Assume the bob has the 12v in. There will be a variable DC voltage on the PWM pin. That voltage is controlled by the frequency of a signal on one of the pins, generated by linuxcnc. I can use stepconf to assign the pin that produces the signal. But how does the bob know which pin to expect the on?

Clive S
23-04-2021, 03:16 PM
Thanks.
But I don't think I've explained my confusion.
Assume the bob has the 12v in. There will be a variable DC voltage on the PWM pin. That voltage is controlled by the frequency of a signal on one of the pins, generated by linuxcnc. I can use stepconf to assign the pin that produces the signal. But how does the bob know which pin to expect the on?

You have to tell Lcnc which pin to send it to.

Can you post the config

#### Spindle stuff ###

net spindle-cmd-rpm => pwmgen.0.value
net spindle-on <= spindle.0.on => pwmgen.0.enable
net spindle-pwm <= pwmgen.0.pwm
setp pwmgen.0.pwm-freq 100
setp pwmgen.0.scale 1000
setp pwmgen.0.offset 0.1

setp pwmgen.0.dither-pwm true

net spindle-cmd-rpm <= spindle.0.speed-out
net spindle-cmd-rpm-abs <= spindle.0.speed-out-abs
net spindle-cmd-rps <= spindle.0.speed-out-rps
net spindle-cmd-rps-abs <= spindle.0.speed-out-rps-abs
net spindle-at-speed => spindle.0.at-speed
net spindle-cw <= spindle.0.forward

### Parport Pins ###
setp parport.0.pin-01-out-invert 1
net spindle-pwm => parport.0.pin-01-out These are the pins on the bob
net spindle-cw => parport.0.pin-14-out
net spindle-on => parport.0.pin-17-out

jolyonjenkins
23-04-2021, 03:20 PM
But how do I know which pin to send it to? I'm assuming that the bob is looking for a signal on a particular pin, which is determined by the hardware of the board. I don't have a problem with configuing Linuxcnc, but I don't see how I know which pin the board wants. I feel I am either missing some concept or being very stupid.

jolyonjenkins
23-04-2021, 03:27 PM
But how do I know which pin to send it to? I'm assuming that the bob is looking for a signal on a particular pin, which is determined by the hardware of the board. I don't have a problem with configuing Linuxcnc, but I don't see how I know which pin the board wants. I feel I am either missing some concept or being very stupid.

magicniner
24-04-2021, 10:39 AM
I feel I am either missing some concept or being very stupid.

You are in the process of learning why cheap hardware is cheap and that some of what you are paying for with better, more expensive products is adequate documentation and support ;-)

Doddy
24-04-2021, 10:52 AM
The BoB has a hard-wired interface from one of the discrete outputs (I have a similar board, that's silk-screened "P1 - PWM" - so pin 1 is assigned by hardware design to the PWM circuit. No configuration, no nothing (you could hack the card, of course). There's nothing clever, just assign the same output in LinuxCNC to the hardwired assignment on the board.

Most BoBs are similar.

jolyonjenkins
24-04-2021, 10:58 AM
The BoB has a hard-wired interface from one of the discrete outputs (I have a similar board, that's silk-screened "P1 - PWM" - so pin 1 is assigned by hardware design to the PWM circuit. No configuration, no nothing (you could hack the card, of course). There's nothing clever, just assign the same output in LinuxCNC to the hardwired assignment on the board.

Most BoBs are similar.

Thank you! That was the information I was after

Paul H
24-04-2021, 11:12 AM
Hi
One thing to watch out for: check that your inverter to control the spindle is isolated from the mains that is to say the the 0 to 10v input is not at mains potential.. this should described in you manual for the inverter...
could be serious risk of electrical shock and the magic smoke will appear...

Best regards
Paul

jolyonjenkins
24-04-2021, 07:26 PM
You are in the process of learning why cheap hardware is cheap and that some of what you are paying for with better, more expensive products is adequate documentation and support ;-)


Not the MOST helpful and specific piece of advice :-) I didn't buy this board, it came with a mill that someone else had retrofitted, and I am well aware of the danger of cheap hardware.
I did find a manual for it

https://www.dropbox.com/s/gfq4isvihnpsr9l/5axis_breakout_board-EN.pdf?dl=0

which I hope someone in the future might find useful

Paul H
24-04-2021, 08:10 PM
Hi jolyonjenkins
Thanks for posting the BoB PDF i use these boards on my Boxford HMC160 CNC mill and Denford CNC Starturn lathe and they have performed well...
makes things easier...

Best regards
Paul

ZASto
25-04-2021, 09:51 AM
Here is the manual for your BOB: https://warp9td.com/images/BOB_Vendors/StepperOnline/ST-V2.pdf

dazp1976
25-04-2021, 01:16 PM
I use these boards too. No issues. Pin 1 is the 0-10v / pwm, pin 17 is the on/off relay. You can then assign fwd/rev to pins 8,9 or16.
Board needs BOTH 5v and 12-24v psu's connected to the relevant inputs in order for it to work fully.

ONE THING TO WATCH. When I tried my output 1 it was backwards. So 10v was at stop and 0v was at max. Had to change active in Mach. Luckily I tested it with a voltmeter first lol.

jolyonjenkins
08-05-2021, 07:49 PM
I'm probably being stupid here, but - I assume the relay is for switching the spindle on and off. At the moment I'm just getting my steppers to work, and testing with Linuxcnc and the stepconf wizard. All the steppers are working, but every time I click on "test this axis" the relay comes on, even before I jog the axis. Why is this? When using the machine for real, I would only want the relay to come on when I want the spindle on, not when moving an axis. I don't have the 24V supply connected atm, if that is relevant

Clive S
08-05-2021, 09:08 PM
Can you post your hal and ini files

Also what Bob are you using and version of Linux

dazp1976
08-05-2021, 10:01 PM
I'm probably being stupid here, but - I assume the relay is for switching the spindle on and off. At the moment I'm just getting my steppers to work, and testing with Linuxcnc and the stepconf wizard. All the steppers are working, but every time I click on "test this axis" the relay comes on, even before I jog the axis. Why is this? When using the machine for real, I would only want the relay to come on when I want the spindle on, not when moving an axis. I don't have the 24V supply connected atm, if that is relevant

Pin17 is the relay.
If you have seperate on/off & direction controls on the vfd:
Ports and pins I would suggest:
Spindle assign- step=pin 1, Dir=pin 16
Output #1 = pin17
Assign M3/M4 to output #1 (for on/off spindle)
Use pin16 for forward/reverse (I'd use a relay set up as NO=fwd / NC=rev)

Pin1 is the 0-10v/GND pins connected below where you plug in the 12-24v supply
Pin1 and all the other limit/estop inputs only work with this supply connected.
If you find that the ouput pin1 is 10v when stopped, change the active low/high level.


The relay also has a jumper next to it so you can change the output from the relay to screw terminal 17 instead.
Something like this anyway

jolyonjenkins
09-05-2021, 04:18 PM
Here are my hal and ini files (I had to rename them as txt files to get them to upload).

The limit switches are all connected to machine ground except when they are pressed.
The estop switch is connected to ground if the machine is on, except when the button is pressed.

The steppers will all jog OK in stepconf. When I select an axis to test in stepconf, the BOB relay comes on (WHY?). When I run linuxcnc, the orange ON button is greyed out, even if I invert the estop input.

Should the limit switches and estop switches maybe be pulled high with resistors?

Doddy
09-05-2021, 04:31 PM
Net xenable? - that's connected to par-port pin 17.

dazp1976
09-05-2021, 04:55 PM
Net xenable? - that's connected to par-port pin 17.

That'll be why the relay is coming on when steppers asked to move.

dazp1976
09-05-2021, 05:00 PM
I'm probably being stupid here, but - I assume the relay is for switching the spindle on and off. At the moment I'm just getting my steppers to work, and testing with Linuxcnc and the stepconf wizard. All the steppers are working, but every time I click on "test this axis" the relay comes on, even before I jog the axis. Why is this? When using the machine for real, I would only want the relay to come on when I want the spindle on, not when moving an axis. I don't have the 24V supply connected atm, if that is relevant

Change Enable to pin 14 and move any enable wiring there.
Then assign Enable1 as pin14 in Mach.
That should solve relay issue.
Looks like you have enable on pin17.

Then.
Pin17 is the spindle relay.
If you have seperate on/off & direction controls on the vfd:
Ports and pins I would suggest:
Spindle assign- step=pin 1, Dir=pin 16
Output #1 = pin17
Assign M3/M4 to output #1 (for on/off spindle)
Use pin16 for forward/reverse (I'd use a relay set up as NO=fwd / NC=rev)

Pin1 is the 0-10v/GND pins connected below where you plug in the 12-24v supply
Pin1 and all the other limit/estop inputs only work with this supply connected.
If you find that the ouput pin1 is 10v when stopped, change the active low/high level.

jolyonjenkins
09-05-2021, 06:42 PM
Ah, thanks. That sorted it

jolyonjenkins
10-05-2021, 05:56 PM
I have another problem. When the machine is on, but the computer is off, pin 17 (the relay) goes high and so the relay switches on. Do I need to pull it low?

dazp1976
10-05-2021, 08:11 PM
I have another problem. When the machine is on, but the computer is off, pin 17 (the relay) goes high and so the relay switches on. Do I need to pull it low?

If you pull it low the relay will just work backwards.

You should always have Mach pc in control BEFORE you turn on the controllers themselves.
When finished. Turn off controllers first, then shut Mach pc down.

I used to get a relay flicker when powering on the pc, that was when I used usb for my 5v input.
I now use a seperate supply into the 5v & gnd terminals on the bottom row of the board for isolation.

jolyonjenkins
10-05-2021, 08:32 PM
I find it a bit odd that it defaults to being high. I'm not sure if it's just floating up or whether this is intentional.
It it's floating, then a resistor ought to pull it down. I can't see that it will make the relay work backwards in any case.
I also use a separate PSU for the logic 5V, not from the computer.

dazp1976
12-05-2021, 01:38 AM
I find it a bit odd that it defaults to being high. I'm not sure if it's just floating up or whether this is intentional.
It it's floating, then a resistor ought to pull it down. I can't see that it will make the relay work backwards in any case.
I also use a separate PSU for the logic 5V, not from the computer.

Those relays can be a bit of a chore. I never used it due to hearing it clicking away on startups.
There is a jumper next to the relay, so:
What I did is change the jumper setting so it uses pin17 screw terminal instead of the onboard relay for spindle on/off.
Got a seperate 5v relay with NO/ COM /NC contacts and hi/low trigger option and conect it to pin 17 output.

When PC is off mine sits in NC position. It will not trigger unless it has signal. Spindle switch is connected to NO. It only turns on spindle if Mach activates pin17 via 'spindle on/off'' button. It will NOT come on unless pc is on with mach running.
This will solve the problems.
I actually have a servo drive for mine. It's setup as: Pin17 is my on/off, Pin16 is my direction control.

Relay like this one below.
https://www.amazon.co.uk/Electromech...732588&sr=8-19
You can get them cheaper, this was just for quickness. Made more sense to me to buy multiple channel ones.
Being able to choose between high or low trigger I found quite useful.

Mine is an eight channel module. I have a few things with 5v negative to the trigger (jumper low). Also have a few things with 5v positive to the trigger (jumper high). Everything works perfectly with either polarity acting as triggers (as long as you set the jumper correctly). Great versatile little units :)