[TASK] Using a rotary angle sensor

[TASK] Using a rotary angle sensor

Postby admin » Wed Nov 04, 2015 3:59 pm

We will go through an example of printing input signal of a rotary angle sensor by using a PHPoC Blue.

Image

Diagram

Image

Source Codes
1. task0.php

Code: Select all

<?php 
 
if(_SERVER("REQUEST_METHOD"))
    exit; // avoid php execution via http request
 
include 
"/lib/sd_340.php";
 
echo 
"PHPoC example : P4S-34X / ADC / Catalex Rotary Angle Sensor\r\n";
 
adc_setup
(0, 0); // adc0, channel 0
 
$last_adc_in 
= 0;
 
while(1)
{
    $adc_in = adc_in(0, 30);
 
    if
(abs($adc_in - $last_adc_in) > 5)
    {
        printf("Voltage : %.2fV\r\n", $adc_in / 4095.0 * 3.3);
 
        $last_adc_in 
= $adc_in;
 
        usleep
(100000);
    }
}
 
?>


Please download a PSP (PHPoC Support Package) of libraries and examples from PHPoC, and upload it in the PHPoC Blue.

Image


Video

phpBB [video]
admin
Site Admin
 
Posts: 167
Joined: Mon Jan 20, 2014 4:40 pm

Return to Example

Who is online

Users browsing this forum: No registered users and 1 guest

cron