Things used in this project

Hardware components:
Servo (generic)
Servo motor has to be with more 250 torque
×1
Phpoc blue per 100x1000 euk22wtv9i
PHPoC PHPoC Blue
×1
Software apps and online services:
Vs2015logo
Microsoft Visual Studio 2015
  rv17q3stcl
PHPoC PHPoC Debugger

Schematics

Connect the Servo motor with Board
simple diagram to connect the servo motor with board
Servo jenxb5twau
the motor Connected
a photo after we connect the servo motor with PHPoc Blue Board
Servo example pic uwft3lqqpi

Code

task0 file the main file PHP
it used to program the board
<?php
//edited By ibrahim al nasser 2017
// this code originally from Phpoc website i edit this 
// to fit the requirements an also correct some errors
// from practical point of view
if(_SERVER("REQUEST_METHOD"))
exit; // avoid php execution via http request

include_once "/lib/sn_dns.php";
include_once "/lib/vn_mqtt.php";
include_once "/lib/sd_340.php";

define("PWM_PERIOD", 20000); // 20000us (20ms)
define("WIDTH_MIN", 600);
define("WIDTH_MAX", 2450);
	uio_setup(0, 30, "out high");
uio_setup(0, 31, "out high");
	

	$flags = 0;
$angle = 0;

um_read(0, 0, $flags, 4); // read flags (offset 0, 32bit integer)
um_read(0, 4, $angle, 4); // read angle (offset 4, 32bit integer)
			
if(!$flags)
{
	ht_pwm_setup(0, (WIDTH_MIN + WIDTH_MAX) / 2, PWM_PERIOD, "us");

	$flags |= 0x00000001; // set init flag
	um_write(0, 0, int2bin($flags, 4)); // write flags (offset 0, 32bit integer)

	$angle = 90;
	um_write(0, 4, int2bin($angle, 4)); // write angle (offset 4, 32bit integer)
}



//$host_name = "test.mosquitto.org";
//$host_name = "iot.eclipse.org";
$host_name = "broker.hivemq.com";
//$host_name = "broker.mqttdashboard.com";
//$host_name = "[192.168.0.3]";
$port = 1883;

mqtt_setup(0, "PHPoC-MQTT Sub Example",  $host_name, $port); 

/*
$will_qos = 2;
$will_retain = true;
$will_topic = "disaster/tsunami";
$will_message = "Goodbye forever");
$will = array($will_qos, $will_retain, $will_topic, $will_message);
*/
$will = "";
$username = "";
$password = "";

mqtt_connect(true, $will, $username, $password);

$out_topics = array(array("room/open", 1), array("room/close", 2));


$in_topic = "";
$in_content = "";
$is_retain = 0;

while(1)
{	
	while(mqtt_state() == MQTT_CONNECTED)
{
	if(mqtt_subscribe($out_topics))
		break;
}
if(mqtt_state() == MQTT_DISCONNECTED)
		while(mqtt_reconnect() == false);
	uio_out(0, 31, LOW);
	if(mqtt_loop($in_topic, $in_content, $is_retain))
	{
		//TODO , procees the received publish packet here
		if($is_retain == 1)
		//	echo "<<a stale message\r\n";
	uio_out(0, 30, LOW);
	//	echo "<<topic:$in_topic\r\n";
		echo "<<content: $in_content\r\n";
		if($in_content=="openning"){
		uio_out(0, 30, HIGH);

	$delta = -180; // clock wise

	
if($delta)
{
	um_read(0, 4, $angle, 4); // read angle (offset 4, 32bit integer)

	$angle += $delta;

	if($angle > 180)
		$angle = 180;

	if($angle < 0)
		$angle = 0;

	um_write(0, 4, int2bin($angle, 4)); // write angle (offset 4, 32bit integer)

	$width = WIDTH_MIN + (int)round($angle / 180.0 * (WIDTH_MAX - WIDTH_MIN));

	ht_pwm_width(0, $width, PWM_PERIOD);
	
}
			}
		else{
			if($in_content=="closing"){

	$delta = 180; // clock wise
if($delta)
{
	um_read(0, 4, $angle, 4); // read angle (offset 4, 32bit integer)

	$angle += $delta;

	if($angle > 180)
		$angle = 180;

	if($angle < 0)
		$angle = 0;

	um_write(0, 4, int2bin($angle, 4)); // write angle (offset 4, 32bit integer)

	$width = WIDTH_MIN + (int)round($angle / 180.0 * (WIDTH_MAX - WIDTH_MIN));

	ht_pwm_width(0, $width, PWM_PERIOD);
}
				
				}}
	
	}
}
//mqtt_unsubscribe("sensors/temperature");
	
mqtt_disconnect();

?>
phpoc.iniPHP
to extend the cach memory in the board
tcp0_txbuf_size = 4096 ; SSL/TCP send buffer
tcp0_rxbuf_size = 4096 ; SSL/TCP send buffer
ssl0_rxbuf_size = 4096
init.php file PHP
the initial file for the Phpoc Blue board
<?php
system("php task0.php")
?>
Costum Cortana Commands Project
it used to program a specific commands through cortana

Credits

1463573 774857932529293 415376004 n 0whujaicjy
Ibrahim alnasser

a Master Student in Embedded Systems Program , in TU Chemnitz

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

GPS Tracking Using Helium, Azure IoT Hub, and Power BI
Intermediate
  • 4,849
  • 20

Full instructions

Building a wireless, battery-powered GPS tracker using a Helium Atom, Arduino Zero, Azure IoT Hub, and Power BI.

Humidity Monitor Mobile App (Windows 10 IoT + Xamarin)
Intermediate
  • 321
  • 3

Full instructions

Put your Sense HAT readings into the cloud and derive insights on your phone. Built on Windows 10 IoT, .Net Core, and Xamarin Forms.

Wikia Alexa Skill Builder (Elite: Dangerous Wiki Skill)
Intermediate
  • 410
  • 2

Full instructions

Wish you could talk to your favorite Wikia Wiki? With the help of Alexa, now you can!

Adding RC Transmitter/Receiver to Control Mecanum Bot
Intermediate
  • 985
  • 8

Full instructions

We previously showed our Mecanum Bot being controlled by a wireless Xbox controller, now we added RC transmitter/receiver.

ConnectTheDots with Particle Azure IoT Hub Integration
Intermediate
  • 840
  • 8

Protip

This project will allow you to connect your Particle device into an Azure IoT Hub for viewing data in real-time through an ASP.NET web app!

Lego Mindstorms  Elevator
Intermediate
  • 241
  • 3

A 3-story elevator with a mechanical door made from Lego Mindstorms and programmed on RoboCore. It moves up and down and reacts to buttons.

Lego Mindstorms Elevator

Team ElevatorRoboCore

Add projectSign up / Login