Introduction
I am looking into replacing the stepper motors on my motion control head with PID controlled DC motors. This should allow me to make improvements in terms of noise produced by the steppers, and speed. I have previously done some experimenting with PID loops with the Arduino mega and found that although I could get the system working, the board is only really fast enough to run only the PID loop, and not the full firmware.
Therefore I am designing a small custom board which can run one or two axes and be controlled either by I2C or by Step/Dir pins. This should allow the board to be used with other Arduinos, generic 3D printer controllers, most CAM controllers, or by the MiniE motion control engine.
Design Spec
- This project uses an atmega328p (the same chip from in the arduino uno) for closed-loop control of a pair of DC-motor.
- Motor motion is detected by a quadrature encoder for each axis.
- Encoder counting is managed by single purpose IC (LS7366R).
- Two inputs named STEP and DIR allow changing the target position for each motor.
- I2C port allows target position to be changed for both axes.
- Serial port prints current position and target position every second.
- Change PID values using serial port.
- All unused pins broken out to provide expandable functionality.
- Motor driver can control up to two DC motors at a constant current of 1.2A (3.2A peak).
- Built-in thermal shut-down circuit and low voltage detecting circuit
- Power supply voltage: VM=15V max
- Count frequency: 40MHz
Relevant reading
https://www.youmagine.com/designs/dc-motor-closed-loop-control-software
https://github.com/misan/dcservo/blob/master/dcservo.ino
https://github.com/danithebest91/ServoStrap
Previous tests
I did a quick test and got a working PID closed loop controller working. Although as you can see in the videos it is clearly unstable and needs to be tuned.
While doing this I worked out a couple of tricks, most importantly that you need to manually alter the pwm frequency of the arduino to operate at a higher frequency too avoid an audible ‘pwm buzz’ from the motor casings.
Arduino PID controller for DC geared motor from Steven Brace on Vimeo.
04/01/2016
Did a quick schematic in DipTrace and have most of the components placed although there are still a couple more things to iron out.
Communication protocols
- Scalable to allow for more OSDs
- Only 2 wire
- Faster than serial
- OSD cannot be master and slave SPI at same time.
- fastest system, allows many loops of PID
- Already supported by counter ICs
Assigned pins
[ ]Connector for I2C in.
[ ]Connector for serial coms.
[ ]Sharing clock for all ICs, good idea?
[ ]Change ICSP connector to correct header
[ ]Step direction inputs to mirror miniE
[ ]scaling pot?
More to come!
i gonna same thing insted LS7366R i am gonna use another atmega that work as encoder buffer and send encoder count over spi so things will be cool i need your code to do this it will be very helpful to me