Show Posts
|
|
Pages: [1] 2 3 ... 5
|
|
2
|
Products / Arduino Due / Simple way to convert from Floating point to String
|
on: May 13, 2013, 08:23:47 pm
|
Well, I searched for some time on the Internet for an reliable way to convert from a floating point to String, but I found none in 10 secconds and did my self that. If you need, this is the code (Also explained a bit): String floatToString(float f, int decimals = 2){ /* Transforms the floating point string process: eg.: using decimals = 2, input: 1.23456 1.23456 * (pow(10, 2+1) 1.23456 * 1000 = 1234 (as a long) now, let's move digits asside: 3 goes to 4, 2 goes to 3. Stages: "1234" "1233" "1223" Not, put a dot in the place of the separator "1.23"
*/ long fLong = f*(pow(10,decimals+1)); String longString = String(fLong); int len = longString.length();
for(int i = 0; i < decimals; i++){ longString[len - 1 - i] = longString[len - 2 - i]; } longString[len - decimals - 1] = '.';
return longString; }
|
|
|
|
|
3
|
Products / Arduino Due / INSTRUCTIONS to skip verification
|
on: May 12, 2013, 12:48:45 am
|
|
Hi, I was getting furious, because my sketch already had 140kb, and was taking about 1 minute to upload.
Then, I figure out how to "skip" verification (The second "stage" of upload).
To disable verification, go to: ArduinoSoftwareFolder/hardware/arduino/sam/plataform.txt
Then, open it and go to the last line (It's what "calls" bossac to upload the sketch). Find the following section: "-e -w -v -b" and alter it to: "-e -w -b" (just remove the "-v", witch means: VERIFY code after upload).
After all, it should be like this: tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -e -w -b "{build.path}/{build.project_name}.bin" -R
Save the file, close and open Arduino IDE. Select another plataform and select Arduino Due Programming port just to make shure.
Have fun.
|
|
|
|
|
4
|
Products / Arduino Due / [gitHub] THREAD and THREADController classes for Arduino
|
on: May 11, 2013, 01:39:57 am
|
Hi, I always use this library for myself, and I personaly think that is VERY usefull. Its clear that Arduino doesen't support real parallel processes, but we can "sort" of do it with scheduled tasks. Yes, there is already an class called "Scheduller", but for big projects (likes the ones I do, with more than 15.000 lines), it's not "good" enought... I LOVE Object Oriented stuff, and this follows it pretty much. Check out the library here: https://github.com/ivanseidel/ArduinoThreadIt also works for ANY arduino, but I implemented thinking on the DUE, since it's capable of more stuff (I use it with my ArduinOS, and it's just perfect =] ) Any suggestions are welcome!
|
|
|
|
|
5
|
Development / Other Software Development / [gitHub] Thread and ThreadController classes for Arduino
|
on: May 11, 2013, 01:27:28 am
|
Hi, I always use this library for myself, and I personaly think that is VERY usefull. Its clear that Arduino doesen't support real parallel processes, but we can "sort" of do it with scheduled tasks. Yes, there is already an class called "Scheduller", but for big projects (likes the ones I do, with more than 15.000 lines), it's not "good" enought... I LOVE Object Oriented stuff, and this follows it pretty much. Check out the library here: https://github.com/ivanseidel/ArduinoThreadAny suggestions are welcome!
|
|
|
|
|
8
|
Products / Arduino Due / Re: Servo library + timer library?
|
on: April 30, 2013, 05:57:49 pm
|
|
Can you detail the problem? I mean, what happens when you create both Servo and Timer? No one works, the last one works...
And also, have you tried using others timers (0,1,2,3,4,5,6,7,8)?
Did you used my library? github.com/ivanseidel/DueTimer
Ivan
|
|
|
|
|
11
|
Products / Arduino Due / HIDDEN Analog PINS (52, 20 and 21)
|
on: April 27, 2013, 12:39:50 pm
|
|
Hello! This days I was looking at the SAM3X datasheet and notice one WEIRD thing: It said that arduino has 15 Analog ready pins, but when I read the Arduino Due page, there was only 12 listed as Analog...
This is what intrigued me to find a solution to enable the others 3 pins, since my project needed 13 (yes, one more than the available).
The pins, not marked as analog that Could "become" one is 52, 20 and 21.
Maybe Arduino guys did that to maintain the same "pattern" as the old arduinos, but, why not let it enabled? It only changes a few lines of code (to be exact, 6 lines).
I will create a new commit of the arduino in my github repository if any one wants..
|
|
|
|
|
12
|
Products / Arduino Due / Re: Timer Interrupts on Due
|
on: April 20, 2013, 03:12:08 pm
|
Using this code, you can set a timer for any of the ISRs TC0_Handler through TC8_Handler, see table of parameters below. It is possible to use the timers without a physically mapped pin, such as TC1 channel 0 (TC3_Handler) shown here: volatile boolean l;
//TC1 ch 0 void TC3_Handler() { TC_GetStatus(TC1, 0); digitalWrite(13, l = !l); }
void startTimer(Tc *tc, uint32_t channel, IRQn_Type irq, uint32_t frequency) { pmc_set_writeprotect(false); pmc_enable_periph_clk((uint32_t)irq); TC_Configure(tc, channel, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK4); uint32_t rc = VARIANT_MCK/128/frequency; //128 because we selected TIMER_CLOCK4 above TC_SetRA(tc, channel, rc/2); //50% high, 50% low TC_SetRC(tc, channel, rc); TC_Start(tc, channel); tc->TC_CHANNEL[channel].TC_IER=TC_IER_CPCS; tc->TC_CHANNEL[channel].TC_IDR=~TC_IER_CPCS; NVIC_EnableIRQ(irq); }
void setup(){ pinMode(13,OUTPUT); startTimer(TC1, 0, TC3_IRQn, 4); //TC1 channel 0, the IRQ for that channel and the desired frequency }
void loop(){ }
Here is the table of parameters: | ISR/IRQ | TC | Channel | Due pins | | TC0 | TC0 | 0 | 2, 13 | | TC1 | TC0 | 1 | 60, 61 | | TC2 | TC0 | 2 | 58 | | TC3 | TC1 | 0 | none <- this line in the example above | | TC4 | TC1 | 1 | none | | TC5 | TC1 | 2 | none | | TC6 | TC2 | 0 | 4, 5 | | TC7 | TC2 | 1 | 3, 10 | | TC8 | TC2 | 2 | 11, 12 |
Noob question here, could someone please explain the inputs to the startTimer function? What is channel, and how do we use the frequency input? Also, what are the pins in the table for? Can anyone kindly answer to the following question please? How can we disable the Timer by turning off the PWM? (Outside of Timer Function) Hi, If it's really needed to understand the code, i suggest you looking at the Datasheet, that is the best place to get those explanations since every uController is different. But, if you just want to use timers on arduino Due, install the DueTimer library: github.com/ivanseidel/DueTimer Regards, Ivan
|
|
|
|
|
13
|
Products / Arduino Due / Re: Timer Interrupts on Due
|
on: April 15, 2013, 11:10:21 am
|
Thanks guys for this mission. I got 1 MHz working on the DUE, but I found that digitalWrite is slow. So it messes up my tc_handler. Doesn't leave it anymore. And I need to write in the ISR, maximum control every microsecond. You have a fast alternative for digitalWrite ?
after configuring the pin, you can easily do as it follows: Output HIGH on PIN 0 of port D: REG_PIOD_SODR = 0x01; ( equivalent to: 0b0000000000000001); Output low on PIN 0 of port D: REG_PIOD_CODR = 0x01; ( equivalent to: 0b0000000000000001); And, to configure PIN 0 of port D as output pin: REG_PIOD_OER = 0x01; ( equivalent to: 0b0000000000000001); Notice, that even digital pins are buffered, so, trying to read this register, will return NULL or some random value... Also, writing more than one pin on the register will cause NO problem. Also, to know wich port the pin relates with, read the arduino description, right on top, there is an link to check this... There is one other easy way of doing this, but i'm without a computer right now...
|
|
|
|
|
14
|
Products / Arduino Due / Re: Timer Interrupts on Due
|
on: April 14, 2013, 12:41:34 pm
|
Henrimontreal, you are only getting the header - you need all the code which is packaged up as a library and placed within the Arduino IDE Library folder prior to writing your program. See http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use on libraries and how they are used. Then you can get the timer library, install it like in the tutorial, then your code will not give such error(s). Putting the .h file on your desktop is not enough. Well, this is so strange! Even though, I copy them into the Arduino's Library as well as the same folder on my desktop. I still have the same error!  I am so frustrated!  Hi, I have sent a new commit to GitHub, with a new organization to facilitate installation. Please, download egain ( https://github.com/ivanseidel/DueTimer/archive/master.zip) the files, and install as explained on Arduino site. Thanks, Ivan Seidel
|
|
|
|
|
15
|
Products / Arduino Due / Re: Timer Library for Arduino DUE
|
on: April 12, 2013, 12:54:52 am
|
Hi! As i like libraries, i have done one for Timers on the Arduino DUE. You can check it out here: https://github.com/ivanseidel/DueTimerAll 6 timers are fully implemented, and ready to play with... May I ask you how I can use your file? I cannot include any library from out side. Is there anyway to run within one file? I would like to use a timer and change the REG by Serial Monitor. Hi, If you want to include the library to your project, than all you nees to do is to copy DueTimer.h and DueTimer.cpp to your sketch folder and include it normaly (#include "DueTimer.h"). What do you mean by change REG? And might I ask why can't you install the library? Thanks, Ivan
|
|
|
|
|