Merhaba
mikro c 6.0 programını kurdum. anca derleme yapamıyorum ve aşağıdaki hataları alıyorum yardımcı olursanız sevinirim.
internal error pwm_init not found.
undeclared identifier pwm1_start in expression
undeclared identifier ra2_bit in epression
internal error.
undeclared identifier rb2bit in epression
Bu konuda ne yapabiliriz
Hocam kodu eklerseniz derlemeye calisirim.
Kullandığınız version mikroc pro 6 xx mi yoksa düz eski versiyon olan mikroc 6 mi
6.2.1.0 versiyonu kullandım.
yazılımı nasıl göndereyim
mesaj birleştirme:: 26 Nisan 2016, 23:23:21
#define FrontObject RA6_bit // Front Sensor Define - 0V when obstacle / opponent detected (For MZ80, MR45)
#define LeftObject RA4_bit // Left Sensor Define - 0V when obstacle / opponent detected (For MZ80, MR45)
#define RightObject RA7_bit // Right Sensor Define - 0V when obstacle / opponent detected (For MZ80, MR45)
#define LeftLine RA5_bit // Left Edge Sensor Define - 0V when white line sensed (For QTR1A)
#define MiddleLine RA0_bit // Middle Edge Sensor Define - 0V when white line sensed For QTR1A)
#define RightLine RA1_bit // Right Edge Sensor Define - 0V when white line sensed (For QTR1A)
#define BUTTON RA3_bit // Button Define - 5V goes When pushed
#define LED RB2_bit // Led lights when high given
#define MotorLeft RB1_bit // Left Motor Direction Pin - 5V Forward, 0V backward
#define MotorRight RB0_bit // Right Motor Direction Pin - 5V Forward, 0V backward
#define MotorPWM RB3_bit // Common Enable Pin For Motors, PWM speed channel
// Mode Dipswitch Pins
#define Dip1 RB7_bit // DipSwitch 1
#define Dip2 RB6_bit // DipSwitch 2
#define Dip3 RB5_bit // DipSwitch 3
#define Dip4 RB4_bit // DipSwitch 4
#define BUZZER RA2_bit // Buzzer beeps when 5V (high) given
void InOut_define()
{
TRISB=0xF0; // b7 b6 b5 b4 b3 b2 b1 b0
// 1 1 1 1 0 0 0 0
TRISA=0xFB; // A7 A6 A5 A4 A3 A2 A1 A0
// 1 1 1 1 1 0 1 1
PORTA=0; // A port Outputs at 0V
OPTION_REG.F7 = 0; // Enable individual pull-up
CMCON = 0x07 ; // Internal comparators closed
Sound_Init(&PORTA, 2); // Sound library Defined to Porta.2 (Buzzer Pin)
Pwm1_Init(5000); // PWM Frequency
Pwm1_Start(); // PWM function started
}
int i=0; // I defined and equals to 0.
void Beep5sec() // Buzzer Function
{
int LastValue=5; // This variable will be used for remembering what robot made last thing.
for(i=0;i<5;i++) // Buzzer Counter for 5 Sec Wait (Minisumo Start Routine)
{
BUZZER=1; // Buzzer, Porta.2 = 5V
LED=1; // Led, Portb.2 = 5V
delay_ms(500); // 500 ms Delay
BUZZER=0; // Buzzer, Porta.2 = 0V
LED=0; // Led, Portb.2 = 0V
delay_ms(500); // 500 ms Delay
}
}
void SensorTest()
{
while(1) {
if(LeftLine==0) { Sound_Play( 290, 100);} // If left Line Sensor gives signal, Give sound from buzzer at 290 hz for 100 ms.
if(RightLine==0) {Sound_Play( 500, 100);} // If Right Line Sensor gives signal, Give sound from buzzer at 500 hz for 100 ms.
if(FrontObject==0) { Sound_Play( 1500, 100); } // If Front Object Sensor gives signal, Give sound from buzzer at 1500 hz for 100 ms.
if(LeftObject==0 ) {Sound_Play( 4500, 100);} // If Left Object Sensor gives signal, Give sound from buzzer at 4500 hz for 100 ms.
if(RightObject==0) {Sound_Play( 12000, 100);} // If Right Object Sensor gives signal, Give sound from buzzer at 12000 hz for 100 ms.
BUZZER=0; // Buzzer Stopped
}
}
void Forward()
{
Pwm1_Set_Duty(255);
MotorLeft=1; // Left Motor Forward
MotorRight=1; // Right Motor Forward
}
void Forward2()
{
Pwm1_Set_Duty(255);
MotorLeft=1; // Left Motor Forward
MotorRight=1; // Right Motor Forward
}
void Backward()
{
Pwm1_Set_Duty(255);
MotorLeft=0; // Left Motor Backward
MotorRight=0; // Right Motor Backward
}
void Stop()
{
MotorPWM=0; // Motors are passive
}
void RightTurn()
{
Pwm1_Set_Duty(250); // Motors are active speed is 220 / 255
MotorLeft=1; // Left Motor Forward
MotorRight=0; // Right Motor Backward
}
void LeftTurn()
{
Pwm1_Set_Duty(250); // Motors are active speed is 220 / 255
MotorLeft=0; // Left Motor Backward
MotorRight=1; // Right Motor İleri
}
void RightEdge()
{
while (RightLine==0){
LED=1; // Led Lights
Pwm1_Set_Duty(255); // Motors are active speed is 250 / 255
MotorLeft=0; // Left Motor Backward
MotorRight=0; // Right Motor Backward
delay_ms(5); // 50 milisecond delay // It will make Backward
}
Pwm1_Set_Duty(255);
MotorLeft=0; // Left Motor Backward
MotorRight=1; // Right Motor İleri
delay_ms(250); // 80 Ms delay, It will turn
LED=0; // Led don't emits light anymore
}
void LeftEdge()
{
while (LeftLine==0){
LED=1; // Led Lights
Pwm1_Set_Duty(255); // Motors are active speed is 250 / 255
MotorLeft=0; // Left Motor Backward
MotorRight=0; // Right Motor Backward
delay_ms(5); // 50 milisecond delay // It will make Backward
}
Pwm1_Set_Duty(255);
MotorLeft=1; // Sol Motor İleri
MotorRight=0; // Sağ Motor Backward
delay_ms(250); // 80 Ms delay, It will turn
LED=0; // Led don't emits light anymore
}
void DoubleEdge()
{
while (LeftLine==0){
LED=1; // Led Lights
Pwm1_Set_Duty(255); // Motors are active speed is 180 / 255
MotorLeft=0; // Left Motor Backward
MotorRight=0; // Right Motor Backward
delay_ms(5); // 50 milisecond delay // It will make Backward
}
MotorLeft=1; // Left Motor İleri
MotorRight=0; // Right Motor Backward
delay_ms(333); // 300 Ms delay, It will turn
}
int LastValue=5;
void main() {
InOut_define(); // Input Output Function Called
Stop(); // Motors are stopped
BUZZER=1; // Buzzer Beeps, 5V
LED=1; // Led Lights, 5V
delay_ms(200); // 200 ms delay , While Led and Buzzer Active
BUZZER=0; // Buzzer stopped, Led still lights.
while (BUTTON==0) { // While Button is not pressed (When it is pressed it gives 5V, logic 1)
Stop(); // Motors are stopped
}
Beep5sec(); // Buzzer beep function for 5 second. If your competition allows direct matches by remote start. Just add double slash (//) to that line.
//Main Code for sensor control
while(1) // Firmware stucks inside that while section.
{
if (Dip1==0){ // If dipswitch 1 Choosed // Turn to Left Till Sensors Detect Opponent
while (FrontObject==1 && LeftObject==1 && RightObject==1){ // While Object/Opponent Sensors Not Seeing Anything
Pwm1_Set_Duty(100);
LeftTurn();
} }
else if (Dip2==0){ // If dipswitch 2 Choosed // Left Turn 60 Ms And Forward
Pwm1_Set_Duty(100);
LeftTurn();
delay_ms(60);
Forward();
}
else if (Dip3==0){ // If dipswitch 3 Choosed // Right Turn 60 Ms And Forward
Pwm1_Set_Duty(100);
RightTurn();
delay_ms(60);
Forward();
}
else if (Dip4==0){ // If dipswitch 4 Choosed // Turn to Right Till Sensors Detect Opponent
while (FrontObject==1 && LeftObject==1 && RightObject==1){ // While Object/Opponent Sensors Not Seeing Anything
Pwm1_Set_Duty(100);
RightTurn();
} }
while (1){
LED=0;
// Line Sensor Control
if(LeftLine==0 && RightLine==1) { LeftEdge();} else // If Left Edge Sensor Detects White Line
if(LeftLine==1 && RightLine==0) { RightEdge();} else // If Right Edge Sensor Detects White Line
if(LeftLine==0 && RightLine==0) { DoubleEdge();} else // If Both Edge Sensor Detect White Line
// Opponent Sensor Control
if(FrontObject==0) { Forward(); LastValue=5;} else // If Front Sensor Detects Opponent Go Forward, LastValue Variable is 5 (Dummy Value)
if(LeftObject==0 && RightObject==1) { LeftTurn(); LastValue=7; } else // If Left Sensor Detects Opponent Go Forward, LastValue Variable is 7
if(RightObject==0 && LeftObject==1) { RightTurn(); LastValue=3; } else // If Right Sensor Detects Opponent Go Forward, LastValue Variable is 3
// If that sensor values not detected, It will look to LastValue for remembering what robot made last thing.
{
Pwm1_Set_Duty(95); // Speed is 120 / 255
if (LastValue==5) {Forward2();} else // If last Value is 5, Call Forward function
if (LastValue==7) {LeftTurn();} else // If last Value is 7, Call Left function
if (LastValue==3) {RightTurn();} } // If last Value is 3, Call Right function
//Pwm1_Set_Duty(100); // Speed is 120 / 255
if (BUTTON==1) {BUZZER=1; Stop(); SensorTest();} // If button pressed while robot is working it will call SensorTest block
//At Sensor Test Block, you can diagnose mini sumo robot's sensors.
// That if button==1 statement must be commented if start module used.
}
}
} }
@bbs2006 hocam. Yarin iş yerinde kodunuzu derler denetim. Su an telefondan girdiğim için deneyemiyorum.
Hocam işlemci nedir. Picxxxx
16f,628
Merhaba
@bbs2006 program derlemede hata yapmıyor.
Sizin hatanız Library Manager kısmındaki PWM kutusunun tıklı olmamasından kaynaklanıyor.
Ordaki tum library kısımlarını tıkleyin.
Sorun kalmayacaktır.
Ne yapmam gerekiyor
Nasıl eklememem gerekir
http://www.circuitsgallery.com/2013/08/pic-pwm-generation2.html (http://www.circuitsgallery.com/2013/08/pic-pwm-generation2.html)
ben mikro c içerisinde library maneger kısmını bulamadım. yoksa yanlış yerde mi arıyorum.
https://www.youtube.com/watch?v=usYuEdLA8c4 (https://www.youtube.com/watch?v=usYuEdLA8c4)
Library manager programın neresinde
Arkadaşın verdiği videoda 23. saniyede library manager açılıyor.
O bölüm sağda yoksa Wiew>Library Manager seçip yeniden deneyebilirsin.