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.

Everything Else » Make Arduino Duemilanova run NerdKit C code.

February 11, 2010
by feilipu
feilipu's Avatar

Just got a NerdKit, and this is my first post...

Although it was fun to put the it all together and make it work, I like stable power and comms, so I also just bought a Duemilanova to play with too.

But, also not liking IDE programming, much less dirty code that has "wiring" in it, I thought it might be nice to run NerdKit C code on the 328p in the Duemilanova.

Following the simple instructions from the pdf in the ATmega328P Upgrade Nano-Guide gets you most of the way.

In the .c code file you're writing change the CPU speed definition from

#define F_CPU 14745600 // for NerdKit

to

#define F_CPU 16000000 // for Duemilanova

To make avrdude work these parameters are needed for the make file:

AVRDUDEFLAGS=-c stk500v1 -p m328p -b 57600 -P /dev/ttyUSB0

Press the "S1" button on the board simultaneously with your make or avrdude command

It works. That's all!

February 11, 2010
by Phrank916
Phrank916's Avatar

There are some really nice arduino based boards and dev-board kits out there. I really like the RBBB kit from Modern Device. It's super-small and pretty cheap. I was thinking of buying it to use as another development platform, but I am pretty sure that when I do, I'll simply wipe the Arduino bootloader and install the NerdKits foodloader or just use my ISP to program it directly. This is very good info though for anyone wanting to use one of these kits and they don't happen to have an ISP.

Ted

February 11, 2010
by dav1dr4y
dav1dr4y's Avatar

Cool. Good information. I also have a Nerdkit and a Arduino Duemilanove. (Also have a Basic Stamp and am thinking of getting a PICAXE. uc junkie.) I was interested in your idea. But I also like using the IDE for Arduino. I like options. I thought I read that any .hex file ought to work in the Arduino (and the reverse I presume). To test this I took the LED_Blink.c that comes with Nerdkit and modified it to use pin PB5 instead of PC4, which corresponds to digital pin 13 (with the built in LED) on the Arduino. I started it running on my nerdkit. I then uploaded the LED_Blink.hex file to my Arduino using essentially the AVRDUDE parameters you give above. I used a GUI to start AVRDUDE called ArduinoUploader (found at ngcoders.com). Anyway, the program ran as expected there. So, the lesson for me is I can keep the Arduino bootloader and use the Arduino IDE when I want and also upload non-IDE, non-Wiring code when I want also.

I should be able to do the reverse also. Upload Arduino IDE generated .hex files to my Nerdkit bootloader ATMega... but I can't (yet) find what Arduino does with the .hex files.

Anyway, thanks for gettin' me going on this train of thought.

/David

(I am unclear on what is 'bad' about Wiring. The Arduino code seems like c code to me. I guess that shows my limited understanding of the programming so far.)

February 11, 2010
by dav1dr4y
dav1dr4y's Avatar

Ok, I figured out how to find the hex file that Arduino generates. (Hold down the shift key during a compile or compile/upload and the verbose output shows the path to the temp directory where it is stored.) After changing the board to Diecimila 168 and recompile I was able AVRDUDE the hex up to the Nerdkit chip and it ran fine.

Now that I have done this and re-read this thread I think I misunderstood feilipu. But Phrank916 was talking about replacing the bootloader on the Arduino'd chip. Anyway, I'm happy to have both kits and be able to run programs made with or without the Arduino IDE on either.

/David

April 08, 2010
by esoderberg
esoderberg's Avatar

I'm trying to load an ATmega168 Duemilinova with code used on the Nerdkit.

I've tried using the update to the makefile given by feilipu

AVRDUDEFLAGS=-c stk500v1 -p m328p -b 57600 -P /dev/ttyUSB0

with m168 replacing the m328p as well as replacing /dev/ttyUSB0 with COM2

I get

stk500_getsync(): not in sync: resp 0x00

stk500_disable(): protocol error, expect 0x14, resp 0x51

with no success.
Any guidance would be appreciated.

May 26, 2010
by DrNoExpert
DrNoExpert's Avatar

I got into microcontrollers with the nerdkit, yet now I want to expand on programming languages. Right now I'm working on PICAXE, yet the only problem is that they have low amounts of memory, and the PIC have higher memory for the price. is it possible I can program a PIC microcontroller with a PICAXE programmer?

May 27, 2010
by dav1dr4y
dav1dr4y's Avatar

This is probably not the best place to get the best PICAXE info. You know the PICAXE is a PIC with a BASIC interpreter pre-programmed into it? Clearly that has a memory cost. I imagine you may also know the 20, 28 and 40 pin X1 and X2 versions of the PICAXE have quite a bit more memory than the smaller ones.
Programming a PIC with a PICAXE? I kinda doubt it. Better to ask this of the relevant experts though. Probably at PICAXE Forums. I recommend reading at and buying at PHAnderson's PICAXE Stuff

/David

October 16, 2010
by n_brei
n_brei's Avatar

I am trying to use the NerdKits USB cable to program an Arduino Pro Mini. As far as I can discern from the Internet, Arduino wants my laptop to trigger a reset via DTR or RST, aka BLK or GRN, neither of which wires exist on the NerdKits USB cable.

I figured I could press the physical reset button. Alas, this doesn't seem to work. Accompanied by a lot of flashes from the onboard green LED:

Binary sketch size: 920 bytes (of a 30720 byte maximum)

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding

What am I missing, and where would I otherwise find the info I am missing?

The alternative would be to find the hex file and try to run avrdude manually, but the 'hold shift while uploading' trick doesn't seem to be doing what you guys said it should be doing.

October 16, 2010
by n_brei
n_brei's Avatar

Update: Never mind.

However, I still don't see verbose output when I hold down shift when I compile inside the Arduino IDE...

Could someone point me to the temporary hex file path on a Mac?

October 17, 2010
by Ralphxyz
Ralphxyz's Avatar

Just using Searchlight to search for the file name should show you the .hex file. Hold your mouse over the results to see the path.

Ralph

May 06, 2011
by Snoogie2563
Snoogie2563's Avatar

OK, I guess I'm newer than new at this. What exactly is an Arduino and how does it differ from what you do to program the ATMega 168 that the NerdKit is based on. I'm really confused because they both (NerdKit and Arduino) use ATMega MCUs made by AVR. I've seen the term IDE tossed around and seen statements made to the effect that the Arduino saves you a lot of headaches associated with microcontroller programming. Can somebody enlighten me?

May 06, 2011
by 6ofhalfdozen
6ofhalfdozen's Avatar

Heya Snoogie2563,

They are the same exact chip but are running different bootloaders and because of that they run different chip programming software/languages. So, same chip, different "software" for the hardware. Clear as mud, right?
The nerdkit runs the atmel AVR type C code using "gritty" code with bit shifts and most "rawer" forms of code. While the Arduino runs a similar type of C that has a lot of things renamed and a lot of prebuilt code chunks to simplify things for the user. They also use "sketches", though to be honest, I don't really know what they are except that there is a lot of mentions of them in the arduino discussions elsewhere.

An IDE is a seriously overworked little acronymn and tends to mean a lot of things to a lot of different people in soo many places. In this context, it is supposed to mean "Integrated Development Environment" which means all the bits and bobs needed to do programming; code editor, compiler, linker, assembler, etc ad nausem.. In general discussions like this, it tends to mean "programming software."

Anyhow, I don't know for certain as I haven't actually worked on an arduino, but I have heard that they are slightly "easier and faster" to use on the code side. dunno, but thats what some say.. hope that helped a little..

May 06, 2011
by bretm
bretm's Avatar

Arduino is also a hardware specification. It defines the exact layout of the headers on an Arduino board so that anyone can make their own board and ensure that it is compatible with Arduino shields, which are hardware extensions.

The way I think of it is NerdKit is for learning first and then building, and Arduino is for building first and then learning.

Since everything is already assembled when you get an Arduino board you can get new projects up and running quickly. But you haven't necessarily learned how those parts work, and it's not exactly embeddable unless you want to leave your Arduino board embedded in a project and shell out $30 for another one.

NerdKit requires some assembly, but the parts are easily embeddable into other projects and less expensive to reorder. And you end up with a better understanding of the low-level stuff so that you can do things like design your own Arduino board or shield.

May 07, 2011
by dav1dr4y
dav1dr4y's Avatar

Snoogie2563, None of the comments here are wrong but I don't they give the real sense of what an Arduino is. I started out on Nerdkit and still feel fond of it. I have also messed with PIC, PICAXE and done quite a bit of stuff with Propeller. But I find what I most often return to is Arduino.
It is true that the official Arduino board is about $30. The are lots of variations at various prices too. But the basic Arduino hw is almost identical to Nerdkit. You can build your own on a breadboard just like Nerdkit. See Arduino on a breadboard. The main differences are that Arduino bootloader detects programming during bootup rather than Nerdkit requiring you to flip the program switch. Arduino then boots automatically into your program without flipping a switch and hitting reset. (Another diff is all Arduinos for the last couple years use the 328 instead the 168. That mainly means more memory. They are essentially identical othewise.)

Like 6ofhalfdozen said, IDE stands for integrated development environment. In Arduino's case this means an editor for programming, with syntax highlighting and a button to push to compile, build, load your program and start it all in one step. It also has a simple terminal built for serial IO. The Arduino IDE uses Avrdude to load the device just like Nerdkit only you don't normally see it.

The Arduino programming language is very C and C++ like. I am not enough of an expert in either to tell you exactly the difference. It does not have C++'s object oriented stuff. In fact Arduino uses gcc to compile like Nerdkit. Arduino adds, through libraries and preprocessing, some simplifing ambiguation of the hardware. For example, all IO pins are given a name. DigitalWrite(8, HIGH) will set "pin 8" high without having to know that "pin 8" is really PORTB bit 2. (There is a mapping of Arduino "pins" to 168/328 pins on the link above.) These features are really what makes an Arduino an Arduino in my opinion. The hardware is not that special. (Ironically, what I am saying "makes" an Arduino is really 'Wiring' but Arduino implemented Wiring more successfully than Wiring did. But that is another story.)

This coolness comes at a cost. One that some people make much of is that DigitalWrite prevents you from understanding what is really going on. This true to a degree. But in my experience getting something working is a major step in an on going process of understanding. There is nothing preventing you from learning what is going on at the hardware level. In fact, the more significant issue will motivate to learn exactly that. The big cost is speed. DigitalWrite is much slower than PORTB |= B00000010; So after you have a couple versions of your code working and you are trying to more speed out of it there is nothing to stop you replacing DigitalWrite with direct port manipulation. The Arduino environment is not so restricting as some people sometimes imply. (I am just using DigitalWrite as an example.)

Finally, a really nice thing is what is nice about Nerdkit. The community support. Only, and I cannot think of a gentle way to say this, there must be 2 or 3 orders of magnitude more. I am big on having examples to get me going. It seems I can find an example of almost anything for Arduino on the internet. Especially interfacing to this or that chip.

Really finally... It does not have to either/or. Concepts are transferable both ways. I have and like both. Check it out. Have fun.

/David

May 07, 2011
by Rick_S
Rick_S's Avatar

Very well put. One other thing I might add is that if you did purchase an arduino for the convenience of a pre-built dev board but wanted to stick with the NK development environment you can. All you have to do is change the name of the programmer from avr109 to arduino and specify the correct com port for the arduino. Then AVRDUDE will use the arduino bootloader to automatically program the chip from the command line. (I think the arduino progammer option was added to later versions of AVRDUDE so if you have an old version it may not work).

I also purchased an arduino clone in kit form off ebay a while ago. I socketed the crystal on it that way I could actually use a NK micro with the NK crystal on the board. It makes for a great little standalone board and frees up breadboard space. All I had to add to program it was a switch between digital8 (pin14) and ground for programming.

Rick

July 24, 2011
by lavared
lavared's Avatar

Hi All,

I have also been thinking about the same issue. Actually my problem is I have a RGB matrix code (developed in arduino environment) which runs perfectly fine with the arduino board (tested it with Arduino Uno board). But when I make changes to the code (w.r.t data types, port definitions and replacing inbuilt functions like digitalwrite, pinmode etc) to adapt it to my Nerdkits setup, the program does'nt run even though it compiles very well. The only difference I see is the crystal clock freq 14.7MHz in Nerdkits whereas 16MHz in arduino board. Otherwise everything is the same i.e. port deinitions, connections etc.

Reference to Arduino Code: http://blog.spitzenpfeil.org/wordpress/wp-content/uploads/2008/10/matrix_code.pde

Reference to my Nerdkits code: http://www.nerdkits.com/forum/thread/1658/

Can anybody guess what could be the reason for this discrepancy ?

Thanks.

July 27, 2012
by raildoc
raildoc's Avatar

How about Arduino Leonardo using ATmega32U4? In addition to bigger memory, built-in serial communication, and higher speed could be very advantageous. Might make a nice next-generation NK.

Post a Reply

Please log in to post a reply.

Did you know that you can see each keypress on a computer keyboard on an oscilloscope? Learn more...