Show Posts
Pages: [1]
1  Development / Other Software Development / Noob's Guide To Setting Up Codeblocks for Arduino Uno on Windows 7 on: February 12, 2011, 08:01:26 pm
Hello everybody. I am new to Arduino and new to c++. I wanted to move from the Arduino development environment for a variety of reasons. Based on what I read, and, in particular from this post http://arduino.cc/forum/index.php/topic,37631.0.html I spend about 4 days figuring out how to do it. I succeeded.

I think the problem is that some of the information is dated, or not directly relevant to my platform. I gave up trying to figure out why, but I ran into all kinds of problems which led me to new problems. Thanks to Google, and the fact I am stuck in a wheelchair for a few weeks, I was able to get, step by step, to the point where it all works. I am sure this is easy for a lot of people, but I'm an old guy and having slung code for a long time. I carefully (I hope) documented the process. I present it here for posterity. If anybody tries this and finds a problem, please let me know.

Here goes

General Warnings
I’m going to pretend your Windows 7 user name is mingy_desktop, but you;ll have to change it as needed.

Make sure you do not have a user name with an embedded space eg: mingy_desktop is, mingy desktop is not.
Unhide the C:\Users\mingy_desktop\AppData directory. I did this through the command prompt: Go to c:\users\mingy_desktop and type appdata attrib -H

If at some point you are trying again or ‘stuck’ uninstall CodeBlocks and delete all relevant associated data, which is found in C:\Users\mingy_desktop\AppData\Roaming\codeblocks. Remove the directory

Understand that every time you modify ArduinoProject.cbp, you have to close the project and create a new one. CodeBlocks will not recognize those project changes on an existing project.

1 )   Start Arduino and compile a simple sketch, like blink. Without closing Arduino, open Explorer and search for ‘core.a’. Make a folder C:\arduino-022\libArduinoCoreAT328p and copy core.a to that folder. Arduino core.a when it closes, so it can bet tricky to find. Mine was in C:\Users\mingy_desktop\Local\Temp\build7176365035724894050.tmp

2 )   Install WinAVR

3 )   Install Codeblocks

4 )   Run Codeblocks
         a.   Set GNU AVR GCC compiler as your default compiler
         b.   File New Project - AVR Project
         c.   Make sure C:\WINAVR-20100100\avr\include is in your search directories (Complier and debugger setting) (or wherever your winavr include directory is)
         d.   May as well make sure C:\arduino-022\hardware\arduinocores\arduino is in your search directories (You’ll need to add a bunch more of these as you develop more and more code)
         e.   File Save Project as Template and name it ArduinoProject

5 )   Close Codeblocks

6 )   Find the Codeblocks User Templates. Mine were in C:\Users\mingy_desktop\AppData\Roaming\codeblocks\UserTemplates\ArduinoProject

7 )   Copy the attached file start.cpp to (eg) C:\Users\mingy_desktop\AppData\Roaming\codeblocks\UserTemplates\ArduinoProject\start.cpp

8 )   Copy the attached ArduinoProject.cbp C:\Users\mingy_desktop\AppData\Roaming\codeblocks\UserTemplates\ArduinoProject\ArduinoProject.cbp

9 )   Note that the ArduinoProject.cbp file may have to be modified in that your COM port may not be COM3 (check in Arduino or the device manager and avrdude.exe may be elsewhere. I believe the one which comes with Arduino is out of date, thats why I use the version which comes with WinAVR

10)   Now, run CodeBlocks and File New FromTemplate User Templates Arduino Project. Tell it to create the project in a folder with no spaces in the name like AVRTest and with a name with no spaces like ArduinoProject.

11)   Select Build Target Debug and build the project. Most errors are because the Settings Compiler and Debugger Search Directories need to be filled in. Note that if you save source files like start.cpp from CodeBlocks, they’ll be saved to the project directory, not the templates directory, so use notepad or something to edit them in the templates directory.

12)   Make sure Arduino is closed, plug in your Arduino Uno, Select Build Target Release and build the project. You should compile fine because you have already tested that, however you may have problems with the programmer. If that happens, copy the command line which gets echoed in the CodeBlocks Log & Others window at the bottom of the screen. Open a DOS shell and past that line into the command line.

      C:\WinAVR-20100110\bin\avrdude.exe -CC:\WinAVR-20100110\bin\avrdude.conf -V -F -c arduino -pm328p -P COM3 -U flash:w:D:\TempAVR\bin\Release\ArduinoProject.elf.hex:a

It is easier to figure out what is wrong from the DOS command line because you can edit the line over and over. You can you a working command line as a prototype for the ArduinProject.cpb line.

13)   If everything works ok you should get a message like
                 avrdude.exe: 13294 bytes of flash written
                 avrdude.exe done.  Thank you.
                 Process terminated with status 0 (0 minutes, 3 seconds)
                 0 errors, 0 warnings

        If you get some sort of synch or protocol error, check to make sure your com port settings agree with the ArduinoProject.cbp settings you made. Baud rate doesn't seem to matter

14)   Open the Arduino serial port monitor. You should see a message
                 Hello from Arduino Code::Blocks template


Thats it!

I hope this proves to be of some use to someone!

Good Luck
2  Using Arduino / Sensors / Re: Noob with 18S20 Weirdness on: February 10, 2011, 12:02:12 pm
nayma

That's great! I only picked up one at the store, but I did get a similar Temperature/Humidity sensor. I figured once I got it to work I'd go buy some more, but then I broke my leg and I'm stuck in wheel chair for a few weeks at least smiley-sad

What type of project are you working on?

A few years ago I built a house with hydronic heating (hot water in the floor) and I want to accomplish a few things with my project:
1) Remotely monitor/alarm room temperatures and the function of the geothermal system
2) Better control the 'zoning' so I don't waste energy over heating rooms.

I figure an Arduino with an Ethernet shield, some temperature sensors, and an I/O board (opto triacs and opto isolators) should do it.


3  Using Arduino / Sensors / Re: Noob with 18S20 Weirdness More Info on: February 07, 2011, 01:47:18 pm
I don't see I can edit the prior post, but the root problem comes from the fact the example sketch calls

 sensors.requestTemperatures(); // Send the command to get temperatures

instead of

 sensors.requestTemperaturesByAddress(insideThermometer); // Send the command to get temperatures

the 'by address' call looks at the LSB of the device address, recognizes the device as an 18S20 and inserts a 750mS delay. The sensors.requestTemperatures(); call does not do such a check as it looks at the device resolution (9 bits) and uses a 94 mSec delay

Still working on the power state misread - though it does not seem to affect the operation of the device.

4  Using Arduino / Sensors / Re: Noob with 18S20 Weirdness *** Solved *** on: February 07, 2011, 01:04:21 pm
Just in case anybody else comes looking, I found in another Arduino forum that the 81S20 wants a delay (used 750 mSec) between issuing the read temp command and reading it back.

I don't know why it thinks its in parasitic mode (I'm working on it) but I can now read the correct temperature.

 smiley
5  Using Arduino / Sensors / Noob with 18S20 Weirdness on: February 06, 2011, 06:54:05 pm
Hello and thanks for your patience. I an new to Arduino, but I did digital design and micro controller apps for over a decade ending about 15 years ago. I know c cold, but c++ is a 'work in process' at the moment.

I am trying to build a home monitoring system. I successfully downloaded and ran applications for a DHT22, and now I'm trying ot do the same for an 18S20. I have pretty much used the various application examples such as the Arduino Onewire library and the library for Dallas Temperature ICs. In the Dallas Library it says "DS18S20 - Please note there appears to be an issue with this series." but it doesn't say what that issue may be or how it presents itself.

Besides redefining the I/O pin, I added a couple lines of code to trace. This is what I get from the code

Dallas Temperature IC Control Library Demo
Locating devices...Found 1 devices.
Parasite power is: ON
Device 0 Address: 10CFDFDB01080039    Device 0 Addr[0] 10
Device 0 Resolution: 9
Requesting temperatures...DONE
Temp C: 85.00 Temp F: 185.00


The first bit of weirdness if that I have wired the device not to use Parasite Power, but it is reporting that it is using parasite power. Whether I wire it as parasitic or not and whether I 'force' the code to not use the parasite power, the reported temperature is always 85.00/185.00 (its about 25/80) in my room.

The fact the device reports an address is encouraging as it shows its not dead.

Are there any suggestions? Does anybody know what the 18S20 'issues' are?

Thanks
Pages: [1]