NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » Problems with Make??
August 03, 2013 by Ralphxyz |
So here is the error:
And here is the MakeFile:
The MakeFile is one I just grabbed from another folder I do not know if it ever worked :-( Anybody see any thing obvious or can you interpret the error code for me so I know where to look. I am not sure what line it is failing on. Thanks, Ralph |
---|---|
August 03, 2013 by Ralphxyz |
Well I switched to a known working MakeFile, now I get this for errors:
Here are my #includes:
What is the correct syntax for the path for the GCC compiler? I'd take the answer about the first MakeFile if anyone chatches it. Ralph |
August 03, 2013 by pcbolt |
Ralph - Can't be sure about this but in the second case it looks like the object files associated with "adc.h" and "acs712.h" (the adc.o and acs712.o files) aren't included in the LINKOBJECTS line. I'm not sure where the function "uart_puts" is located but you may need to include that object file as well. I'm assuming the 3 files that are part of your "include" statements are in sub directories below your project directory (or you may need the "../" modifier). In the first case, it looks like a whole other compiler is being called, maybe one on your system that is in the default search path. I noticed the line...
is calling a make file "rule" that doesn't exist since it will expand to...
and all your rules (expanded) are:
You may need to re-write it to:
|
August 04, 2013 by Ralphxyz |
Thanks pcbolt! Here is my known working MakeFile that I am using now:
And here are my current errors:
It appears my #include path is working, but maybe not:
Now re: "it looks like the object files associated with "adc.h" and "acs712.h" (the adc.o and acs712.o files) aren't included in the LINKOBJECTS line. " There are no .o (object) files!! Should these preexist I have an adc.c, uart.c and acs712.c file so I might be able to compile them and make the object files. I thought the compiler would make them automatically. Do I tell the compiler to make them in the MakeFile LINKOBJECTS= line? re: "I'm not sure where the function "uart_puts" is located" uart_puts is in Root/uart/uart.h (#include "uart/uart.h")
All of the "undefined references" are in their associated .h files (at least all that I have checked so far). So I think my newest question is what about those .o (object) files. Do I need to pre make them? Ralph |
August 04, 2013 by pcbolt |
Ralph - I don't think the compiler will automatically compile any of the adc.c, uart.c, acs712.c files without you telling it to. Also, it won't link them into your final upload file without you telling it to. In your last post, I would take this line...
And add
At this point the compiler will complain that it can't find the .o files unless you put in a rule to create them. You can create a new rule and put it at the end of you make file like this...
If you precompile adc.o you won't need to do this. This applies to the other two files as well. There are slicker ways to do this but you'd have to get Noter to tell you how. |
August 05, 2013 by Ralphxyz |
I "tried" pre-compiling adc.c etc but that failed. I "thought" I had done that before on another project but can not remember exactly how I did it. So Paul you still around, anything to add? I sure would appreciate the help and thanks pcbolt I will try your modifications. Ralph |
August 05, 2013 by Noter |
Since it's a one time compile, do it manually instead of using a make file. In a command window navigate to where uart.c resides and compile with this command:
Then do the same for the other two changing the command for their specific names ...
Then add the objects to your main makefile like pcbolt shows in his post -
If you find you are changing uart.c, adc.c, or acs712.c often then consider creating makefiles for each of them but compile only, no linking. |
August 05, 2013 by JimFrederickson |
Hello Ralph, I am pretty sure that part of your problem is with your include files as well?
Aren't these lines saying "from the install directory for the AVR Tool Chain look for subdirectory uart and then find file uart.h"? (etc... For the other 2) Do you really and truly have a "subdirectory uart in the install directory for the AVR
Tool Chain where uart.h is located"? My includes for the "Sample Nerdkit Programs" are:
So this "backs up one level from the current directory looks for subdirectory
libnerdkits and finds delay.h". Also in the same directory are the "object files". I have my own libraries for various thing. When I am working on updating those
libraries this is the makefile I use for that:
This way since each of the libraries hex files are checked against their corresponding
source if I had made any changes that the corresponding library gets recompiled prior to
recompiling the program I am testing the library in. For my "normal programs" where I am just using my libraries, without making changes to
them, I have just put their ".h" and ".o" file into the "libnerdkits" just to keep
everything together. |
August 05, 2013 by Noter |
If Ralph's include files were not being found he would not get all the undefined references to functions defined in them. |
August 05, 2013 by JimFrederickson |
Actually I guess he is telling it to "look in the current directory for subdirectory
uart and then look for uart.h"... (For searching in the AVR Tool Chain Installation
Directory I guess it would be bracketed by "<" and ">". My main thought was to get Ralph to think about what he "has done" vs "what he wants to
do"... It seems that the way he has the ".h" and ".o" files setup, or at least how they seemed
to be setup VIA his source and makefile, creates alot of potential complications. So "yes" while "include files are being found" are they the "ones he expects/wants to be
found"? I think I ran into a problem when two object/library files were named the same.
("uart/uart.o" and "../libnerdkits/uart.o" even though they are in separate
directories.) My problem with that could have been something else, but I do know that
now I don't do that anymore regardless. Does Ralph really have/want 2 separate "uart.o" files? Or Is there only supposed to be 1? |
August 05, 2013 by Noter |
I think linking with two object files named the same is not a problem as long as they don't both contain one or more functions with the same name. So possibly he is ok with both but if errors occur one or the other will need to be removed from his LINKOBJECTS.
However, it is not good practice to duplicate object file names within a project. |
August 06, 2013 by Ralphxyz |
So yes I have subdirectories in my program folder (Root/uart/uart.c and uart.h) etc. And like Noter said the files must be being found so I believe the path syntax is correct. I do not need any references to libnerdkits. What does the += in LINKOBJECTS do. I have not tried that yet. I do not have any uart.o files will they be compiled when I compile the main.c program? I am just trying to run (compile) some example code I found off the web for the ACS712 current sensor. But it did not come with a MakeFile so I was just using a default Nerdkit MakeFile. Thanks once again everyone. Ralph |
August 06, 2013 by Noter |
In make the += just appends to the string. Kind of like the += in C where it just adds to the number. No, the uart and other two objects will not be compiled when you compile the main program. They will be compiled when you navigate a command window to their directory and execute the appropriate avr-gcc command from my prior post to manually compile them. Unless you change them it only has to be done once so it's not worth the time and effort to create or modify a make file for a single compile. The object files don't go away unless you delete them so no need to compile every time. Otherwise the easiest thing is to copy the libnerdkits make file into each of the sub directories and modify it to compile the single source in the directory. Then if you want you can add each of these new make files to your main make file in the same fashion as the libnerdkits make file is called just before the compile/link of your main program. |
August 06, 2013 by Ralphxyz |
Once again Paul I am indebted to you. I compiled the individual files making the object files and then compiled my main.c program perfect!! Now where can I put this thread so that next year I can find it, sure would be nice to have a Library. Now I have to add my stepper motor code and LCD output to the ACS712 code. That ACS712 sure is a nice chip. So far I have just done DC but it also does AC. Ralph |
August 10, 2013 by JimFrederickson |
Hello Ralph, So is ALL OF THIS stuff you are doing with Stepper Motors, and Current Measurements for
your Solar Panel Sun Tracker? You had mentioned that before... Curious... |
August 11, 2013 by Ralphxyz |
Hi Jim, specifically no but it could be adapted. This thread specifically was to help me run a ACS712 library that I had found on the web. I was hoping the library might give me more sensitivity in my current measurements. The Solar Panel Sun Tracker is still on my list. Ralph |
August 11, 2013 by sask55 |
Hi Ralph You have mentioned that the ACS712 chip does AC current. You may be aware of this but,I thought I would point out that reading AC current would not be as straight forward as reading DC is. In a typical sin wave AC the current at any given instant varies. Half of the time the current is flowing one direction and the other half of the time the current is flowing the other direction. With induction and capacitance in the circuit the current/voltage relationship can be complex. Basically it is not possible get a meaningful current measurement on AC with just one reading, or a simple average of a number of readings, as can be done with DC. By repeatedly sampling the current over at least one full AC cycle and determining the RMS (root mean square) the effective AC current is determined. In the case of the ACS712 chip measuring AC current the voltage output would cycle up and down once each AC cycle just as the voltage does but not necessarily I phase with the voltage supply. If the Micro takes an ADC reading it would read the current at a specific instant in the cycle. In order to get the effective AC current you will have to incorporate a hardware or software method of determining the RMS value of the variance from the 2.5 volt output level. I believe that a simple average of the ACS712 output voltage would always be 2.5 Volts when measuring AC current. The chip is capable of measuring the current in both polarities. 2.5 volt output is representative of no current. In the past I have made use of a chip that is very similar to the ACS712 to take a detailed look at the relationship of current vs voltage on AC motors. I did not do much experimenting but it is possible with an oscilloscope to see phase lag and the influence of stating capacitors at motor start up. This type of experimenting could definitely be dangerous and possibly costly because of the higher voltages often used on AC line voltage motors. I am not recommending anyone attempt to work with AC line voltage, but the results were interesting. I just thought you may not have considered the added level of complexity in measuring AC current and voltage levels. Darryl |
August 12, 2013 by Ralphxyz |
Hi Darryl, thanks! Exactly, that is why I was trying to use the ACS712 library I had found on the web it is setup to do AC. Darn wish I could find the link. There are a lot of Arduino projects using the ACS712 and lots of discussions on the web. It is such a simple component to use, I got some pre-made modules that are nice except the pins are backwards and need to be reversed. I tried the 5 amp module to see if I could get more sensitivity but I am seeing the same as with the 30 amp module I was trying to measure my stepper motor current which you helped me with. Because of the lack of real sensitivity I am looking at the A3967, A3977 stepper drivers I can put a encoder on the first stepper and get a pulse which in turn will drive another stepper motor in sync with the first. We will talk about this concept in another thread :-) Ralph |
August 12, 2013 by Noter |
I use these when the pins are not on the bottom side of a module for insertion into a breadboard. |
August 12, 2013 by Ralphxyz |
Yeah, I have also seen some using 90 degree pins so they stand off the breadboard. These are kind of silly, the components and the indicator led face the breadboard. It's a easy change, obviously not made by users. Ralph |
Please log in to post a reply.
Did you know that any circuit of voltage sources and resistors can be simplified to a "Thevenin" equivalent circuit? Learn more...
|