The BOB PID is a very low cost, but quite capable, PID servo controller,
which can replace stepper motors in any standard application, such as 3D
printers or CNC machines.
Serial and step / direction inputs.
- The serial interface, via any
TTL to
USB adapter, allows for easy tuning of the P.I.D. constants and setting
options like the polarity of the output direction signal. It also supports
a
bootloader^
for future firmware updates and new abilities /
optimisation.
- The PMinMO Standard Step / Direction input
allows it`s use in any application where a standard
stepper driver was intended. Our
Pololu
adapter cable makes plugging it into a RAMPS / GRBL or pretty much any
other motion controller very easy.
Position input comes from a standard
quadrature type position
encoder, like our non-contact, high
speed magnetic ENC connected to the motor shaft. Up to 73,000 edges per
second or 18,000 lines per second are supported with the current
0.93 firmware. That supports up to 1,095 RPM with
a 1000 line (4k quad) encoder (73K/4K*60), or over 12,000 RPM with our 360
quad ENC2 (73K/360*60).
TEMPORARY: To tune the PID controller for your motor and load, you will need
a USB to TTL serial converter. e.g. FTDI friend, etc... Our
RLC3 works nicely. 416063
OPTIONAL: +5 volt regulator parts. The BOB PID needs +5 volt logic power
from somewhere... But that can come from many sources:
The USB-TTL adapter can provide +5 from USB while it's attached to your computer
for tuning the PID constants. If you have a spare USB power adapter, just
plug it into that after you are done.
Or, if you are using some other driver, and it doesn't put out +5 volts,
you can supply +5 volt power form your own source.
Or, you can order the regulator parts and install them on the BOB PID so
it can make +5 from your motor power supply.
416025
NOTE: If these options are confusing, please reivew the
Servo block diagram to see how they all fit
together.
Note: Most components are installed on the underside of the PCB... The side
with "U1 PIC"
Z-axis
Pin
Signal from BOB PCB All even pins are ground
1 "E"
/Enable
3 "D"
PWM Drive (not direction)
5 "S"
Direction (not step)
7 "-"
Ground
9 "+"
+5 Logic power (if needed)
Motor Driver Output via Z Axis cable
[ ] Install a 10 pin 2x5 header over the Z axis on JP3. On the boards underside,
this is the 2nd from the right block of 2x5 pins in JP3 with "Z" just below
it. Note that we swapped the standard functions of Step / Direction to support
the PIC. For a PMinMOstepper driver,
you must swap pins 2 and 3 in the cable. Our
MassMind H-bridge driver has those pin
swapped, for a straight cable.
X-axis
Pin
Signal from BOB PCB All even pins are ground
1 "E"
/Enable (JP3 square pad )
3 "D"
Direction
5 "S"
Step
7 "-"
Ground
9 "+"
+5 Logic power (if needed)
Step / Direction input from motion
controller via X Axis cable (if desired)
[ ] Install a 10 pin 2x5 header over the X axis on JP3. On the boards underside,
this is the far left block in JP3, starting from pin 1. This is
PMinMO standard, so our
Pololu adapter cable works nicely.
J2
Pin
Signal to BOB PCB
1
+5 Logic power (if needed)
2
CTS (unused)
3
Ground
4
TX <- USB/Host
5
RX -> USB/Host
Serial Console: To talk to the controller via USB - TTL serial
(Required to set the PID constants):
[ ] Install J2 RLC header for USB / serial
communications to a host. The host is used to tune the PID loop, provide
motion commands for test or use, and update firmware via the bootloader.
Note that pin 4 TX is data FROM the USB/Host going TO the PID controller.
RX is TO Host FROM PID.
[ ] Install a 1x6 (or 1x5, pins 6 & 1 share +5) header over the holes
for the Z and Y LEDs. (see picture) The polarity tab should be towards the
outside edge of the PCB and if a 1x5, it should be slid down to
use the square pad toward the lower edge, near "D7" on the underside,
of the PCB. See the picture below. This brings power, ground, and data lines
originally for those LEDs out for a
Quadrature Encoder; we can
those data lines as inputs instead. The cable for the
MassMind Encoder ENC2 is shown:
(see also for
ENC1)
[ ] Install C4 (upper right corner, not shown in photo) and C7 (just left
of U1 "PIC") to ensure stable power and avoid unexpected resets. Despite
the value indicated on the PCB, C4 can be any good sized electrolytic capacitor
(e.g. 220uF to 1000uF). Note it's long lead should be installed in the square
pad nearest the "+" and just above and right of "C4".
[ ] Install JP4 and JP5 on the under side of the PCB, about an inch from
the left, just below U1. See left bubble in picture.
[ ] Install a jumper over the RP2 LED network from STEP Y to the corresponding
pin on the bottom side of RP2. See right bubble in picture.
[ ] Install a jumper sideways over RP2 from STEP A to the pin NOT
directly on the other side of RP2, but one place over, towards the Y jumper
you just installed. See right bubble in picture.
[ ] The PIC 18F14K22 is installed as U1 PIC on the bottom side center left.
The notch on one end of the chip should match the notch on PCB and face the
U1 PIC text. Be sure it is programmed first
(Source code in github).
The chip provided with the kit is already programmed and includes a bootloader
for future firmware updates.
The PCB can be mounted to any surface with standoffs. The mounting holes
are at these locations, measured from the left and bottom of the PCB (right,
up)
ERROR FEEDBACK: OPTION. If you will want error feedback to your
motion controller:
[ ] First be very careful that it can accept an error signal on pin 7 of
the PMinMO connector. This pin is normally grounded,
and so it will make any error much worse if we activate a short to ground.
Connect a low value resistor over the "X" just above U1 on the underside
of the PCB.
ERROR LED: OPTION. For an error indicator, this LED will light
if the controller looses track of a shaft which is spinning too fast:
Install an LED with long lead in the A2D pin of J12 (lower edge of PCB) and
the short lead in the hole just right of that. Keep the short lead long,
and bend it over to also connect to J12 pin 1 (far right of J12) where a
low value resistor (e.g. 330 to 560 ohms) should be installed with it's other
lead in one of the GND pads of J11. (see center bubble in picture above)
Operation
TTL Serial 38400 N 8 2 X-ON/X-OFF: Connect a
USB (or
RS-232) to TTL serial converter to the
J2 connector. e.g. FTDI Friend, RLC3 Again,
pin 4 "TX" is data FROM the USB/Host going TO the PID controller. RX is TO
USB/Host FROM PID controller. Configure your serial terminal program (e.g.
Hyperterm, RealTerm, PuTTY, etc...) for whatever COM/TTY port shows up, and
38,400 baud, No parity, 8 data bits, and 2 stop bits. Select X-ON / X-OFF
handshaking if available.
Video
Note: The pre-programmed chips come with a bootloader installed. On power
up, the serial connection will display a countdown in order to give time
for the user to go into the bootloader mode if desired. Just wait for the
countdown to finish for normal operation. If the screen fills up with "!"
the magent isn't placed correctly.
Commands:
e Enable. On startup the unit will NOT drive the motor, until it
is enabled. This also resets any position error, so the motor should not
move.
{space} Disable. To stop the motor at any time, just hit the space
bar. This also disables tracking of the hardware input enable line.
#p, #i, #d Set the constant to the value entered.
For example, to set the p term to 14, enter 14p To set I to 0.1,
enter .1i. Always use lower case (it's faster) and always enter
the value first, then the letter. These settings only last as long
as power is on, unless you save them into non-volitile memory.
216w Set Direction to positive high, negative low
286w Set Direction to positive low, negative high
60w Make the motor enable track the step/direction input motor enable
line
50w Make the motor enable NOT track the step/direction input motor
enable line. {space} also does this and disables the motor.
#s (since v0.92) Set the number of steps per each step input pulse.
e.g. 10s changes the setpoint by 10 positions each step.
1s is a one to one step to position setting.
#v (since v0.95) Set velocity for move commands from terminal. Like
s but internal. Applies v positions per 1/200th of a second from setpoint.
321w Save settings / constants in non-volitile memory. Once direction
is set, the PID tuning is done, and input enable tracking set, saving the
settings allows you to remove the console cable and just operate from the
hardware step/direction input.
#{enter} Move to the location entered. e.g. to move to 100, enter
100 and press enter. To go to 1, press 1. For negative values, put the minus
sign at the end, not the start, of the number. e.g. to move to -20, type
20-{enter}. The total range is double... 1.17549435 e-38 to 6.80564693
e+38 with 32 bit precision.
Start by entering very small values for pid. e.g. .01p.01i.01d then
hit e to enable the drive and see if the motor moves at all. If
not, try increasing p until the motor just moves a bit when you hit
space and then e again or when you twist the shaft away from the home position.
If you are getting up to 1p and the motor isn't turning, something is wrong
with the enable or driver or wiring.
Once the motor starts turning, it may go in the wrong direction, which will
make the error get worse and worse. Hit space, then put in
216w and enter then e again. If the motor still just spins,
try space, 286w and e. The motor should just jump
slightly when you hit e and should hold position loosely. E.g. you should
be able to twist the shaft quite a bit and the motor should try to resist
you a litte and move back to home. Enter 321w to save the settings.
Now increase p and tweak the motor shaft until it just starts oscillating.
Set p to about half that value. Estimate the number of osciallations per
second and set d to that frequency divided by 8. Set i to less than the frequency
divided by 2. This is a good starting point. Continue with our
PID Tuning / Troubleshooting page.
Troubleshooting
On power up, after enable, the motor runs continuously in one direction
or the other.
The polarity of the direction signal is backwards. Use the Set Direction
commands (above) to make it zig or zag as it should. MD
On power up, after enable, the motor holds position in one direction
only. If you push it against the correct position, it will resist, but
will then go dead as soon as it moves away from the set point.
The Step / Direction lines from the controller to the driver are reversed.
Step is feeding direction and direction is feeding step.
The motor oscillates, moves slowly, shudders/grinds, or generally moves
but not well.
The error LED comes on, or the serial console shows "!", or the motor looses
it's position
1.The encoder is putting out invalid phase A and B signals. The
MassMind ENC1 Encoder will do this
if it looses track of it's magnet. Recheck the positioning of the magent.
2. The PID controller isn't able to keep pace with the encoder. Please measure
the RPM of the shaft if possible and contact us with this information. A
firmware update may become available to improve speed.
Movement works ok from the serial console, but the step / direction interface
has no effect. Especially when the step and direction signals are open collector
You will need to provide 1K ohm pull up to logic power from each signal.
Output motor enable can now track the hardware input enable line from the
step direction interface.
- This is disabled by default
- Enable with command 60w, disable with 50w or {space} which is still the
e-stop
Baudrate is 38400 to match the bootloader
The code can be bootloaded
Add "hello world" message to make it clear when the bootloader is done.
0.92 Step size / Faster
A new parameter 's' can be set for the size of each step from the step/direction
input. e.g. 10s changes the setpoint by 10 positions each step. 1s is a one
to one step to position setting.
The initial versions just used doubles for everything and that was really
slow in the interrupt routine for the encoder and step/direction inputs.
This code moves to integers (longs... 32 bits -2,147,483,648 to +2,147,483,647)
for the position and setpoint which should support much faster rotation and
higher resolution encoders; up to 360 line 1440 quad.
0.93 Faster! More Sensitive
By increasing the clock speed from 16 to 64MHz, 4x faster operation is possible
allowing support for up to 1000 line, 4,000 quad encoders
Fixing a bug in the PWM output routine (was always multiplying PWM by 10)
both increased the update speed and improved sensitivity. Known issue: Step size parameter is not saved to eeprom.
0.94 (not released)
Actually save the step size parameter
Faster processing of step input, slightly faster encoder processing. Just
track error, vs Setpoint - encoder_counter.
Note: Step/Direction input is now relative.
Calculation of Derivative and Integral terms changed. May need to re-tune
0.95 Improved User Interface, Faster!
Just one "!" per encoder overrun; avoid buffer overrun
Add version / status / settings as "?" command
Let the user know they need to enter 321w to save
Past MAX_ERROR, disable and suggest other direction
Movements via serial command have a max velocity 'v'
Setpoint is now relative, always returns to 0, no wraparaound jerk
Smaller datasizes (short long, 24 bits) used for most variables, faster
Derivative and Integral terms changed. May need to re-tune. EEPROM Version
'4'
BugFix: Avoid PIDerror changing during calculations. Can cause small random
jerks.
Comming attractions (new features wish list). If you see something
you really want, let us know.
Support for RC servo output (100Hz PWM with zero at 1.5mS, reverse at 1mS
and forward at 2mS) so we can support ESC's for BLDC motors. This may not
work with all ESCs, but it's worth trying. Some of the new ESC's can manage
small movements quite well.
Support for 0 to 10 volt analog output instead of just 0-5v PWM using the
relay driver circuit on the BOB PID. This is just a hardware mod. Do anyone
have a 0-10 volt input servo driver / motor to test on?
Tuning mode with frequency and oscillation of whatever size the last movement
was. E.g. you hit 10t 1000 and it moves back and forth by 1000 clicks every
10 seconds. Then you can just enter tuning parameters and quickly see the
results.
Binary error reporting mode / program. This will just transmit a single byte
over and over again whose value will be proportional to the current error.
A program on the PC will receive this data and plot it, allowing you to see
exactly what the error is over time. Combined with the Tuning mode, it will
make accurate tuning much easier.
Autotune program. This will use the error reporting and the tuning mode to
automatically adjust the PID values for the best movement.
DRO mode. Output of the current position in engineering units on a large
display or web page.
/Techref/io/SERVO/BOBPID.htm
Another typo on this page: To the right of where it says Step/Direction input from motion controller there is a box labeled X-axis Pin. It reads "Signal from BOB PCB" and it should say "Signal to BOB PCB" I think? I'm curious if the BOB PCB board is getting it's 5 volts from the grbl shield through the PMinMO adapter cable I purchased from you? I don't have your controller board working yet. The grbl shield works to drive steppers with a PMinMO driver in the socket but the drive I built from your kit has no lights lit when powered up. The error light on the BOB PID flashed for a second when motor power is applied. The BOB PID boards error light will also come on if I rotate the motor shaft by hand in either direction.
James Newton of MassMind replies: I guess it makes more sense to have that say "to" instead of "from", thanks for the feedback. The BOB PID needs logic power from somewhere and it can get it from the DC motor driver, or from the motion controller or whatever.
https://youtu.be/Wxd9-VgvRpI Running
from RAMPS/Marlin with a SyRen 25 Amp
Driver or SyRen 50 Amp Driver: (NOT
the Sabertooth dual units)
The trick is to use Option 3 "Analog One-Direction with foward/reverse select
on S2" That is, on the DIP switch 1,2,3 ON, 4,5 OFF, 6 ON.
From the SyRen to our motor connector:
- S1 to Z axis pin 3 "D", the PWM Drive
- S2 to Z axis pin 5 "S", Direction signal
- 0V to Z axis pin 7 "-", Ground