Hi,
Ich habe drei Fragen:
1.
Warum schreibst du in den WriteInteger Befehl noch eine "10" nach dem Komma? (Ich beziehe mich auf folgendes Programm)
Code:
// RC-Signale an SCL und SDA messen 23.3.2010 mic
// Timersetup der Lib: Mode 10, Phase Correct
// Mit ICR1 als Top ergibt bei ICR1=210 ca. 8MHz/420=19047,6Hz ;)
// Drehbereich meiner RS-2-Servos ist von ca. 14 bis ca. 38
// Aus: https://www.roboternetz.de/phpBB2/ze...=492812#492812
#include "RP6RobotBaseLib.h"
volatile uint8_t rc_input_pwr=26, rc_input_dir=26;
int main(void)
{
initRobotBase();
TIMSK |= (1 << TOIE1); // Die Timer1 Overflow-ISR zur Servoansteuerung
setLEDs(1); // und los!
writeString_P("\n\nRC-Empfänger an SCL und SDA auswerten.\n");
writeString_P("mic 23.3.2010\n\n");
while(1)
{
writeString_P("SCL (PC0): ");
writeInteger(rc_input_dir, 10);
writeString_P("\nSDA (PC1): ");
writeInteger(rc_input_pwr, 10);
writeString_P("\n\n");
mSleep(300);
}
return 0;
}
ISR (TIMER1_OVF_vect) // RC-Signale an SCL und SDA messen
{
static uint16_t rc_temp_pwr=0;
static uint16_t rc_temp_dir=0;
if (PINC & 1) rc_temp_dir++; else
if (rc_temp_dir) { rc_input_dir=rc_temp_dir-1; rc_temp_dir=0; }
if (PINC & 2) rc_temp_pwr++; else
if (rc_temp_pwr) { rc_input_pwr=rc_temp_pwr-1; rc_temp_pwr=0; }
}
Und 2.
Würde dieser Code vom Prinzip her funktionieren oder fehlt noch was, außer den Werten die ich noch nicht kenne?
Code:
#include "RP6RobotBaseLib.h"
volatile uint8_t rc_input_pwrr=26, rc_input_pwrl=26;
int main(void)
{
initRobotBase();
TIMSK |= (1 << TOIE1); // Die Timer1 Overflow-ISR zur Servoansteuerung
while(1)
{
// if (rc_input_pwrl<x && rc_input_pwrl>y) {changeDirection(BWD); moveAtSpeed(60,0)}
// if (rc_input_pwrl<x && rc_input_pwrl>y) {changeDirection(FWD); moveAtSpeed(60,0)}
// if (rc_input_pwrr<x && rc_input_pwrr>y) {changeDirection(BWD); moveAtSpeed(0,60)}
// if (rc_input_pwrr<x && rc_input_pwrr>y) {changeDirection(FWD); moveAtSpeed(0,60)}
// task_motionControl();
}
return 0;
}
ISR (TIMER1_OVF_vect) // RC-Signale an SCL und SDA messen
{
static uint16_t rc_temp_pwrl=0;
static uint16_t rc_temp_pwrr=0;
if (PINC & 1) rc_temp_pwrl++; else
if (rc_temp_pwrl) { rc_input_pwrl=rc_temp_pwrl-1; rc_temp_pwrl=0; }
if (PINC & 2) rc_temp_pwrr++; else
if (rc_temp_pwrr) { rc_input_pwrr=rc_temp_pwrr-1; rc_temp_pwrr=0; }
}
und 3.
Hat jetzt zwar nicht sehr viel mit dem Thema zu tun aber ist ja schnell beantwortet. Kann man das RP6 C-Control PRO M128
Erweiterungsmodul so wie man es bei Conrad bekommt direkt benutzen ohne diesen extra Baustein (C-CONTROL PRO UNIT MEGA 12
?? Mit benutzen meine ich Programmieren und in Verbindung mit dem RP6 laufen lassen.???
)
Danke!
Lesezeichen