NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Support Forum » Problems making a make file

March 09, 2012
by mdrumm
mdrumm's Avatar

I tried taking the dip_arithmetic make file and changing it to load my bottle jam file. Have not been able to do it so far. Not sure why. I am running windows 7. I have got the Nerd Kits dip_arithmetic program to load and work as well as the others. There is something I am not seeing.Thanks for any help.

The error I get is

make-c ''/libnerdkits make: ''/libnerdkits: no such file or directory make: [bottle_jam.hex] error 2

My modified make file:

GCCFLAGS=-g -Os -Wall -mmcu=atmega168 LINKFLAGS=-Wl,-u,vfprintf -lprintf_flt -Wl,-u,vfscanf -lscanf_flt -lm AVRDUDEFLAGS=-c avr109 -p m168 -b 115200 -P com3 LINKOBJECTS=../libnerdkits/delay.o ../libnerdkits/lcd.o ../libnerdkits/uart.o

all: bottle_jam-upload

bottle_jam.hex: bottle_jam.c make -C ../libnerdkits avr-gcc ${GCCFLAGS} ${LINKFLAGS} -o bottle_jam.o bottle_jam.c ${LINKOBJECTS} avr-objcopy -j .text -O ihex bottle_jam.o bottle_jam.hex

bottle_jam.ass: bottle_jam.hex avr-objdump -S -d bottle_jam.o > bottle_jam.ass

bottle_jam-upload: bottle_jam.hex avrdude ${AVRDUDEFLAGS} -U flash:w:bottle_jam.hex:a


The beginnings of my program, it will eventally count 2 rows of 3 bottles or 3 rows of 4 bottles then activate a machine proccess or set a alarm it's not finished. I know there is probably bugs in this part. I have not been able to load it to play with it yet. I usually would program this with a plc. A micro processor would be cheaper.So far I have been having a lot of fun with this I love learning new things.

// initialload.c// for NerdKits with ATmega168 // mrobbins@mit.edu

define F_CPU 14745600

include <stdio.h>

include <avr/io.h>

include <avr/interrupt.h>

include <avr/pgmspace.h>

include <inttypes.h>

include "../libnerdkits/delay.h"

include "../libnerdkits/lcd.h"

//****Inserted code****

// Set the 5 pins to input mode - 3 eyes, 2 select buttons ( 2 lanes 6 bottles or 3 lanes 12 bottles), DDRC &= ~(1<<PC0); // set PC0 as input DDRC &= ~(1<<PC1); // set PC1 as input DDRC &= ~(1<<PC2); // set PC2 as input DDRC &= ~(1<<PC3); // set PC3 as input DDRC &= ~(1<<PC4); // set PC4 as input

// turn on the internal resistors for the pins

PORTC |= (1<<PC0); // turn on internal pull up resistor for PC0 PORTC |= (1<<PC1); // turn on internal pull up resistor for PC1 PORTC |= (1<<PC2); // turn on internal pull up resistor for PC2 PORTC |= (1<<PC3); // turn on internal pull up resistor for PC3 PORTC |= (1<<PC4); // turn on internal pull up resistor for PC4

// declare the variables to represent each bit uint8_t a1; uint8_t a2; uint8_t a3;

uint8_t b1; uint8_t b2;

//***Inserted code****

int main(intc) {

// fire up the LCD lcd_init(); lcd_home();

// busy loop while(1) {

uint8_t b1 = PINC & (1<<PC3) uint8_t b2 = PINC & (1<<PC4)

if (uint8_t b1) { // If button 1 is pushed must push reset to unlock it and //make another selection

lcd_line_one(); lcd_write_string(PSTR(" You have selected ")); lcd_line_two(); lcd_write_string(PSTR("*****")); lcd_line_three(); lcd_write_string(PSTR("the Bottle Drop pattern 2 lanes X 3 Bottles ")); lcd_line_four(); lcd_write_string(PSTR("Must reset before making another selection ")); }

if (uint8_t b2) { // If button 2 is pushed must push reset to unlock it and //make another selection

lcd_line_one(); lcd_write_string(PSTR(" You have selected ")); lcd_line_two(); lcd_write_string(PSTR("*****")); lcd_line_three(); lcd_write_string(PSTR("the Bottle Drop pattern 3 lanes X 4 Bottles ")); lcd_line_four(); lcd_write_string(PSTR(" Must reset before making another selection "));

}

if ~(uint8_t b1) & ~(uint8_t b2) {

lcd_line_one(); lcd_write_string(PSTR("Please Select 2 Lanes X 3 Bottles ")); lcd_line_two(); lcd_write_string(PSTR(" Or ")); lcd_line_three(); lcd_write_string(PSTR("Select 3 Lanes X 4 Bottles ")); lcd_line_four(); lcd_write_string(PSTR(" To enable the Bottle Drop Jam Alarm "));

}

return 0; }

March 09, 2012
by dvdsnyd
dvdsnyd's Avatar

Just put the code in indented form so it is a little easier to see what is going on.

// initialload.c// for NerdKits with ATmega168 // mrobbins@mit.edu
define F_CPU 14745600
include <stdio.h>
include <avr/io.h>
include <avr/interrupt.h>
include <avr/pgmspace.h>
include <inttypes.h>
include "../libnerdkits/delay.h"
include "../libnerdkits/lcd.h"

//****Inserted code****

// Set the 5 pins to input mode - 3 eyes, 2 select buttons ( 2 lanes 6 bottles or 3 lanes 12 bottles), DDRC &= ~(1<<PC0); // set PC0 as input DDRC &= ~(1<<PC1); // set PC1 as input DDRC &= ~(1<<PC2); // set PC2 as input DDRC &= ~(1<<PC3); // set PC3 as input DDRC &= ~(1<<PC4); // set PC4 as input

// turn on the internal resistors for the pins

PORTC |= (1<<PC0); // turn on internal pull up resistor for PC0 PORTC |= (1<<PC1); // turn on internal pull up resistor for PC1 PORTC |= (1<<PC2); // turn on internal pull up resistor for PC2 PORTC |= (1<<PC3); // turn on internal pull up resistor for PC3 PORTC |= (1<<PC4); // turn on internal pull up resistor for PC4

// declare the variables to represent each bit uint8_t a1; uint8_t a2; uint8_t a3;

uint8_t b1; uint8_t b2;

//***Inserted code****

int main(intc) {

// fire up the LCD lcd_init(); lcd_home();

// busy loop while(1) {

uint8_t b1 = PINC & (1<<PC3) uint8_t b2 = PINC & (1<<PC4)

if (uint8_t b1) { // If button 1 is pushed must push reset to unlock it and //make another selection

lcd_line_one(); lcd_write_string(PSTR(" You have selected ")); lcd_line_two(); lcd_write_string(PSTR("*****")); lcd_line_three(); lcd_write_string(PSTR("the Bottle Drop pattern 2 lanes X 3 Bottles ")); lcd_line_four(); lcd_write_string(PSTR("Must reset before making another selection ")); }

if (uint8_t b2) { // If button 2 is pushed must push reset to unlock it and //make another selection

lcd_line_one(); lcd_write_string(PSTR(" You have selected ")); lcd_line_two(); lcd_write_string(PSTR("*****")); lcd_line_three(); lcd_write_string(PSTR("the Bottle Drop pattern 3 lanes X 4 Bottles ")); lcd_line_four(); lcd_write_string(PSTR(" Must reset before making another selection "));

}

if ~(uint8_t b1) & ~(uint8_t b2) {

lcd_line_one(); lcd_write_string(PSTR("Please Select 2 Lanes X 3 Bottles ")); lcd_line_two(); lcd_write_string(PSTR(" Or ")); lcd_line_three(); lcd_write_string(PSTR("Select 3 Lanes X 4 Bottles ")); lcd_line_four(); lcd_write_string(PSTR(" To enable the Bottle Drop Jam Alarm "));

}

return 0; }
March 09, 2012
by dvdsnyd
dvdsnyd's Avatar
make-c ''/libnerdkits make: ''/libnerdkits: no such file or directory make: [bottle_jam.hex] error 2

My modified make file:

GCCFLAGS=-g -Os -Wall -mmcu=atmega168 LINKFLAGS=-Wl,-u,vfprintf -lprintf_flt -Wl,-u,vfscanf -lscanf_flt -lm AVRDUDEFLAGS=-c avr109 -p m168 -b 115200 -P com3 LINKOBJECTS=../libnerdkits/delay.o ../libnerdkits/lcd.o ../libnerdkits/uart.o

all: bottle_jam-upload

bottle_jam.hex: bottle_jam.c make -C ../libnerdkits avr-gcc ${GCCFLAGS} ${LINKFLAGS} -o bottle_jam.o bottle_jam.c ${LINKOBJECTS} avr-objcopy -j .text -O ihex bottle_jam.o bottle_jam.hex

bottle_jam.ass: bottle_jam.hex avr-objdump -S -d bottle_jam.o > bottle_jam.ass

bottle_jam-upload: bottle_jam.hex avrdude ${AVRDUDEFLAGS} -U flash:w:bottle_jam.hex:a
March 09, 2012
by pcbolt
pcbolt's Avatar

David -

Is there a file called "Makefile" inside your libnerdkits directory? And is that directory at the same level (i.e. common parent directory) as your bottle_jam directory? If so, could you please post the contents of that file as well?

March 10, 2012
by Rick_S
Rick_S's Avatar

David, along what pcbolt was saying...

The standard NerdKit makefile assumes a certain directory (folder) structure. The reason for this is that it keeps thier libraries in a common directory for all their projects. Those libraries are the LCD, UART, and DELAY libraries. In the standard setup, there is also a shared makefile in the libnerdkits directory that creates the object files for those libraries. If your program uses any of those, you will need to keep your project directory in the NerdKit CODE directory so the structure would look something like this:

Code─┐
     │
     ├── bootloader168
     ├── bootloader328P
     ├── dip_arithmetic
     ├── dip_arithmetic_edu
     ├── initialload
     ├── led_blink
     ├── libnerdkits
     ├── tempsensor
     ├── tempsensor_edu
     ├── trafficlight
     └── YOUR PROJCET DIRECTORY

Using this structure would allow your makefile to find the library files and your error should go away.

It can be done other ways but that requires a bit more work in the makefile.

Rick

Post a Reply

Please log in to post a reply.

Did you know that NerdKits has been featured in the MIT Undergraduate Research Journal? Learn more...