Hallo,
ich hab das Gefühl, wir kommen der Lösung näher. Danke schon mal
Ich habe den Code eingefügt, ohne Ergbnis.
Angeschlossen ist der Stapel (Master mit Servo drauf) wiefolgt:
- Per USB am Raspberry Pi
Der BrickV läuft auf einem Win7 PC, der im gleichen LAN läuft.
Das PHP Script habe ich sowohl auf jedem Win-PC als auch auf dem Raspberry direkt getestet.
Die Firmware der Bricks und Bricklets ist auch die aktuelle.
Hier nochmal eine etwas besser formatierte Ausgabe (alles Getter()), nach dem setzen der Werte:
Array
(
[temperature] => 454
[overAllCurr] => 0
[outputV] => 9000
[stackInV] => 0
[externInV] => 12073
)
ROT
Array
(
[Acceleration] => 0
[Velocity] => 0
[Period] => 1
[PulsWidth] => Array
(
[min] => 1000
[max] => 2000
)
[Degree] => Array
(
[min] => 0
[max] => 0
)
[Position] => 0
[Enabled] => 1
)
GRÜN
Array
(
[Acceleration] => 0
[Velocity] => 0
[Period] => 1
[PulsWidth] => Array
(
[min] => 1000
[max] => 2000
)
[Degree] => Array
(
[min] => 0
[max] => 0
)
[Position] => 0
[Enabled] => 1
)
BLAU
Array
(
[Acceleration] => 0
[Velocity] => 0
[Period] => 1
[PulsWidth] => Array
(
[min] => 1000
[max] => 2000
)
[Degree] => Array
(
[min] => 0
[max] => 0
)
[Position] => 0
[Enabled] => 1
)
d.h. es wird überall die Periode 1 zurück gegeben.
der LED Streifen leuchtet aber weiß, d.h. die Periode müsste min >100 sein, pro Servo. Wenn ich im BrickV 1 einstelle, leuchten die LEDs nicht, was ja auch gut so ist
Ich versteh es nicht
hier nochmal die komplette Klasse, falls es hilft:
<?php
require_once PATH_INC."main.inc.php";
/**
* @author MR
*/
class Led_Inc extends Main_Inc {
private $common;
/**
* @var IPConnection
*/
private $tinker_conn;
/**
* @var BrickServo
*/
private $tinker_serv;
private $color_new;
static private $s_red = array(
'id' => 4,
'min_p' => 1,
'max_p' => 500
);
static private $s_green = array(
'id' => 5,
'min_p' => 1,
'max_p' => 8400
);
static private $s_blue = array(
'id' => 6,
'min_p' => 1,
'max_p' => 5000
);
public function __construct(){
parent::__construct();
Main_Class::include_db('common','common.db');
$this->common = new Common_DB();
$this->DATA =& parent::$DATA['led'];
$this->DATA['error'] = '';
$this->DATA['state'] = 0;
Main_Class::include_utils('Tinkerforge/IPConnection');
Main_Class::include_utils('Tinkerforge/BrickServo');
try {
$this->tinker_conn = new Tinkerforge\IPConnection();
$this->tinker_serv = new Tinkerforge\BrickServo( tfUID_SERVO, $this->tinker_conn );
$this->tinker_serv->setResponseExpectedAll(True);
$this->tinker_conn->connect( tfHOST, tfPORT );
$this->set_color();
$this->set_data();
$this->get_data();
$this->tinker_conn->disconnect();
Main_Class::include_design('led','led.design');
} catch (Exception $exc) {
echo $exc->getTraceAsString();
}
}
public function __destruct() {
if( $this->tinker_conn->getConnectionState() )
$this->tinker_conn->disconnect();
}
protected function set_color(){
if( $_REQUEST['rgb'] && substr($_REQUEST['rgb'], 0, 3)=='rgb' ){
$rgb_str = substr($_REQUEST['rgb'], 4);
$rgb_str = substr($rgb_str, 0, strlen($rgb_str)-1);
$arrRGB = explode(',', $rgb_str);
if( isset($arrRGB[0]) && isset($arrRGB[1]) && isset($arrRGB[2])){
$this->color_new['red'] = $arrRGB[0];
$this->color_new['green'] = $arrRGB[1];
$this->color_new['blue'] = $arrRGB[2];
$this->DATA['newRGB'] = $this->color_new;
}
}
}
protected function set_data(){
// Configure two servos with voltage 5.5V
// Servo 1: Connected to port 0, period of 19.5ms, pulse width of 1 to 2ms
// and operating angle -100 to 100°
//
// Servo 2: Connected to port 5, period of 20ms, pulse width of 0.95
// to 1.95ms and operating angle -90 to 90°
$this->tinker_serv->setOutputVoltage(9000);
// blue
$this->tinker_serv->setDegree($this->s_blue['id'], 0, 0);
$this->tinker_serv->setVelocity($this->s_blue['id'], 0); // Full speed
$this->tinker_serv->setAcceleration($this->s_blue['id'], 0); // Slow acceleration
$this->tinker_serv->setPulseWidth($this->s_blue['id'], 1000, 2000);
$this->tinker_serv->setPeriod($this->s_blue['id'], 1);
// red
$this->tinker_serv->setDegree($this->s_red['id'], 0, 0);
$this->tinker_serv->setVelocity($this->s_red['id'], 0); // Full speed
$this->tinker_serv->setAcceleration($this->s_red['id'], 0); // Slow acceleration
$this->tinker_serv->setPulseWidth($this->s_red['id'], 1000, 2000);
$this->tinker_serv->setPeriod($this->s_red['id'], 7000);
// green
$this->tinker_serv->setDegree($this->s_green['id'], 0, 0);
$this->tinker_serv->setVelocity($this->s_green['id'], 0); // Full speed
$this->tinker_serv->setAcceleration($this->s_green['id'], 0); // Slow acceleration
$this->tinker_serv->setPulseWidth($this->s_green['id'], 1000, 2000);
$this->tinker_serv->setPeriod($this->s_green['id'], 1);
// setPostion and enable
$this->tinker_serv->setPosition($this->s_blue['id'], 0); // Set to most right position
$this->tinker_serv->enable($this->s_blue['id']);
$this->tinker_serv->setPosition($this->s_red['id'], 0); // Set to most right position
$this->tinker_serv->enable($this->s_red['id']);
$this->tinker_serv->setPosition($this->s_green['id'], 0);
$this->tinker_serv->enable($this->s_green['id']);
}
protected function get_data(){
$arrSred['temperature'] = $this->tinker_serv->getChipTemperature();
$arrSred['overAllCurr'] = $this->tinker_serv->getOverallCurrent();
$arrSred['outputV'] = $this->tinker_serv->getOutputVoltage();
$arrSred['stackInV'] = $this->tinker_serv->getStackInputVoltage();
$arrSred['externInV'] = $this->tinker_serv->getExternalInputVoltage();
$this->DATA['general'] = $arrSred;
unset($arrSred);
#echo 'RED';
$arrSred['Acceleration'] = $this->tinker_serv->getAcceleration($this->s_red['id']);
$arrSred['Velocity'] = $this->tinker_serv->getVelocity($this->s_red['id']);
$arrSred['Period'] = $this->tinker_serv->getPeriod($this->s_red['id']);
$arrSred['PulsWidth'] = $this->tinker_serv->getPulseWidth($this->s_red['id']);
$arrSred['Degree'] = $this->tinker_serv->getDegree($this->s_red['id']);
$arrSred['Position'] = $this->tinker_serv->getPosition($this->s_red['id']);
$arrSred['Enabled'] = $this->tinker_serv->isEnabled($this->s_red['id']);
$this->DATA['red'] = $arrSred;
unset($arrSred);
#echo 'BLUE';
$arrSred['Acceleration'] = $this->tinker_serv->getAcceleration($this->s_blue['id']);
$arrSred['Velocity'] = $this->tinker_serv->getVelocity($this->s_blue['id']);
$arrSred['Period'] = $this->tinker_serv->getPeriod($this->s_blue['id']);
$arrSred['PulsWidth'] = $this->tinker_serv->getPulseWidth($this->s_blue['id']);
$arrSred['Degree'] = $this->tinker_serv->getDegree($this->s_blue['id']);
$arrSred['Position'] = $this->tinker_serv->getPosition($this->s_blue['id']);
$arrSred['Enabled'] = $this->tinker_serv->isEnabled($this->s_blue['id']);
$this->DATA['blue'] = $arrSred;
unset($arrSred);
#echo 'GREEN';
$arrSred['Acceleration'] = $this->tinker_serv->getAcceleration($this->s_green['id']);
$arrSred['Velocity'] = $this->tinker_serv->getVelocity($this->s_green['id']);
$arrSred['Period'] = $this->tinker_serv->getPeriod($this->s_green['id']);
$arrSred['PulsWidth'] = $this->tinker_serv->getPulseWidth($this->s_green['id']);
$arrSred['Degree'] = $this->tinker_serv->getDegree($this->s_green['id']);
$arrSred['Position'] = $this->tinker_serv->getPosition($this->s_green['id']);
$arrSred['Enabled'] = $this->tinker_serv->isEnabled($this->s_green['id']);
$this->DATA['green'] = $arrSred;
}
}
new Led_Inc();
?>
die set_color() hat zZ keine Auswirkung!