Jump to content

Einstein

Members
  • Gesamte Inhalte

    138
  • Benutzer seit

  • Letzter Besuch

Alle erstellten Inhalte von Einstein

  1. Hallo Leute, ich weiß nicht ob ich etwas Falsch mache. Ich habe einen Masterbrick mit ChibiExtension und LCD sowie Ambilight und IR_TEMP. Dieser wird mit einem StepDown mit 12V versorgt. Soweit so gut funktioniert das auch einwandfrei. Ein Problem habe ich aber, er zeigt mir zwar die Spannung an (11,9V siehe Bild ) jedoch nicht den "Stromverbrauch" des Stacks. Kann mir da jemand helfen weil es sollten schon ein paar mA fließen. Gruß
  2. Hallo Leute, ich wollte euch mal mein Projekt vorstellen. Als Host habe ich ein Sheevaplug auf dem ein Debian läuft. Darauf läuft zusätzlich noch zum Monitoren des Netzwerks Cacti (www.cacti.net wer es nicht kennt). Ich habe erst einmal versucht nur RRD zu erstellen und die Werte dort drinnen zu speichern (deutlich effizienter als in ner Datenbank http://de.wikipedia.org/wiki/RRD). Hier ein Paar Bilder (IR_TEMP/AMBILIGHT mit Chibi-Extension von heute mit kleinen "Stromausfall"). AMBILIGHT TEMPERATUR Danach hab ich noch ein Template für Cacti geschrieben. Ich schiele mit dem RRDs auch so in Richtung der Wetterstation von thunderbird http://www.tinkerunity.org/forum/index.php/topic,164.0.html vielleicht hilft es auch dir etwas. Wenn fragen sind immer her damit. Gruß
  3. Wobei ich vielleicht anmerken möchte das es aber hoffentlich auch möglich ist diese per Gigabit mit POE zu versorgen.
  4. Ohh entschuldige das hatte ich vergessen. Ich hab die aktuellen bindings vorhin runtergeladen und ich teste es auch auf dem Embeddedgerät selber inklusive compilieren. Gruß
  5. In Java funktioniert auch das Programm ohne Probleme, jedoch ist es für ein embedded Gerät und dort läuft Java ohne MMU nur sehr langsam und mehr schlecht als recht. Gruß
  6. Ich hatte es oben noch einmal editiert, wenn ich 2ms schlafe geht es. Ich bin unter Linux unterwegs. Ich hänge mal den kompletten Quelltext an. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> #include <unistd.h> #include <iostream> #include <string> #include "lib/ip_connection.h" #include "lib/bricklet_temperature_ir.h" #include "lib/bricklet_lcd_20x4.h" #include "lib/bricklet_ambient_light.h" #define HOST "localhost" #define PORT 4223 using namespace std; /********************************* ** MAIN ** ** ** *********************************/ int main(int argc, char* argv[]) { // Create ip connection to brickd IPConnection ipcon; if(ipcon_create(&ipcon, HOST, PORT) < 0) { fprintf(stderr, "Could not create connection\n"); exit(1); } // Create device object char* UID_tir = argv[1]; char* UID_al = argv[2]; char* UID_lcd = argv[3]; // Add device to ip connection TemperatureIR tir; temperature_ir_create(&tir, UID_tir); if(ipcon_add_device(&ipcon, &tir) < 0) { fprintf(stderr, "Could not connect to IR_Temp\n"); exit(1); } usleep(100); AmbientLight al; ambient_light_create(&al, UID_al); int amb_temp = ipcon_add_device(&ipcon, &al); if(amb_temp < 0) { fprintf(stderr, "Could not connect to Ambient Light\n"); printf("%i", amb_temp); exit(1); } usleep(100); LCD20x4 lcd; lcd_20x4_create(&lcd, UID_lcd); if(ipcon_add_device(&ipcon, &lcd) < 0) { fprintf(stderr, "Could not connect to LCD\n"); exit(1); } // Don't use device before it is added to a connection // Get current ambient and object temperatures (unit is °C/10) int16_t obj; int16_t amb; uint16_t illuminance; while(1) { sleep(1); if(ambient_light_get_illuminance(&al, &illuminance) < 0) { fprintf(stderr, "Could not get value, probably timeout\n"); exit(1); } ambient_light_get_illuminance(&al, &illuminance); temperature_ir_get_object_temperature(&tir, &obj); temperature_ir_get_ambient_temperature(&tir, &amb); lcd_20x4_write_line(&lcd, 0, 0, "Temperatur: "); lcd_20x4_write_line(&lcd, 1, 0, "Sensor: "); lcd_20x4_write_line(&lcd, 2, 0, "Helligkeit: "); lcd_20x4_backlight_on(&lcd); printf("%f:%f", obj/10.0, amb/10.0); printf("\n %f", illuminance/10.0); printf("\n"); } //printf("Ambient Temperature: %f °C\n", amb/10.0); //printf("Press ctrl+c to close\n"); //ipcon_join_thread(&ipcon); // Join mainloop of ip connection } Ich habs mittlerweile runtergebrochen bis auf 100µs. Gruß EDIT: egal was ich dazwischenschreibe es muss etwas dazwischen. Aktuell steht 1µs dazwischen.
  7. Ich programmiere eigentlich in Java daher vielleicht auch mein schlechter Code. Compileerrors erhalte ich keine und mit Sleep von 1s funktioniert es auch. Gibt es eine Möglichkeit diese Initialisierung noch schneller ablaufen zu lassen? Gruß EDIT: ich hab zwischendrin ein usleep(2000) eingebaut und nun ist es etwas fixer. P.S.: ich bin unter linux unterwegs, nix mit windows
  8. Hallo Leute, ich hoffe mir kann jemand von euch weiterhelfen. Ich weiß nicht ob ich nur auf dem Schlauch stehe aber mein Code will immer nur eine Connection herstellen... Die UID sind definitiv korrekt, wenn ich sie einzeln teste funktioniert es aber alle 3 zusammen gehen nicht. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> #include <unistd.h> #include <iostream> #include <string> #include "lib/ip_connection.h" #include "lib/bricklet_temperature_ir.h" #include "lib/bricklet_lcd_20x4.h" #include "lib/bricklet_ambient_light.h" #define HOST "localhost" #define PORT 4223 /*#define UID_al "XXX" #define UID_lcd "XXX" #define UID_tir "XXX" // Change to your UID*/ using namespace std; /********************************* ** MAIN ** ** ** *********************************/ int main(int argc, char* argv[]) { // Create ip connection to brickd IPConnection ipcon; if(ipcon_create(&ipcon, HOST, PORT) < 0) { fprintf(stderr, "Could not create connection\n"); exit(1); } // Create device object char* UID_tir = argv[1]; char* UID_al = argv[2]; char* UID_lcd = argv[3]; // Add device to ip connection TemperatureIR tir; temperature_ir_create(&tir, UID_tir); if(ipcon_add_device(&ipcon, &tir) < 0) { fprintf(stderr, "Could not connect to IR_Temp\n"); exit(1); } AmbientLight al; ambient_light_create(&al, UID_al); int amb_temp = ipcon_add_device(&ipcon, &al); if(amb_temp < 0) { fprintf(stderr, "Could not connect to Ambient Light\n"); printf("%i", amb_temp); exit(1); } LCD20x4 lcd; lcd_20x4_create(&lcd, UID_lcd); if(ipcon_add_device(&ipcon, &lcd) < 0) { fprintf(stderr, "Could not connect to LCD\n"); exit(1); } Hat jemand eine Idee? Gruß
  9. Immer gerne, klappte auch ganz gut mit dem fixen. Thema kann geschlossen werden denke ich.
  10. Also ich hab alle gefunden unter Zubehör. Zum zweiten sofern ich das richtig mitbekommen hab is das noch in der Beta-Phase. Gruß
  11. soo nun funktionierts wunderbar. ist nur noch die Frage bei 915MHz Kann ich zwar Kanal 5 auswählen, aber speichert bzw ich habs grad mit Java ausgelesen immer Kanal 4. Er speichert immer Kanal der eingestellt ist -1. Ich hoffe du kannst mit meiner Schilderung was anfangen. Gruß
  12. Ich nutze eigentlich die latest von heute. hier der Auszug aus der BrickMaster.java /************************************************************* * This file was automatically generated on 2012-02-15. * * * * If you have a bugfix for this file and want to commit it, * * please fix the bug in the generator. You can find a link * * to the generator git on tinkerforge.com * *************************************************************/ package com.tinkerforge; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.concurrent.TimeUnit; public class BrickMaster extends Device { private final static byte TYPE_GET_STACK_VOLTAGE = (byte)1; private final static byte TYPE_GET_STACK_CURRENT = (byte)2; private final static byte TYPE_SET_EXTENSION_TYPE = (byte)3; private final static byte TYPE_GET_EXTENSION_TYPE = (byte)4; private final static byte TYPE_IS_CHIBI_PRESENT = (byte)5; private final static byte TYPE_SET_CHIBI_ADDRESS = (byte)6; private final static byte TYPE_GET_CHIBI_ADDRESS = (byte)7; private final static byte TYPE_SET_CHIBI_MASTER_ADDRESS = (byte)8; private final static byte TYPE_GET_CHIBI_MASTER_ADDRESS = (byte)9; private final static byte TYPE_SET_CHIBI_SLAVE_ADDRESS = (byte)10; private final static byte TYPE_GET_CHIBI_SLAVE_ADDRESS = (byte)11; private final static byte TYPE_GET_CHIBI_SIGNAL_STRENGTH = (byte)12; private final static byte TYPE_GET_CHIBI_ERROR_LOG = (byte)13; public class ChibiErrorLog { public int underrun; public int crcError; public int noAck; public int overflow; public String toString() { return "[" + "underrun = " + underrun + ", " + "crcError = " + crcError + ", " + "noAck = " + noAck + ", " + "overflow = " + overflow + "]"; } } public class Version { public String name = null; public short[] firmwareVersion = new short[3]; public short[] bindingVersion = new short[3]; public String toString() { return "[" + "name = " + name + ", " + "firmwareVersion = " + firmwareVersion + ", " + "bindingVersion = " + bindingVersion + "]"; } } public BrickMaster(String uid) { super(uid); bindingVersion[0] = 1; bindingVersion[1] = 1; bindingVersion[2] = 0; } public int getStackVoltage() throws IPConnection.TimeoutException { ByteBuffer bb = ByteBuffer.allocate(4); bb.order(ByteOrder.LITTLE_ENDIAN); bb.put((byte)stackID); bb.put((byte)TYPE_GET_STACK_VOLTAGE); bb.putShort((short)4); ipcon.write(this, bb, TYPE_GET_STACK_VOLTAGE, true); byte[] answer = null; try { answer = answerQueue.poll(IPConnection.TIMEOUT_ANSWER, TimeUnit.MILLISECONDS); if(answer == null) { throw new IPConnection.TimeoutException("Did not receive answer for getStackVoltage in time"); } } catch (InterruptedException e) { e.printStackTrace(); } bb = ByteBuffer.wrap(answer, 4, answer.length - 4); bb.order(ByteOrder.LITTLE_ENDIAN); int voltage = IPConnection.unsignedShort(bb.getShort()); semaphoreWrite.release(); return voltage; } public int getStackCurrent() throws IPConnection.TimeoutException { ByteBuffer bb = ByteBuffer.allocate(4); bb.order(ByteOrder.LITTLE_ENDIAN); bb.put((byte)stackID); bb.put((byte)TYPE_GET_STACK_CURRENT); bb.putShort((short)4); ipcon.write(this, bb, TYPE_GET_STACK_CURRENT, true); byte[] answer = null; try { answer = answerQueue.poll(IPConnection.TIMEOUT_ANSWER, TimeUnit.MILLISECONDS); if(answer == null) { throw new IPConnection.TimeoutException("Did not receive answer for getStackCurrent in time"); } } catch (InterruptedException e) { e.printStackTrace(); } bb = ByteBuffer.wrap(answer, 4, answer.length - 4); bb.order(ByteOrder.LITTLE_ENDIAN); int current = IPConnection.unsignedShort(bb.getShort()); semaphoreWrite.release(); return current; } public void setExtensionType(short extension, long exttype) { ByteBuffer bb = ByteBuffer.allocate(9); bb.order(ByteOrder.LITTLE_ENDIAN); bb.put((byte)stackID); bb.put((byte)TYPE_SET_EXTENSION_TYPE); bb.putShort((short)9); bb.put((byte)extension); bb.putInt((int)exttype); ipcon.write(this, bb, TYPE_SET_EXTENSION_TYPE, false); } public long getExtensionType(short extension) throws IPConnection.TimeoutException { ByteBuffer bb = ByteBuffer.allocate(5); bb.order(ByteOrder.LITTLE_ENDIAN); bb.put((byte)stackID); bb.put((byte)TYPE_GET_EXTENSION_TYPE); bb.putShort((short)5); bb.put((byte)extension); ipcon.write(this, bb, TYPE_GET_EXTENSION_TYPE, true); byte[] answer = null; try { answer = answerQueue.poll(IPConnection.TIMEOUT_ANSWER, TimeUnit.MILLISECONDS); if(answer == null) { throw new IPConnection.TimeoutException("Did not receive answer for getExtensionType in time"); } } catch (InterruptedException e) { e.printStackTrace(); } bb = ByteBuffer.wrap(answer, 4, answer.length - 4); bb.order(ByteOrder.LITTLE_ENDIAN); long exttype = IPConnection.unsignedInt(bb.getInt()); semaphoreWrite.release(); return exttype; } public boolean isChibiPresent() throws IPConnection.TimeoutException { ByteBuffer bb = ByteBuffer.allocate(4); bb.order(ByteOrder.LITTLE_ENDIAN); bb.put((byte)stackID); bb.put((byte)TYPE_IS_CHIBI_PRESENT); bb.putShort((short)4); ipcon.write(this, bb, TYPE_IS_CHIBI_PRESENT, true); byte[] answer = null; try { answer = answerQueue.poll(IPConnection.TIMEOUT_ANSWER, TimeUnit.MILLISECONDS); if(answer == null) { throw new IPConnection.TimeoutException("Did not receive answer for isChibiPresent in time"); } } catch (InterruptedException e) { e.printStackTrace(); } bb = ByteBuffer.wrap(answer, 4, answer.length - 4); bb.order(ByteOrder.LITTLE_ENDIAN); boolean present = (bb.get()) != 0; semaphoreWrite.release(); return present; } public void setChibiAddress(short address) { ByteBuffer bb = ByteBuffer.allocate(5); bb.order(ByteOrder.LITTLE_ENDIAN); bb.put((byte)stackID); bb.put((byte)TYPE_SET_CHIBI_ADDRESS); bb.putShort((short)5); bb.put((byte)address); ipcon.write(this, bb, TYPE_SET_CHIBI_ADDRESS, false); } public short getChibiAddress() throws IPConnection.TimeoutException { ByteBuffer bb = ByteBuffer.allocate(4); bb.order(ByteOrder.LITTLE_ENDIAN); bb.put((byte)stackID); bb.put((byte)TYPE_GET_CHIBI_ADDRESS); bb.putShort((short)4); ipcon.write(this, bb, TYPE_GET_CHIBI_ADDRESS, true); byte[] answer = null; try { answer = answerQueue.poll(IPConnection.TIMEOUT_ANSWER, TimeUnit.MILLISECONDS); if(answer == null) { throw new IPConnection.TimeoutException("Did not receive answer for getChibiAddress in time"); } } catch (InterruptedException e) { e.printStackTrace(); } bb = ByteBuffer.wrap(answer, 4, answer.length - 4); bb.order(ByteOrder.LITTLE_ENDIAN); short address = IPConnection.unsignedByte(bb.get()); semaphoreWrite.release(); return address; } public void setChibiMasterAddress(short address) { ByteBuffer bb = ByteBuffer.allocate(5); bb.order(ByteOrder.LITTLE_ENDIAN); bb.put((byte)stackID); bb.put((byte)TYPE_SET_CHIBI_MASTER_ADDRESS); bb.putShort((short)5); bb.put((byte)address); ipcon.write(this, bb, TYPE_SET_CHIBI_MASTER_ADDRESS, false); } public short getChibiMasterAddress() throws IPConnection.TimeoutException { ByteBuffer bb = ByteBuffer.allocate(4); bb.order(ByteOrder.LITTLE_ENDIAN); bb.put((byte)stackID); bb.put((byte)TYPE_GET_CHIBI_MASTER_ADDRESS); bb.putShort((short)4); ipcon.write(this, bb, TYPE_GET_CHIBI_MASTER_ADDRESS, true); byte[] answer = null; try { answer = answerQueue.poll(IPConnection.TIMEOUT_ANSWER, TimeUnit.MILLISECONDS); if(answer == null) { throw new IPConnection.TimeoutException("Did not receive answer for getChibiMasterAddress in time"); } } catch (InterruptedException e) { e.printStackTrace(); } bb = ByteBuffer.wrap(answer, 4, answer.length - 4); bb.order(ByteOrder.LITTLE_ENDIAN); short address = IPConnection.unsignedByte(bb.get()); semaphoreWrite.release(); return address; } public void setChibiSlaveAddress(short num, short address) { ByteBuffer bb = ByteBuffer.allocate(6); bb.order(ByteOrder.LITTLE_ENDIAN); bb.put((byte)stackID); bb.put((byte)TYPE_SET_CHIBI_SLAVE_ADDRESS); bb.putShort((short)6); bb.put((byte)num); bb.put((byte)address); ipcon.write(this, bb, TYPE_SET_CHIBI_SLAVE_ADDRESS, false); } public short getChibiSlaveAddress(short num) throws IPConnection.TimeoutException { ByteBuffer bb = ByteBuffer.allocate(5); bb.order(ByteOrder.LITTLE_ENDIAN); bb.put((byte)stackID); bb.put((byte)TYPE_GET_CHIBI_SLAVE_ADDRESS); bb.putShort((short)5); bb.put((byte)num); ipcon.write(this, bb, TYPE_GET_CHIBI_SLAVE_ADDRESS, true); byte[] answer = null; try { answer = answerQueue.poll(IPConnection.TIMEOUT_ANSWER, TimeUnit.MILLISECONDS); if(answer == null) { throw new IPConnection.TimeoutException("Did not receive answer for getChibiSlaveAddress in time"); } } catch (InterruptedException e) { e.printStackTrace(); } bb = ByteBuffer.wrap(answer, 4, answer.length - 4); bb.order(ByteOrder.LITTLE_ENDIAN); short address = IPConnection.unsignedByte(bb.get()); semaphoreWrite.release(); return address; } public short getChibiSignalStrength() throws IPConnection.TimeoutException { ByteBuffer bb = ByteBuffer.allocate(4); bb.order(ByteOrder.LITTLE_ENDIAN); bb.put((byte)stackID); bb.put((byte)TYPE_GET_CHIBI_SIGNAL_STRENGTH); bb.putShort((short)4); ipcon.write(this, bb, TYPE_GET_CHIBI_SIGNAL_STRENGTH, true); byte[] answer = null; try { answer = answerQueue.poll(IPConnection.TIMEOUT_ANSWER, TimeUnit.MILLISECONDS); if(answer == null) { throw new IPConnection.TimeoutException("Did not receive answer for getChibiSignalStrength in time"); } } catch (InterruptedException e) { e.printStackTrace(); } bb = ByteBuffer.wrap(answer, 4, answer.length - 4); bb.order(ByteOrder.LITTLE_ENDIAN); short signalStrength = IPConnection.unsignedByte(bb.get()); semaphoreWrite.release(); return signalStrength; } public ChibiErrorLog getChibiErrorLog() throws IPConnection.TimeoutException { ByteBuffer bb = ByteBuffer.allocate(4); bb.order(ByteOrder.LITTLE_ENDIAN); bb.put((byte)stackID); bb.put((byte)TYPE_GET_CHIBI_ERROR_LOG); bb.putShort((short)4); ipcon.write(this, bb, TYPE_GET_CHIBI_ERROR_LOG, true); byte[] answer = null; try { answer = answerQueue.poll(IPConnection.TIMEOUT_ANSWER, TimeUnit.MILLISECONDS); if(answer == null) { throw new IPConnection.TimeoutException("Did not receive answer for getChibiErrorLog in time"); } } catch (InterruptedException e) { e.printStackTrace(); } bb = ByteBuffer.wrap(answer, 4, answer.length - 4); bb.order(ByteOrder.LITTLE_ENDIAN); ChibiErrorLog obj = new ChibiErrorLog(); obj.underrun = IPConnection.unsignedShort(bb.getShort()); obj.crcError = IPConnection.unsignedShort(bb.getShort()); obj.noAck = IPConnection.unsignedShort(bb.getShort()); obj.overflow = IPConnection.unsignedShort(bb.getShort()); semaphoreWrite.release(); return obj; } public Version getVersion() { Version version = new Version(); version.name = name; version.firmwareVersion[0] = firmwareVersion[0]; version.firmwareVersion[1] = firmwareVersion[1]; version.firmwareVersion[2] = firmwareVersion[2]; version.bindingVersion[0] = bindingVersion[0]; version.bindingVersion[1] = bindingVersion[1]; version.bindingVersion[2] = bindingVersion[2]; return version; } public void addListener(Object o) { } } und hier meinen Quelltext den ich versucht habe import com.tinkerforge.BrickMaster; import com.tinkerforge.IPConnection; public class ExampleStackStatus { private static final String host = new String("localhost"); private static final int port = 4223; private static final String UID = new String("*****"); // Change to your UID // Note: To make the example code cleaner we do not handle exceptions. Exceptions you // might normally want to catch are described in the commnents below public static void main(String args[]) throws Exception { // Create connection to brickd IPConnection ipcon = new IPConnection(host, port); // Can throw IOException BrickMaster master = new BrickMaster(UID); // Create device object // Add device to ip connection ipcon.addDevice(master); // Can throw IPConnection.TimeoutException // Don't use device before it is added to a connection // Get voltage and current from stack (in mV/mA) int voltage = master.getStackVoltage(); int current = master.getStackCurrent(); if (master.isChibiPresent() == true) { System.out.println("Chibi da"); short frequenz = master.getChibiFrequency(); System.out.println(frequenz); short kanal = master.getChibiChannel(); System.out.println(kanal); } System.out.println("Stack Voltage: " + voltage/1000.0 + " V"); System.out.println("Stack Current: " + current/1000.0 + " A"); System.out.println("Press ctrl+c to exit"); ipcon.joinThread(); } } Ich versteh es nicht ganz...vielleicht siehst du gleich das Problem Gruß
  13. Hallo Leute, ich hab folgendes Problem mit der ChibiExtension. Über brickv stell ich Kanal 5 ein und mach einen Reset. Danach ist der Kanal der angezeigt wird 5-1 = 4. Das ist das erste Problem. Wenn ich jetzt per java versuche die Frequenz auszulesen und den Kanal gibt es die Funktionen nicht in der Tinkerforge.jar (ich hab schon reingeschut in der Klasse BrickMaster fehlen die Funktionen einfach komplett. hier der Fehler: javac -cp Tinkerforge.jar:. ExampleStackStatus.java ExampleStackStatus.java:28: error: cannot find symbol short frequenz = master.getChibiFrequency(); ^ symbol: method getChibiFrequency() location: variable master of type BrickMaster ExampleStackStatus.java:30: error: cannot find symbol short kanal = master.getChibiChannel(); ^ symbol: method getChibiChannel() location: variable master of type BrickMaster 2 errors Ich hoffe es kann mir wer helfen. Gruß Einstein
×
×
  • Neu erstellen...