This project is similar to my other project. Instead of using Stepper Motor Controller (using Full-step or Half-step method to control step motors), this project used the stepper motor controller Ⅱ (using micro-stepping method to control step motors). The micro-stepping method makes the step motor move smoother and significantly reduces the vibration in comparison with full-step and half-step method (vibration is one of weaknesses of step motors).How It Works
When a finger touches to the drawing area in webpage, the XY coordinate of touching point is sent to PHPoC. After scaling the coordinate, PHPoC will move two step motors to locate the pen to that coordinate. During moving period, PHPoC continuously sends trajectory of the pen to web app, the web app draws the trajectory on the canvas.Wiring
- Stack two step motor controllers on PHPoC
- Connect to servo motor
- Connect to limit switches.
This project uses two motors and two step motor controllers:
- One step motor and one step motor controller controls left-right direction (X-axis). This step motor controller needs to connect to two limit switches attached on left and right side of XY-Plotter. Left-switch to SW#1, right-switch to SW#0.
- One step motor and one step motor controller controls up-down direction (Y-axis). This step motor controller needs to connect to two limit switches attached on top and bottom side of XY-Plotter. Bottom-switch to SW#1, top-switch to SW#0.
Note that: we only use SW#0 and SW#1. We don't use SW#2 and SW#3 as in imageSource Code
Main task (task0.php):
- Receiving the command from webpage and do task according to command
- CMD_MOVE: move pen to a position by controlling two step motor
- CMD_PEN_UP: raise the pen by changing the angle of servo motor
- CMD_PEN_DOWN: lower the pen by changing the angle of servo motor
- Continuously read the current position of pen and send to webpage
Web interface (index.php)
- Providing the user interface
- Handling the user event and send command with coordinate to PHPoC
- Receiving the trajectory from PHPoC and draw it on webpage