Loading...
  Show Posts
Pages: 1 2 [3] 4 5 ... 10
31  Using Arduino / Motors, Mechanics, and Power / Re: A Spark plug controlled from the Arduino - Review of guide on: August 11, 2012, 11:44:59 am
Speed is strongly depending on code. But having a 2stroke engine having currently a fixed ignition retard everything is better than that.  A delay of 8microseconds at 8000RPM would mean a 0,4°retard, which is acceptable to me...there is no such accuracy in calibrating the engine with defined air temperature and engine temperature...

Firing a multicylinder 4-stroke engine is much more challenging and I do not have the software knowledg to do so...
32  Using Arduino / General Electronics / Power supply in rough automotive condition on: August 06, 2012, 12:45:18 am
Hi,
I would like to use the UNO in the car and need to make shure the voltage peaks from the car does not kill the board (And I do not trust the connector regarding vibration). Therefore I plan not using the UNO internal voltage controller but an external with according capacitor, coil and diode suppressing the voltage peaks. A LM2940 is the voltage regulator down to 5V.

Can I feed the 5V from the 2940 directly into the 5V pins on the board or does the UNO voltage controller on the board is being overstressed?
33  Using Arduino / Programming Questions / Re: Arduino drops time with interrupt time measurement on: July 28, 2012, 02:23:25 pm
Dear all,
I have found the issue. The code for blinking the trigger is based on mS and the ISR is based on microseconds. So I changed the code to the following:

Code:
int pin = 13;
volatile int state = LOW;
const int ledPin =  12;      // the number of the LED pin
int ledState = LOW;             // ledState used to set the LED
unsigned long previousMillis = 0;        // will store last time LED was updated
unsigned long interval = 1000;           // interval at which to blink (milliseconds)

int trigger = 13;     // Trigger Ausgnag
volatile unsigned long microshigh1;  //Microsekunden wenn der Trigger auf HIGH geht- vorheriger  Trigger
volatile unsigned long microshigh2;  //Microsekunden wenn der Trigger auf HIGH geht- aktueller Trigger
volatile unsigned long deltamicros;  //Abstand zweier high Flanken


void setup()
{
  //Wie werden die Arduino ÜPins benutzt?
  Serial.begin(115200);
  pinMode(pin, OUTPUT);
  attachInterrupt(0, ignite, CHANGE);  //put interrupt on pin 2--->  Triggereingang
  pinMode(ledPin, OUTPUT);// Virtueller trigger

}
void loop()

  unsigned long currentMillis = micros();

  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;   

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
 Serial.println(deltamicros);
  }
}


void ignite()
{
 
  digitalWrite(pin, state);
  digitalWrite(10, LOW);
  microshigh2 = micros();
  deltamicros= microshigh2-microshigh1;
 
  microshigh1=  microshigh2;
 state = !state;
}

And the result with 1000microseconds is reasonable good including SerialPrint:

Deltamicros   Difference
100000   
100012   12
100004   -8
100000   -4
100012   12
100004   -8
100012   8
100000   -12
100004   4
100012   8
100000   -12
100004   4
100012   8
100004   -8
100004   0
100008   4
100000   -8
100008   8
100008   0
100012   4


Thank you all for your support!
34  Using Arduino / Programming Questions / Re: Arduino drops time with interrupt time measurement on: July 28, 2012, 09:31:49 am
Code:
int pin = 13;
volatile int state = LOW;
const int ledPin =  12;      // the number of the LED pin
int ledState = LOW;             // ledState used to set the LED
unsigned long previousMillis = 0;        // will store last time LED was updated
unsigned long interval = 1000;           // interval at which to blink (milliseconds)

int trigger = 13;     // Trigger Ausgnag
unsigned long microshigh1;  //Microsekunden wenn der Trigger auf HIGH geht- vorheriger  Trigger
unsigned long microshigh2;  //Microsekunden wenn der Trigger auf HIGH geht- aktueller Trigger
unsigned long deltamicros;  //Abstand zweier high Flanken


void setup()
{
  //Wie werden die Arduino ÜPins benutzt?
  Serial.begin(115200);
  pinMode(pin, OUTPUT);
  attachInterrupt(0, ignite, CHANGE);  //put interrupt on pin 2--->  Triggereingang
  pinMode(ledPin, OUTPUT);// Virtueller trigger

}
void loop()

  unsigned long currentMillis = millis();

  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;   

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
 Serial.println(deltamicros);
  }
}


void ignite()
{
 
  digitalWrite(pin, state);
  digitalWrite(10, LOW);
  microshigh2 = micros();
  deltamicros= microshigh2-microshigh1;
 
  microshigh1=  microshigh2;
 state = !state;
}
35  Using Arduino / Programming Questions / Re: Arduino drops time with interrupt time measurement on: July 28, 2012, 07:16:08 am
Ahh- I misunderstood all of you not using SerialPrint at all. Sorry! Now I changed the code and put the command in the loop

Code:
void loop()

  unsigned long currentMillis = millis();

  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;   

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
 Serial.println(deltamicros);
  }
}

I decreased the speed of blinking to give more time for SerialPrintThe result remains unchanged. Still 1mS variation:

1001504
1001468
1000448
1001476
1000448
1001468
1000448
1001472
1000448

36  Using Arduino / Programming Questions / Re: Arduino drops time with interrupt time measurement on: July 28, 2012, 06:02:26 am
MarkT,
in general I do agree, but
- I need to know if the interrupt is working with a minimum (or at least a defined) delay
- the code shows an intervall of 100mS at 115200baud which should be quick enough to submit the data
- the serial data submission is after the interrupt work...shouldn't lead to a delay

But anyhow I do agree that this is not optimum, but I do not know any other way to control function accuracy and I do not have a oscilloscope
37  Using Arduino / Programming Questions / Re: Arduino drops time with interrupt time measurement on: July 28, 2012, 03:51:58 am
Tried the changed code. Is the modification what you have meant?


First the results in microseconds:
101372   
100356   -1016
101372   1016
101380   8
100348   -1032
101380   1032
101372   -8
100356   -1016
101372   1016
100352   -1020
101376   1024
101380   4
100352   -1028
101376   1024
101372   -4
100352   -1020
101376   1024
101380   4
101372   -8


This is the code

Code:
int pin = 13;
volatile int state = LOW;
const int ledPin =  12;      // the number of the LED pin
int ledState = LOW;             // ledState used to set the LED
unsigned long previousMillis = 0;        // will store last time LED was updated
unsigned long interval = 100;           // interval at which to blink (milliseconds)

int trigger = 13;     // Trigger Ausgnag
unsigned long microshigh1;  //Microsekunden wenn der Trigger auf HIGH geht- vorheriger  Trigger
unsigned long microshigh2;  //Microsekunden wenn der Trigger auf HIGH geht- aktueller Trigger
unsigned long deltamicros;  //Abstand zweier high Flanken


void setup()
{
  //Wie werden die Arduino ÜPins benutzt?
  Serial.begin(115200);
  pinMode(pin, OUTPUT);
  attachInterrupt(0, ignite, CHANGE);  //put interrupt on pin 2--->  Triggereingang
  pinMode(ledPin, OUTPUT);// Virtueller trigger

}
void loop()

  unsigned long currentMillis = millis();

  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;   

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
  }
}

void ignite()
{
  state = !state;
  digitalWrite(pin, state);
  digitalWrite(10, LOW);
  microshigh2 = micros();
  deltamicros= microshigh2-microshigh1;
 Serial.println(deltamicros);
  microshigh1=  microshigh2;
}

This wasn't the root cause. I tried to put the microshigh1 and 2 into volatile memory state improving speed...no success as well
38  Using Arduino / Programming Questions / Re: Arduino drops time with interrupt time measurement on: July 28, 2012, 01:29:21 am
You're right. I changed it. Is that the root cause of the timing variation...?
39  Using Arduino / Programming Questions / Arduino drops time with interrupt time measurement on: July 28, 2012, 12:56:31 am
Hi ,
I used a Arduino Duemilanove to generate a 5V trigger signal to be measured by itself through an interrupt (So the microcontroller feeds the trigger is the same as the one measuring it). This is my code

Code:
int pin = 13;
volatile int state = LOW;
const int ledPin =  12;      // the number of the LED pin
int ledState = LOW;             // ledState used to set the LED
long previousMillis = 0;        // will store last time LED was updated
long interval = 100;           // interval at which to blink (milliseconds)

int trigger = 13;     // Trigger Ausgnag
unsigned long microshigh1;  //Microsekunden wenn der Trigger auf HIGH geht- vorheriger  Trigger
unsigned long microshigh2;  //Microsekunden wenn der Trigger auf HIGH geht- aktueller Trigger
unsigned long deltamicros;  //Abstand zweier high Flanken


void setup()
{
  //Wie werden die Arduino ÜPins benutzt?
  Serial.begin(115200);
  pinMode(pin, OUTPUT);
  attachInterrupt(0, ignite, CHANGE);  //put interrupt on pin 2--->  Triggereingang
  pinMode(ledPin, OUTPUT);// Virtueller trigger

}
void loop()

  unsigned long currentMillis = millis();

  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;   

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
  }
}


void ignite()
{
  state = !state;
  digitalWrite(pin, state);
  digitalWrite(10, LOW);
  microshigh2 = micros();

  deltamicros= microshigh2-microshigh1;
  Serial.println(deltamicros);
  microshigh1=  microshigh2;
}

The result is the following received by the serial out:

Measured
   time   Variation
101396   
101376   -20
100352   -1024
101376   1024
101372   -4
100356   -1016
101372   1016
101384   12
100344   -1040
101380   1036
100356   -1024
101372   1016

As you see there is pretty much of a variation although I used and interrupt. is that normal and I should not expect a better result?
40  Using Arduino / Programming Questions / Re: How to time how many minutes an output is on on: July 22, 2012, 01:05:40 am
I agree to James that using the millis() value is the right way to go. I do not know how long the Arduino will run without reset, but please be aware that there is an rollover where the millis() counter is flipping back to "0" after appr. 50 days.

41  Using Arduino / Programming Questions / selecting arrays on: July 22, 2012, 01:00:55 am
Hi,
I may have a simple question but I cannot find it it the forum yet:
I have a bunch of arrays like
Code:
int map1[] = { 210, 200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0 };
int map2[] = { 210, 200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0 };

What is basically want to do is using an algo like
Code:
selected= 120/60
This will give me value 2

I am searching for a possibility to retrieve array values like this
Code:
value = (map(selected))[4]

Does anyone have an idea how to do that?
42  Using Arduino / Project Guidance / Re: Homebrew 2-stroke ignition? on: July 06, 2012, 10:49:32 am
Yes- the sensor respone is slower (see Bosch PSA-C Sensor datasheet), but this is only delay in response. I meant the time to measure an analog voltage from the arduino itself is the downside of it.

43  Using Arduino / Project Guidance / Re: Homebrew 2-stroke ignition? on: July 05, 2012, 11:38:43 pm
Hi PeterH,
I do agree to this, but this will be too complicated for me because the MAP Sensor needs a AnalogRead command. But Arduino takes about 20mS...takes too long for the for the 10.000RPM and its cycle time.
So I leave it to the first step of changeing the retard over RPM.
44  Using Arduino / Project Guidance / Re: Homebrew 2-stroke ignition? on: July 02, 2012, 08:26:42 am
Mhhh- a 360° stroke at 10.000RPM takes about 6mS. I am sure you agree that using interrupts is the best way to handle it not using IFTHEN loops. 1° of ignition is 17microseconds at 10.000RPM. The 328 is not as quick as that...

I know I am naggy, but beside learning something about engines no one answered my question from my first post:
As the igntion timing is critical I need to pull the coil pin to low with an internal interrupt command

Can anyone help me with that?
45  Using Arduino / Project Guidance / Re: Homebrew 2-stroke ignition? on: July 02, 2012, 02:51:15 am
You are right that TDC accuracy is important. Please bear in mind that the scooter originally works with a FIXED (!!!) ignition value and one sensor/ actuator in the CDI ignition system- you can make it only better  smiley
I do not mind too much about the lower RPMs- here are the biggest variations regarding angular speed over 360° crankshaft angle. The higher revs are of more importance- and here is luckily the changes much lower.

Important to me is that the sensor in and acuator out is perfectly running. Sensor "in" is no problem with AttachInterrupt. 

But how to kick out the OUT actuator signal with highest accuracy? I'd like to avoid the "ifthen" loop looking for micorseconds, which is timingwise not what I need!
Pages: 1 2 [3] 4 5 ... 10