Show Posts
Pages: [1]
1  Using Arduino / Project Guidance / Re: create a function with assembly on: September 29, 2013, 08:43:38 am
Ok, well the ide can be modified to compile .s files.

CATCH: Once you do this the teensyduino stuff won't work because it won't be there. Also the teensyduino installer won't recognize the arduino folder. Perhaps I copied the new files incorrectly?

The inline assembly does work though. Thanks for the tip.
From the main sketch.
__asm__ ("\n"
                  "\ pants\n"
                  "\t.type   pants, @function\n"
                  "\tldi r24,lo8(0)\n"
                  "\tldi r25,hi8(0)\n"
                   "\t.size   pants, .-pants\n");
extern "C" int pants();

void loop()
2  Using Arduino / Project Guidance / create a function with assembly on: September 29, 2013, 01:50:47 am
Im having some difficulty with timing on an interrupt function on a teensy2 board I have. I have int1 configured to interrupt on falling edge and the function toggles a digital output and is done. Im seeing a 7 microsecond delay (with oscilloscope) due to overhead in the c function (pushing a ton of registers).

I need to find a way to define this function fully in assembly yet retain using the arduino libraries so that I can reduce the interrupt function overhead (5 clock cycles at  mhz according to the datasheet gives about 625 nanoseconds delay.
3  Using Arduino / Project Guidance / Re: producing serial output at regular (slow) intervals on: April 24, 2011, 01:18:06 pm
The code is lengthy, but I will abbreviate it for analysis.

void setup()
  //setup serial
  //set pins for digital read/write as required
  //install interrupts for wheel count sensor (attachInterrupt)

void loop()
  //wait for external signal to start
  //timed serial output would start here in current organization
  for (int i = 0; i < NUM_TASKS; i++)
      case whatever:
        //call function that does something, returns when task is completed
      //more cases to check for
  //programmed set of tasks has been completed

In its current state this is what happens:
loop() does not repeat until the entire set of programmed tasks has been completed. Each task function only returns when that task has been completed.

In order to use polling on millis() I would have to restructure the code so that every task function exits immediately instead of exiting when the task has been completed.

Is it worth my while to reorganize the code to what would essentially be a big state machine in order to use polling for serial output?

I think the only limiting factors for using serial output in an interrupt routine would be the use of PWM outputs and external interrupts for the wheel sensors (looks like I will use 4 external interrupts total). Serial input is not a big concern as I am only interested in one-way serial communication (the code is runs autonomously once started)
4  Using Arduino / Project Guidance / producing serial output at regular (slow) intervals on: April 24, 2011, 08:53:22 am
I have a project where I would possibly like to have some serial data (CSV values) output at a regular interval (about 10 Hz). Because of the way the program is currently structured, it is not feasible for me to poll millis() to check if 100 milliseconds has passed, but I have read a lot of people say to not use serial output in interrupt routines.

I have configured a baud rate of 115200 bps. The amount of serial data to output is about 17 bytes. I also have a pair of interrupts to handle wheel count sensors (I will probably have to implement some hardware to reduce the frequency of this - this part is easy).
5  Using Arduino / Project Guidance / Re: 40W of LEDs on one PWM out on: April 24, 2011, 08:42:14 am
An npn transistor can be used to provide the higher gate voltage of a MOSFET. Just be sure to use appropriately sized resistors on the base and collector.
6  Forum 2005-2010 (read only) / Development / Re: alternator regulation on: April 29, 2009, 10:11:59 pm
I plan on posting results on my website My current plan is to use the ready-welder (spool gun for mig welding). When it is ready, you should be able to stick weld with it, but I don't know a whole lot about welding.
7  Forum 2005-2010 (read only) / Development / Re: alternator regulation on: April 28, 2009, 12:06:35 am
Well I wanted to get an idea of what kind of software you guys would use to accomplish this. I am pretty fluent in C/C++ (from which I gather the arduino language is based on) so writing code for this wouldn't be a problem. I was wondering what kind of algorithm would work well for this.
8  Forum 2005-2010 (read only) / Development / alternator regulation on: April 23, 2009, 12:08:32 am
I have in mind to use the arduino to regulate the voltage output of the alternator in a vehicle. I will be using the arduino Mega board.
I could just use the internal regulator, or the factory external regulator, but they just don't do the kind of things I want them to do.
I want to disconnect the alternator from the vehicle (possibly including ground), increase the output voltage and do some welding with the alternator. I read an article about PID regulating systems, but forgot where it was.
I know I will need appropriate devices to interface with the alternator (voltage dividers, transistors, input protection, etc).
Then there are the endless possibilities of what else I can do with the arduino mega on a vehicle. I already have preparations to use it as an electric fan controller (two speed taurus fan).
9  Forum 2005-2010 (read only) / Development / Re: stk500v2 programmer sketch on: December 08, 2010, 11:24:30 pm
Anybody interested in testing this out as I add features?
10  Forum 2005-2010 (read only) / Development / Re: stk500v2 programmer sketch on: November 24, 2010, 11:31:47 am
Sure, I am using software SPI.
When I send the commands for read flash, the first byte appears to be returned successfully, but all the other bytes return the low byte of the address instead of what was actually read.

I am implementing a routine that sends the command byte, the two bytes for address (load address is implemented), and a 0 byte to retrieve the value. The second command does a bitwise of the command byte and 8 before sending. Every command after the first read command just returns the low byte of the address.

EDIT: Hmm, I think I fixed it. I forgot to save the command byte to a temporary variable before overwriting it with the response data.
11  Forum 2005-2010 (read only) / Development / stk500v2 programmer sketch on: November 24, 2010, 02:10:29 am
I started work on a sketch (may be made into a library later) that implements the stk500v2 protocol for programming atmel AVR microcontrollers. The best progress I have made so far is reading fuses. I'm working on the read flash routine, but it is giving me problems.
Pages: [1]