|
153
|
Using Arduino / Microcontrollers / Re: ATMEGA2560v-Au Bootloader
|
on: March 22, 2012, 10:00:51 am
|
I cannot give an exact technical answer of how to CREATE the necessary modified bootloader. However, having done this exact thing successfully in the past, I recommend you try one of the following two approaches: (1) Get the already compiled file for Sparkfun's 3.3 V / 8 Mhz version of Mega2560 (hex file, credit Brett Hagman): http://code.google.com/p/wiring/downloads/detail?name=WiringBoot_sparkfun-megapro-8MHz.hexThen burn using avrdude commandline specifying "m2560" for the microcontroller (even though technically, the uC is Atmega2560-V version) (2) Or instead, if using Arduino IDE, first edit the "boards.txt" file in the appropriate arduino folder (for example) "arduino-0022/hardware/arduino/", by changing the following two parameters in the file: mega2560.upload.speed=57600
mega2560.build.f_cpu=8000000L
Then reload Arduino IDE, select Tools >> Board >> Arduino Mega 2560, then Tools >> Burn bootloader, and so on. Note: In both of the above cases, AFTER the bootloader is burned, I think you will get a msg toward the end as follows: "avrdude: verification error, first mismatch at byte 0x3e000... 0x0d != 0xff" This error can be ignored; Test it out by uploading a sketch, and it will work fine.
|
|
|
|
|
154
|
Using Arduino / Microcontrollers / Re: Bootloading Mega1280 to run @ 8 Mhz, 3.3 V
|
on: March 22, 2012, 12:39:01 am
|
Almost there! Specifically, bootloader upload worked great... HOWEVER, now when I try to upload (via standard FTDI-FT232 chip), the Arduino IDE states: avrdude: serial_baud_lookup(): unknown baud rate: 28800
How can this 28800 baud rate (different from the standard 19200 or 57600) be made possible in the sketch upload?
In the meantime, I'm trying to look through the Arduino folder for any possible config files that can be edited to allow this baud rate.
|
|
|
|
|
155
|
Using Arduino / Microcontrollers / [SOLVED] Bootloading Mega1280 to run @ 8 Mhz, 3.3 V
|
on: March 21, 2012, 06:43:10 pm
|
I'm doing an experiment with running an independent Atmega1280 chip in a breadboard-Arduino style (sort of). Works great with the default Arduino Mega1280 bootloader, with the chip running @ 5 Volts, 16 Mhz. However, my idea is to run the chip at 3.3 Volts, and thus with an external crystal of 8 Mhz, going by the allowed frequency suggested by datasheet. What would I need to change in the boards.txt file and/or other files, in order to burn the Arduino bootloader onto the Atmega1280, and facilitate the 3.3-V/8Mhz instead of the original 5-V/16Mhz?(Note: I'm using my Uno as the programmer device.) Currently, the boards.txt file says the following (default): mega.name=Arduino Mega (ATmega1280)
mega.upload.protocol=stk500 mega.upload.maximum_size=126976 mega.upload.speed=57600
mega.bootloader.low_fuses=0xFF mega.bootloader.high_fuses=0xDA mega.bootloader.extended_fuses=0xF5 mega.bootloader.path=atmega mega.bootloader.file=ATmegaBOOT_168_atmega1280.hex mega.bootloader.unlock_bits=0x3F mega.bootloader.lock_bits=0x0F
mega.build.mcu=atmega1280 mega.build.f_cpu=16000000L mega.build.core=arduino
|
|
|
|
|
157
|
Using Arduino / Sensors / Re: Mitutoyo Digimatic SPC
|
on: December 06, 2011, 09:35:09 pm
|
|
@Steve Spence: Congrats for persisting through all the difficulties and getting it finished. I'm interested in testing your code myself when I get a chance in the next couple of weeks. Since you already have your working code ready in the post above, perhaps you should put it together along with an image of your basic circuit hookup and put it in the Exhibition/Gallery section, or on the Playground.
|
|
|
|
|
159
|
Using Arduino / Sensors / Re: Mitutoyo Digimatic SPC
|
on: November 24, 2011, 08:43:42 pm
|
Glad to see someone else working on this interface (digimatic protocol which appears to be used in Mitutoyo calipers and a few other measurement devices). I wrote the original code that you seem to have started with. Wow at that time, struggled with finding related information on the internet and concluded that I was the only one in the world who needed to log mechanical/dimensional data  Below's the latest version; try it out... had sleepless nights with interpreting the BCD myself (note the strtoint function which was a temporary fix for the fact that the read binary-format values were in reverse), but following code should most likely work #include<stdlib.h>
int dat = 2; // pin 2 int clk = 3; // pin 3 int iclk = 1; int req = 5; // pin 5 - note to self: also try pin 4 instead (closer on Atmega328 chip for breadboard version)
int i = 0; int j = 0; int k = 0; const int kmax = 5; int mydata[52]; String mydata2[13]; int convint[13]; String mydata3 = "";
void setup() { Serial.begin(19200); pinMode(req, OUTPUT); pinMode(clk, INPUT); pinMode(dat, INPUT); }
void loop() { digitalWrite(req, HIGH); delay(25); digitalWrite(req, LOW); attachInterrupt(iclk, myisr, RISING); if (i > 51) { Serial.println(); for (j = 0; j < 13; j++) { Serial.print("--"); mydata2[j] = ""; for (k = 0; k < 4; k++) { mydata2[j] = mydata2[j] + mydata[(j*4)+k]; } Serial.print(mydata2[j]); } finalconv(); i = 0; } }
void myisr() { if(i < 52) { j = i % 52; mydata[j] = digitalRead(dat); i++; } }
int strtoint(String strtoconv) { if (strtoconv == "0000") return 0; if (strtoconv == "1000") return 1; if (strtoconv == "0100") return 2; if (strtoconv == "1100") return 3; if (strtoconv == "0010") return 4; if (strtoconv == "1010") return 5; if (strtoconv == "0110") return 6; if (strtoconv == "1110") return 7; if (strtoconv == "0001") return 8; if (strtoconv == "1001") return 9; if (strtoconv == "1111") return 0; }
void finalconv() { mydata3 = ""; long int myval; int mysign; String myunits = ""; float myfin; for (j = 0; j < 13; j++) { convint[j] = strtoint(mydata2[j]); switch(j) { case 0: break; case 1: break; case 2: break; case 3: break; case 4: if (convint[4] == 0) mysign = 1; else if (convint[4] == 8) mysign = -1; break; case 5: myval = convint[5]*100000; break; case 6: myval += convint[6]*10000; break; case 7: myval += convint[7]*1000; break; case 8: myval += convint[8]*100; break; case 9: myval += convint[9]*10; break; case 10: myval += convint[10]*1; break; case 11: switch (convint[11]) { case 0: myfin = myval / 1.00000; break; case 1: myfin = myval / 10.00000; break; case 2: myfin = myval / 100.00000; break; case 3: myfin = myval / 1000.00000; break; case 4: myfin = myval / 10000.00000; break; case 5: myfin = myval / 100000.00000; break; } break; case 12: switch (convint[12]) { case 0: myunits = "mm"; break; case 1: myunits = "in"; break; case 2: myunits = "mm +nogo"; break; case 3: myunits = "mm go"; break; case 4: myunits = "mm -nogo"; break; case 5: myunits = "in +nogo"; break; case 6: myunits = "in go"; break; case 7: myunits = "in -nogo"; break; default: myunits = ""; } break; } } myfin = myfin * mysign; Serial.println(); Serial.print(myfin,5); Serial.println(myunits); }
|
|
|
|
|
161
|
Using Arduino / Programming Questions / Re: Efficiency of multiple If conditions
|
on: November 05, 2011, 12:50:59 am
|
Or would Code2 also skip the whole line as soon as the 1st condition fails? This is what C does. Efficient, but can be a little surprising. Efficient, but can be a little surprising. Especially if the if test involves a function call, and you expect that function call to be made. Interesting. So in general, for such functions, it's probably better to store the function-return-value to a variable first (although that comes at the cost of one extra variable) and only then do any test that involves multiple conditions.
|
|
|
|
|
162
|
Using Arduino / Programming Questions / Efficiency of multiple If conditions
|
on: November 04, 2011, 05:18:47 am
|
A doubt that popped up while I was writing some simple code: Is worst-case number of operations in Code 1 fewer than Code 2 below? In Code1, if the 1st condition fails after reading Variable1, I assume the microcontroller won't even do any memory-read of Variable2 as it proceeds to skip the 2nd condition test. Whereas in Code2, since both conditions are within the same line of code, are they both treated as one unit and thus would the microcontroller do memory-reads together of both Variable1 and Variable2 right off the bat? Or would Code2 also skip the whole line as soon as the 1st condition fails? Code 1:if (Variable1 == ConstantX) { if (Variable2 == ConstantY) { DoAction(); } }
versusCode 2:if (Variable1 == ConstantX && Variable2 == ConstantY) DoAction();
|
|
|
|
|
163
|
Using Arduino / Programming Questions / Re: storing Serial bytes to a float variable
|
on: October 16, 2011, 08:41:15 am
|
|
That worked successfully. Thanks dc42. Why the null character at the end by the way?
And indeed arduino's implementation of double and of float appear to be identical: "The double implementation on the Arduino is currently exactly the same as the float, with no gain in precision." [http://arduino.cc/en/Reference/Double]
|
|
|
|
|
164
|
Using Arduino / Programming Questions / storing Serial bytes to a float variable
|
on: October 15, 2011, 04:04:49 am
|
|
I'm reading values from a sensor, coming in as serial data.
The values come in multiple Serial bytes as follows: For example a sensor reading of 2.16 comes in as the following four bytes: '2', '.', '1', '6' Fairly simple, and it's been easy to print those 4 bytes out individually just using mySoftSerial.read() for each incoming byte; and then Serial.print(...) the 4 bytes to the terminal.
However, I would like to STORE altogether the four separate incoming Serial bytes of the value "2.16"... specifically, I want to store into one float variable so I can do arithmetic with it. What would be an effective way to accomplish that?
Seems like a common thing to do, but I haven't come across any simple method.
[sidenote: I tried the approach discussed in a past thread, of using a union that has a float and a byte array, but that didn't solve the problem here because it appears the incoming data also has to have been sent out from a byte array originating from a union, which is not the case here]
|
|
|
|
|
165
|
Using Arduino / Storage / Re: ideas for storing/logging a LOT of measured data
|
on: October 09, 2011, 07:05:52 am
|
OK all, Thanks again for the insights. Here's a positive update: I've used the sdfatlib suggested by robtillaart; huge difference in speed using that library or using certain strategies with the regular SD.h, as suggested at this thread by the author of sdfatlib: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1293975555And I'm also using 512-byte blocks for storing data before writing to the SD card and things are going smoothly so far, I think. Will post a generic version of the code for general use when I'm done. I'm able to write each block of 512 bytes in around 60 milliseconds, which is fantastic, and doesn't really interrupt the flow of other things for my requirements.
|
|
|
|
|