When user access webpage of PHPoC Blue from a web browser on Smart Phone or PC, a WebSocket connection will be created between PHPoC Blue and web browser. WebSocket connection allows to real-time exchange data between web browser and PHPoC Blue without reloading webpage.
When user rotates the needle on webpage, the rotated angle will be send to PHPoC Blue. PHPoC Blue convert angle to the equivalent position (unit is pulse), and then use PID algorithm to rotate DC motor the equivalent position.
PID library for PHPoC is available here. It also contains auto-tuning function for both position and speed.
Angle to Position CalculationAssumption:
- Incremental Encoder Resolution (counts per revolution): ENC_RESOLUTION
- Gear Ratio: GEAR_RATIO
Signal from Encoder will be decoded by PHPoC DC Motor Controller. PHPoC DC Motor Controller acts as Quadrature Decoder, which will quadruple (x4) the number of pulses per revolution.
We have:
- a revolution <=> 360 degree <=> ENC_RESOLUTION * GEAR_RATIO * 4
- angle <=> position
=> position = angle * ENC_RESOLUTION * GEAR_RATIO * 4 / 360
The motor I used have:
- ENC_RESOLUTION = 13
- GEAR_RATIO = 100
=> position = angle * 13 * 100 * 4 /360
(see line 75 of task0.php)
Wiring- Stack DC motor controller on PHPoC Blue or Black
- Connect DC motor to DC motor controller (see User Manual of DC motor Controller)
Comments