If you are new to Arduino, you can get started with Arduino Tutorials for newbie.
How It WorksWhen user access webpage of PHPoC [WiFi] Shield from a web browser on smartphone or PC, a WebSocket connection will be created between Arduino and web browser. The WebSocket connection allows for the real-time exchange data between web browser and Arduino without reloading webpage.
When user rotates the plate on webpage, the rotated angle will be send to Arduino. Arduino convert angle to the equivalent number of steps, and then move step motor to the equivalent position.
Angle to the Number of Step Calculation
Assumption:
- Angle per step: ANGLE_PER_STEP. This value is got from motor specification.
- Angle per mirco-step: ANGLE_PER_MICRO_STEP = ANGLE_PER_STEP / MICRO_STEP_MODE
=> the number of micro-step = angle / ANGLE_PER_MICRO_STEP
The motor I used: ANGLE_PER_STEP = 1.8
The mocro-stepping mode I used in this code : MICRO_STEP_MODE = 32
Wiring- Stack PHPoC Shield or PHPoC WiFi Shield on Arduino
- Stack Stepper Motor Controller PES-2604 on PHPoC Shield or PHPoC WiFi Shield
- Connect stepper motor to terminal block of Stepper Motor Controller PES-2605
- Bipolar stepper motor
- Unipolar stepper motor: there are two ways to connect a unipolar stepper motor to terminal block of PES-2605. User can choose one of them.
Arduino Code
See code section
Web User Interface - remote_rotate.php
remote_rotate.php is a file that contains web user interface. It needs to be stored on PHPoC [WiFi] Shield. In order to upload the file to PHPoC [WiFi] Shield, please do the following steps:
- Copy the below code and save it into remote_rotate.php file.
- Install PHPoC Debugger
- Connect PHPoC to PHPoC [WiFi] Shield via micro-USB cable according to this instruction.Note that Arduino must be powered.
- Upload remote_rotate.php file to PHPoC [WiFi] Shield according to this instruction
The image used in web user interface
step_plate.png
The image also needs to be uploaded to PHPoC [WiFi] Shield
How To- Config network information for PHPoC shield or PHPoC WiFi shield
- Install PHPoC Library
- Install PHPoC Expansion Library
- Compile and upload code to Arduino
- Upload web user interface to PHPoC [WiFi] shield
- Open Serial monitor and copy IP address of PHPoC Shield
- Access web user interface via web browser: http://ip_address_of_shield/remote_rotate.php
- Control step motor via web
To buy electronic components, you can order them from utsource.net
The Best Arduino Starter Kit for BeginnerSee The Best Arduino Kit for Beginners
Comments