Browse Source

Fixed temperature measurement.

master
nickg 5 years ago
parent
commit
0685326c19
  1. 10
      Code/miniRobot/miniRobot.ino
  2. 10
      Code/miniRobot/temperatureDistance.ino
  3. 1
      Code/miniRobotRC/_main.ino
  4. 5
      Code/miniRobotRC/fahrsteuerung_old.ino
  5. 2
      Code/miniRobotRC/miniRobotRC.ino

10
Code/miniRobot/miniRobot.ino

@ -13,7 +13,7 @@ RF24 radio(A0, 3); // CE, CSN
byte commands[32]; //byte 0 = command
long timer;
int temperature;
int16_t temperature;
int distance = 0;
void inline clearCommands() {
@ -78,7 +78,7 @@ void setup() {
//Temperatur- und Abstandsmessung
tempDistSetup();
setEchoPins(0, 0); //Setze die pins für den Abstandsensor aus denen gelesenw erden soll das erster ist der Trigger-, das zweite der Echopin
setEchoPins(16, 5); //16: A2, 5: D5
timer = millis();
}
@ -150,9 +150,8 @@ void commandInterpretation() {
break;
}
case getTemp : {
int temp5;
temp5 = (0xFF00 & (commands[i+1] << 8));
temp5 |= (0x00FF & commands[i+2]);
radio.write(&temperature, sizeof(temperature));
break;
}
case timeToDrive : {
@ -169,6 +168,7 @@ void commandInterpretation() {
forwardA = true;
forwardB = true;
driveOn = false; */
break;
}
}

10
Code/miniRobot/temperatureDistance.ino

@ -36,13 +36,13 @@ int calculateDistance(){
void measureDistance(){
PORTD |= (1<<trig);
digitalWrite(trig, HIGH);
// ... wait for 10 µs ...
delayMicroseconds(10);
// ... put the trigger down ...
PORTD &= ~(1<<trig);
digitalWrite(trig, LOW);
PCICR |= 0b00000100;
PCMSK2 |= 0b00010000;
@ -63,10 +63,12 @@ int16_t dallas(int x, byte start){
result = 0;
for(i = 0; i < 2; i++){
data[i] = ds.read();
result += data[i];
}
result = result/2;
result = (data[1]<<8)|data[0];
result = result/16; //DS1820 2 DS18B20 16
ds.reset();
ds.write(0xCC);
ds.write(0x44, 1); //start conversion

1
Code/miniRobotRC/_main.ino

@ -32,7 +32,6 @@ void loop() {
joystickSteuerung(); //TODO ()
}
tasten.clearButton(buttonStart);
}
void lcdMenu() {

5
Code/miniRobotRC/fahrsteuerung_old.ino

@ -1,9 +1,13 @@
void manualDigitalDrive() {
bool goOn = false;
String temp_str = "T: " + String(temperature) + " Grad C";
lcdLines[5] = temp_str;
// while(!tasten.getButtonCycle(buttonL1)) {
clearCommands();
if(!tasten.getAnyPressed()) {
lcdLines[0] = "Warte...";
}
if(tasten.checkButton(buttonB) || tasten.checkButton(buttonUp)) {
pwmA = -215;
@ -40,6 +44,7 @@ void manualDigitalDrive() {
commands[7] = highByte(driveTimeout);
commands[8] = lowByte(driveTimeout);
commands[9] = goDrive;
radio.write(&commands, sizeof(commands));
goOn = false;
}

2
Code/miniRobotRC/miniRobotRC.ino

@ -40,7 +40,7 @@ bool driveOn = false;
uint16_t driveTimeout = 0;
int16_t distance;
int16_t temperature;
int16_t temperature = 0;
//Funk
#include <SPI.h>

Loading…
Cancel
Save