Compiler error

04 Jan 2013

Hi All, I've put together a program using the HMC6352_Hello World, SRF08 and TextLCD as part of my main Roaming program.

If I just use the HMRC6352 and TextLCD it compiles fine no errors and I can download to the mbed and run it and see the compass heading displayed on the lcd screen - so all ok.

Putting it all together I get the following compiler error -

No valid source files to compile?

Any ideas please. Thank you Degs

04 Jan 2013

Maybe you accidently deleted mbed.h? I have seen it before, but that was just a small project and when I copied everything to a new project it worked fine again.

05 Jan 2013

Thank you but #include mbed.h is the first line of my main.cpp

05 Jan 2013

I meant the folder mbed.h in your project.

06 Jan 2013

Hi, I have the Precompiled Build mbed folder within the body of my project, the mbed folder contains Classes, Files, Structs, Groups and has always worked with other programs I've put together?

The error - No valid source files to compile still keeps coming up?

06 Jan 2013

Tbh I would go for plan B then, make a new project, copy your old files to the new project.

06 Jan 2013

What does this error refer to?

More than one section matches selector - cannot all be FIRST/LAST

I get no error number or line reference?

06 Jan 2013
  1. include "mbed.h"
  2. include "HMC6352.h"
  3. include "SRF08.h"
  4. include "TextLCD.h"

This program uses the Magnevation Dual Driver board that I originally had for the OOPIC. I have the board driving HN-GH12-2217Y geared motors type HSIANG NENG.

HMC6352 compass(p9, p10); SRF08 srf08(p28, p29,0xE0); Define SDA, SCL pin and I2C address

PwmOut MotorRightWheel(p21); pwm was p23 PwmOut MotorLeftWheel(p22); pwm was p25

DigitalOut DirectionR=p23;Sets the direction pin on the Magnevation was p27 DigitalOut DirectionL=p24; was p29 DigitalOut BrakeR=p25;Releases the Brake pin on the Magnevation was p28 DigitalOut BrakeL=p26; was p30

TextLCD lcd(p15, p16, p17, p18, p19, p20);

float RangeReading() { float value; value = srf08.read(); return (value); }

float DriveForwardFullSpeed() { float s; DirectionR=0;Set the direction Right motor DirectionL=1;Set the direction Left motor BrakeR = BrakeL = 1;Take Brake OFF for (s= 0.0; s < 1.0 ; s += 0.01) { MotorRightWheel=s; MotorLeftWheel=s; wait(0.2); } return (s); }

float DriveReverse() { float s =0; DirectionR=1;Set the direction Right motor DirectionL=0;Set the direction Left motor BrakeR = BrakeL = 1; Take Brake OFF for (float s= 0.0; s < 1.0 ; s += 0.01) { MotorRightWheel=s; MotorLeftWheel=s; wait(0.2); } wait(0.2); Slow down and stop for (float s = 1.0; s > 0.0; s -= 0.01) { MotorRightWheel=s; MotorLeftWheel=s; wait(0.2); } BrakeR = BrakeL = 0; Put Brake ON return (s); }

float ZeroSpeedForward() { float s =0; DirectionR=0;Set the direction Right motor DirectionL=1;Set the direction Left motor for (float s = 1.0; s > 0.0; s -= 0.01) { MotorRightWheel=s; MotorLeftWheel=s; wait(0.2); } BrakeR = BrakeL = 0; Put Brake ON return (s); }

int main() {

lcd.printf("Starting HMC6352 test...\n");

Continuous mode, periodic set/reset, 20Hz measurement rate. compass.setOpMode(HMC6352_CONTINUOUS, 1, 20);

float distance, speed = 0; while (1) {

wait(0.1); lcd.cls(); lcd.printf("Heading is: %f\n", compass.sample() / 10.0); wait(1.0); distance = RangeReading(); lcd.printf("\nRange: %2.f cm\n",distance); wait(0.2); if (distance >100 && speed <0.1) { lcd.printf("Forward \n"); speed = DriveForwardFullSpeed(); } distance = RangeReading(); lcd.printf("Range: %2.f cm\n",distance); if (distance < 100 && speed >0.5) { speed = ZeroSpeedForward(); } distance = RangeReading(); if (distance > 0.0 && speed == 0.0) { lcd.printf("Reverse \n"); speed = DriveReverse(); } wait (0.5); } }

06 Jan 2013

Use <<code>><</code>> around code blocks:

#include "mbed.h"
#include "HMC6352.h"
#include "SRF08.h"
#include "TextLCD.h"

//This program uses the Magnevation Dual Driver board that I originally
//had for the OOPIC. I have the board driving HN-GH12-2217Y geared motors
//type HSIANG NENG.

HMC6352 compass(p9, p10);
SRF08 srf08(p28, p29,0xE0);  // Define SDA, SCL pin and I2C address

PwmOut MotorRightWheel(p21); // pwm was p23
PwmOut MotorLeftWheel(p22);  // pwm was p25

DigitalOut DirectionR=p23;//Sets the direction pin on the Magnevation was p27
DigitalOut DirectionL=p24; //was p29
DigitalOut BrakeR=p25;//Releases the Brake pin on the Magnevation was p28
DigitalOut BrakeL=p26; //was p30

TextLCD lcd(p15, p16, p17, p18, p19, p20);

float RangeReading() {
    float value;
    value = srf08.read();
    return (value);
}

float DriveForwardFullSpeed() {
    float s;
    DirectionR=0;//Set the direction Right motor
    DirectionL=1;//Set the direction Left motor
    BrakeR = BrakeL = 1;//Take Brake OFF
    for (s= 0.0; s < 1.0 ; s += 0.01) {
        MotorRightWheel=s;
        MotorLeftWheel=s;
        wait(0.2);
    }
    return (s);
}

float DriveReverse() {
    float s =0;
    DirectionR=1;//Set the direction Right motor
    DirectionL=0;//Set the direction Left motor
    BrakeR = BrakeL = 1; //Take Brake OFF
    for (float s= 0.0; s < 1.0 ; s += 0.01) {
        MotorRightWheel=s;
        MotorLeftWheel=s;
        wait(0.2);
    }
    wait(0.2);// Slow down and stop
    for (float s = 1.0; s > 0.0; s -= 0.01) {
        MotorRightWheel=s;
        MotorLeftWheel=s;
        wait(0.2);
    }
    BrakeR = BrakeL = 0; //Put Brake ON
    return (s);
}

float ZeroSpeedForward() {
    float s =0;
    DirectionR=0;//Set the direction Right motor
    DirectionL=1;//Set the direction Left motor
    for (float s = 1.0; s > 0.0; s -= 0.01) {
        MotorRightWheel=s;
        MotorLeftWheel=s;
        wait(0.2);
    }
    BrakeR = BrakeL = 0; //Put Brake ON
    return (s);
}

int main() {

    lcd.printf("Starting HMC6352 test...\n");
    
    //Continuous mode, periodic set/reset, 20Hz measurement rate.
    compass.setOpMode(HMC6352_CONTINUOUS, 1, 20);

    float distance, speed = 0;
    while (1) {
    
        wait(0.1);
        lcd.cls();
        lcd.printf("Heading is: %f\n", compass.sample() / 10.0);
        wait(1.0);
        distance = RangeReading();
        lcd.printf("\nRange: %2.f cm\n",distance);
        wait(0.2);
        if (distance >100  && speed <0.1) {
            lcd.printf("Forward \n");
            speed = DriveForwardFullSpeed();
        }
        distance = RangeReading();
        lcd.printf("Range: %2.f cm\n",distance);
        if  (distance < 100 && speed >0.5) {
            speed = ZeroSpeedForward();
        }
        distance = RangeReading();
        if (distance > 0.0 && speed == 0.0) {
            lcd.printf("Reverse \n");
            speed = DriveReverse();
        }
        wait (0.5);
    }
}
 
06 Jan 2013

Thank you Erik I'd forgotten that little nutmeg! Can you see anything obvious in my program, I'm beginning to think I have a problem with the two I2C devices?

Degs

06 Jan 2013

When using custom libs it can also be handy to publish the program, then we can import it directly.

Since I didnt see a problem directly, I tested it with a random textLCD library (there are really many of them), and the two other ones. Only got one error, SRF08 had no read option. So I guess you use a custom library for that? When I changed it to getRange it compiled fine.

So maybe the error is in your library? Also see: http://mbed.org/forum/mbed/topic/3658/?page=1#comment-19172

06 Jan 2013

I simply use the first function at line 23 RangeReading()called from line 89 to call srf08.read() and place it in value to return it back to the main program.

The libraries I used were HMC6352 by Aaron Berk SRF08 by Chris Styles TextLCD by Simon Ford

06 Jan 2013

If you publish your program I can import it and have a look at it, but SRF08 has no function read, so unless you changed the library that cant work.

06 Jan 2013

I wonder if a clean build will help? You can do this by using the downward facing arrow on the right hand side of the Compile button in the compiler and then selecting the Compile All option from the resulting drop-down menu.

06 Jan 2013

How do I publish an update to my previous attempt, been a while since I used mbed and I'm just getting back into the swing of things!

06 Jan 2013

Right mouse button, publish (or update). It probably ask you to commit first.

06 Jan 2013

I think I've published it.........correctly, the only change I made to HMC6352 was to write the characters to my LCD display.

Thanks

06 Jan 2013

You only published your HMC library, not all your code.

Edit: nevermind, your error is there. You got an HMC library in your HMC library. Very inception like, not what you want. So delete the HMC library in your HMC library.

Edit2: And afterwards delete the published library, otherwise when people search on HMC they get a broken library (I think you can do it from the admin tab on the libraries page).

06 Jan 2013

Thank you

Edit: Deleted the HMC inside a HMC EDIT2: Deleted the library using Admin tab.

However I'm really struggling with the basics here, I thought if I just used Aarons program like I'd used the SFR08 program and incorporate it into my main.cpp program I could develop things from there.

This is the main program I have called Roaming with HMC6352 SRF08 TextLCD

as imports

#include "mbed.h"
#include "HMC6352.h"
#include "SRF08.h"
#include "TextLCD.h"

//This program uses the Magnevation Dual Driver board that I originally
//had for the OOPIC. I have the board driving HN-GH12-2217Y geared motors
//type HSIANG NENG.

HMC6352 compass(p9, p10);
SRF08 srf08(p28, p29,0xE0);  // Define SDA, SCL pin and I2C address

PwmOut MotorRightWheel(p21); // pwm was p23
PwmOut MotorLeftWheel(p22);  // pwm was p25

DigitalOut DirectionR=p23;//Sets the direction pin on the Magnevation was p27
DigitalOut DirectionL=p24; //was p29
DigitalOut BrakeR=p25;//Releases the Brake pin on the Magnevation was p28
DigitalOut BrakeL=p26; //was p30

TextLCD lcd(p15, p16, p17, p18, p19, p20);

float RangeReading() {
    float value;
    value = srf08.read();
    return (value);
}

float DriveForwardFullSpeed() {
    float s;
    DirectionR=0;//Set the direction Right motor
    DirectionL=1;//Set the direction Left motor
    BrakeR = BrakeL = 1;//Take Brake OFF
    for (s= 0.0; s < 1.0 ; s += 0.01) {
        MotorRightWheel=s;
        MotorLeftWheel=s;
        wait(0.2);
    }
    return (s);
}

float DriveReverse() {
    float s =0;
    DirectionR=1;//Set the direction Right motor
    DirectionL=0;//Set the direction Left motor
    BrakeR = BrakeL = 1; //Take Brake OFF
    for (float s= 0.0; s < 1.0 ; s += 0.01) {
        MotorRightWheel=s;
        MotorLeftWheel=s;
        wait(0.2);
    }
    wait(0.2);// Slow down and stop
    for (float s = 1.0; s > 0.0; s -= 0.01) {
        MotorRightWheel=s;
        MotorLeftWheel=s;
        wait(0.2);
    }
    BrakeR = BrakeL = 0; //Put Brake ON
    return (s);
}

float ZeroSpeedForward() {
    float s =0;
    DirectionR=0;//Set the direction Right motor
    DirectionL=1;//Set the direction Left motor
    for (float s = 1.0; s > 0.0; s -= 0.01) {
        MotorRightWheel=s;
        MotorLeftWheel=s;
        wait(0.2);
    }
    BrakeR = BrakeL = 0; //Put Brake ON
    return (s);
}

int main() {

    lcd.printf("Starting HMC6352 test...\n");
    
    //Continuous mode, periodic set/reset, 20Hz measurement rate.
    compass.setOpMode(HMC6352_CONTINUOUS, 1, 20);

    float distance, speed = 0;
    while (1) {
    
        wait(0.1);
        lcd.cls();
        lcd.printf("Heading is: %f\n", compass.sample() / 10.0);
        wait(1.0);
        distance = RangeReading();
        lcd.printf("\nRange: %2.f cm\n",distance);
        wait(0.2);
        if (distance >100  && speed <0.1) {
            lcd.printf("Forward \n");
            speed = DriveForwardFullSpeed();
        }
        distance = RangeReading();
        lcd.printf("Range: %2.f cm\n",distance);
        if  (distance < 100 && speed >0.5) {
            speed = ZeroSpeedForward();
        }
        distance = RangeReading();
        if (distance > 0.0 && speed == 0.0) {
            lcd.printf("Reverse \n");
            speed = DriveReverse();
        }
        wait (0.5);
    }
}
06 Jan 2013

The problem is there the same as what it was in the link I posted earlier, a duplicate mbed library. In your SRF08 library you probably accidently dragged your mbed library. I expect that your initial error also came from that, then I suppose you copied it to a new project, and at that point you had 2 mbed libraries, resulting in the problem you saw.

So just delete the duplicate mbed library residing in the SRF08 library.

07 Jan 2013

Thank you for spotting that! I've compiled it successfully now so I'll download it tonight and continue with my project. I dare say I'll be posting a few more questions as I re-learn my way around.

Most of all thank you for your patience.

Incidentally I'd like to download the latest mbed file, whats the best way to do that?

07 Jan 2013

Do you mean the latest mbed library version? If you click on the mbed library in your project you have an update button at the right side. If it is greyed out you already have the most recent version.

07 Jan 2013

Yep thanks for that, I can see what happened the other day now, I'd updated the mbed library and I'd somehow also put one in the SRF08 folder?

The one I have now is revision 53 and it says it's up to date.

Many thanks again Erik