Kanał - ATNEL tech-forum
Wszystkie działy
Najnowsze wątki



Teraz jest 27 kwi 2024, o 15:19


Strefa czasowa: UTC + 1





Utwórz nowy wątek Odpowiedz w wątku  [ Posty: 4 ] 
Autor Wiadomość
PostNapisane: 11 lut 2016, o 02:05 
Offline
Nowy

Dołączył(a): 11 lut 2016
Posty: 1
Pomógł: 0

Witam !

mam problem z dodaniem biblioteki <Servo.h> do mojego projektu poniżej szkic

[ proszę poprawić kod zgodnie z instrukcją: topic7402.html bo inaczej wątek zostanie usunięty - mirekk36 ]

błąd :

libraries\Servo\avr\Servo.cpp.o: In function `__vector_11':

C:\Program Files (x86)\Arduino\libraries\Servo\src\avr/Servo.cpp:81: multiple definition of `__vector_11'

libraries\RadioHead\RH_ASK.cpp.o:C:\Users\Anetka\Documents\Arduino\libraries\RadioHead/RH_ASK.cpp:514: first defined here

collect2.exe: error: ld returned 1 exit status


szkic :
D0
D1
D2
D3 PWMA Silnik
D4 LED Pin
D5 PWMA Silnik
D6 AIN1
D7 AIN2
D8 NRF24 CE
D9
D10 NRF24 CSN
D11 NRF24 MOSI
D12 NRF24 MISO
D13 NRF24 SCK
A0
A1
A2
A3
A4
A5
*/

// This section describes the vehicle (this ID is JD83)
byte ID1 = 0x4A; // Enter a four byte ID for the vehicle
byte ID2 = 0x44; // for example F936 for the Fendt 936 model
byte ID3 = 0x38; // would be ID1 = 0x46; ID2 = 0x39; ID3 = 0x33; ID4 = 0x36
byte ID4 = 0x33; // because asci character F is 46 in hexidecimal and so on

// Variables used in the program
int Move_1 = 125;
int Move_2 = 125;
int Move_3 = 125;// Variable used to determine the motor direction
byte Command_Val = 0x00; // Stores the command value
byte Data_Val_1 = 0x00; // Stores the data value
byte Data_Val_2 = 0x00; // Stores the data value
byte Data_Val_3 = 0x00; // Stores the data value
byte Data_Val_4 = 0x00; // Stores the data value
byte Data_Val_5 = 0x00; // Stores the data value
byte Data_Val_6 = 0x00; // Stores the data value

// Include Libraries
#include <SPI.h>
#include <RH_NRF24.h>





RH_NRF24 nrf24; // Create NRF24 object

void setup()
{
pinMode(4, OUTPUT); // Set digital pin 4 as an output

nrf24.init(); // Initiailize NRF24 radio module
nrf24.setChannel(1); // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm);
}

void loop()
{
if (nrf24.available()) // If the NRF24 has recieved data
{
uint8_t buf[11]; // Create array to store it in
uint8_t len = sizeof(buf);
if (nrf24.recv(buf, &len)) // Store the data
{
// We recieved a string of ten bytes, four ID, one command and six data values but they may not be for this tractor
if (buf[0] == ID1 && buf[1] == ID2 && buf[2] == ID3 && buf[3] == ID4){ // Confirm that the correct vehicle ID has been recieved
Command_Val = buf[4]; // Store the new command value
Data_Val_1 = buf[5]; // Store the new data value
Data_Val_2 = buf[6]; // Store the new data value
Data_Val_3 = buf[7]; // Store the new data value
Data_Val_4 = buf[8]; // Store the new data value
Data_Val_5 = buf[9]; // Store the new data value
Data_Val_6 = buf[10]; // Store the new data value
}

}

// Servo not simple, NRF24 and servo libraries trying to use the same timer

// Motor Control
// Data recieved is between 0 and 255. The center is 255/2=127.5 and we want a buffer zone around here to stop the tractor from moving unexpectedly.
if (Data_Val_5 < 120){ // This if function create a buffer zone of 7.5 bits below 127.5
Move_1 = map(Data_Val_5, 120, 0, 0,255); // PWM is 0% at 0 and 100% at 255 so scale the data value for use with the motor
analogWrite(5,Move_1); // Set the PWM value on pin 5 to move the motor

}
else if (Data_Val_5 > 135){ // This if function create a buffer zone of 7.5 bits above 127.5
Move_1 = map(Data_Val_5, 5, 0, 0,0); // PWM is 0% at 0 and 100% at 255 so scale the data value for use with the motor
analogWrite(5,Move_1); // Set the PWM vlue on pin 5 to move the motor


}
else{ // Every other value is in the buffer zone
Move_1=0;
analogWrite(5,Move_1); // Set the PWM to 0%
// Set the direction with pins 6 and 7 but not necessary

}
/////////////////////////////////////////////
// Motor Control
// Data recieved is between 0 and 255. The center is 255/2=127.5 and we want a buffer zone around here to stop the tractor from moving unexpectedly.
if (Data_Val_5 < 120){ // This if function create a buffer zone of 7.5 bits below 127.5
Move_2 = map(Data_Val_5, 5, 0, 0,0); // PWM is 0% at 0 and 100% at 255 so scale the data value for use with the motor
analogWrite(3,Move_2); // Set the PWM value on pin 5 to move the motor

}
else if (Data_Val_5 > 135){ // This if function create a buffer zone of 7.5 bits above 127.5
Move_2 = map(Data_Val_5, 120, 255, 0,255); // PWM is 0% at 0 and 100% at 255 so scale the data value for use with the motor
analogWrite(3,Move_2); // Set the PWM vlue on pin 5 to move the motor


}
else{ // Every other value is in the buffer zone
Move_2=0;
analogWrite(3,Move_2); // Set the PWM to 0%

}
////////////////////////SERVO//////////////////////////////



// LED Control
if(Data_Val_6==1){
digitalWrite(4, HIGH); // Turn LED on
}
else {
digitalWrite(4, LOW); // Turn LED off
}
}
}



Góra
 Zobacz profil  
cytowanie selektywne  Cytuj  
PostNapisane: 11 lut 2016, o 02:43 
Offline
Użytkownik

Dołączył(a): 26 lip 2015
Posty: 269
Pomógł: 34

Poprawnie wstaw kod i usuń któryś z tematów, bo je zdublowałeś.



Góra
 Zobacz profil  
cytowanie selektywne  Cytuj  
PostNapisane: 11 lut 2016, o 08:35 
Offline
Użytkownik
Avatar użytkownika

Dołączył(a): 26 sty 2016
Posty: 1148
Lokalizacja: Kraków
Pomógł: 93

Chyba dwie biblioteki korzystają z tych samych zasobów mikrokontrolera. Albo masz coś nie tak z biblioteką



Góra
 Zobacz profil  
cytowanie selektywne  Cytuj  
PostNapisane: 11 lut 2016, o 10:12 
Offline
Użytkownik
Avatar użytkownika

Dołączył(a): 11 mar 2014
Posty: 1475
Pomógł: 167

Masz napisane w błędzie. Wykorzystujesz to samo przerwanie w dwóch bibliotekach Servo.cpp (dodane przez #include <Servo.h>) i w RH_ASK.cpp (pewnie dodane poprzez #include <RH_NRF24.h>).

--
Pozdrawiam,
Robert



Góra
 Zobacz profil  
cytowanie selektywne  Cytuj  
Wyświetl posty nie starsze niż:  Sortuj wg  
Utwórz nowy wątek Odpowiedz w wątku  [ Posty: 4 ] 

Strefa czasowa: UTC + 1


Kto przegląda forum

Użytkownicy przeglądający ten dział: Brak zidentyfikowanych użytkowników i 2 gości


Nie możesz rozpoczynać nowych wątków
Nie możesz odpowiadać w wątkach
Nie możesz edytować swoich postów
Nie możesz usuwać swoich postów
Nie możesz dodawać załączników

Szukaj:
Skocz do:  
Sitemap
Technologię dostarcza phpBB® Forum Software © phpBB Group phpBB3.PL
phpBB SEO