Show Posts
Pages: [1]
1  Using Arduino / General Electronics / Re: Messure RPM width interrupt problem on: June 07, 2011, 05:45:45 am
Hey

Are u taking the signal directly from the crank sensor on the car, or the output for RPM which is given by the engine control module??
If you are taking the output from a sensor, what sensor is it? Hall-effect or variable reluctance??


Nishad
2  Using Arduino / General Electronics / Re: Arduino automatically triggers interrupt once while uploading on: June 07, 2011, 05:39:51 am
Hey

Ya the shifter does skip neutral as it is a motorcycle transmission. But the clutch has a manual override which can be used to stop the car.
I have also written a program to monitor the ratio between the engine rpm and the wheel speed but haven't tested it on the car yet.  Car is getting its bodywork done. Meanwhile im testing this shifter on the old engine we have in the workshop.

The arduino is only being used for the gear shifter so no other code is gonna affect it. The shifting code itself has worked pretty reliably uptil now.

Thanks

Nishad
3  Using Arduino / General Electronics / Re: Arduino automatically triggers interrupt once while uploading on: June 04, 2011, 12:45:55 am
Pull down resistors are being used, hence when button is pressed, Arduino reads high.

Nishad
4  Using Arduino / General Electronics / Re: Arduino automatically triggers interrupt once while uploading on: June 03, 2011, 08:14:13 am
int upshiftbutton=5;
int downshiftbutton=4;
int sensorpin1=A0;
int sensorpin2=A2;
int sensorpin3=A1;
int upshiftcoil=10;
int downshiftcoil=8;
int sensorvalue1;
int sensorvalue2;
int sensorvalue3;
int upshiftint=7;
int downshiftint=6;
volatile int gearcounter=3;
int buttonState1;           
int lastButtonState1 = LOW;   
int buttonState2;             
int lastButtonState2 = LOW;   
long lastDebounceTime1 = 0;
long lastDebounceTime2 = 0;
long debounceDelay = 50;

void setup()
{
  Serial.begin(9600);
  pinMode(upshiftbutton,INPUT);
  pinMode(downshiftbutton,INPUT);
  pinMode(upshiftcoil,OUTPUT);
  pinMode(downshiftcoil,OUTPUT);
  pinMode(upshiftint,OUTPUT);
  pinMode(downshiftint,OUTPUT);
  pinMode(sensorpin1,INPUT);
  pinMode(sensorpin2,INPUT);
  pinMode(sensorpin3,INPUT);
  attachInterrupt(0,UPSHIFT,RISING);
  attachInterrupt(1,DOWNSHIFT,RISING);
 }

void loop()
{   
 
 sensorvalue2=digitalRead(sensorpin2);
  if(sensorvalue2==1)
     {
      digitalWrite(upshiftcoil,LOW);
     }
     
 sensorvalue3=digitalRead(sensorpin3);
  if(sensorvalue3==1)
       {
         digitalWrite(downshiftcoil,LOW);
       }
     
 int reading1 = digitalRead(upshiftbutton);    \\debounce delay code
   if (reading1!= lastButtonState1)
    {
     lastDebounceTime1 = millis();
    }
 
  if ((millis() - lastDebounceTime1) > debounceDelay)
    {
     buttonState1 = reading1;
    }
 
 digitalWrite(upshiftint, buttonState1);
 lastButtonState1 = reading1;
 
 int reading2 = digitalRead(downshiftbutton);  \\debounce code

  if (reading2!= lastButtonState2)
    {
     lastDebounceTime2 = millis();
    }
 
  if ((millis() - lastDebounceTime2) > debounceDelay)
    {
     buttonState2 = reading2;
    }
 
 digitalWrite(downshiftint, buttonState2);
 lastButtonState2 = reading2;
}

void UPSHIFT ()

{
  int up=digitalRead(5);
  if(up==1)
  {
    sensorvalue1=digitalRead(sensorpin1);
        if  (sensorvalue1==1 && gearcounter<6)
            {
              gearcounter++;
              Serial.println(gearcounter);
             digitalWrite(upshiftcoil,HIGH);
             Serial.println("UPSHIFT");
            }
  }
}

void DOWNSHIFT ()
{
  int down=digitalRead(4);
  if(down==1)
    {   
     sensorvalue1=digitalRead(sensorpin1);
        if  (sensorvalue1==1 && gearcounter>1)
            {
              gearcounter--;
              Serial.println(gearcounter);
             digitalWrite(downshiftcoil,HIGH);
            Serial.println("DOWNSHIFT");
            }
    }
}


Right now I got rid of the unneeded interrupts by only letting the interrupt function do anything when the pushbuttons are pressed, when the Arduino is getting uploaded, no button is pressed hence it ignores the interrupt.
But is there any better way of doing this?
5  Using Arduino / General Electronics / Arduino automatically triggers interrupt once while uploading on: June 02, 2011, 03:52:42 am
Hello

I'm using an Arduino  Duemilanove with an Atmega328 on board. I'm using at as a controller for a electro-pneumatic gear shifter for a Formula Student car.

Two pushbuttons give inputs to the Arduino and after a software debounce delay, the state of the buttons is used to interrupt the microcontroller to either upshift or downshift depending on which button was pressed.

But every time I upload the program on the arduino, it triggers both the interrupts once even when the buttons are not pressed.
The interrupts are triggered only once and after that the program works smoothly.

I will post the code here soon.

Thanks
6  Forum 2005-2010 (read only) / Troubleshooting / Re: Arduino not functioning with external power on: July 10, 2010, 01:03:06 am
Thank you all for the replies.

I did the connections again and used a 7805 to provide a regulated 5V to the 5v pin. Its working now so there must have been a problem with the external connections when it was mounted. Or maybe there was differential grounding.

also, its an official Arduino form Italy, so no problems there.
Thanks for the suggestions.
7  Forum 2005-2010 (read only) / Troubleshooting / Arduino not functioning with external power on: July 09, 2010, 07:22:02 am
I am using an Arduino Duemilanove to run a LED matrix using MAX 7219.
As I am using it for a display on a car, I would like to externally provide it 12V using either the Vin pin or the power jack.

But on supplying 12V at the Vin pin or when given power through the power jack, the LED matrix isnt functioning as expected.  So then I tried supplying 5v to the 5V pin using an IC 7805, but still no go.

The LED matrix display is working properly only when the arduino is powered through the USB cable.
Any suggestions.


8  Forum 2005-2010 (read only) / Interfacing / Re: Melexis SMBus IR Thermometer - NFI on: June 09, 2010, 09:51:31 am
Hey

I have the Melexis 90614ACC (That is the 5v version) of the sensor and i tried to read temp data from it using the i2c master library and dave eatons code as follows:

#include <i2cmaster.h>

void setup()
{
Serial.begin(9600);
Serial.println("Hello!");
i2c_init(); //Initialise the i2c bus
Serial.println("Return from i2c_init");
PORTC = (1 << PORTC4) | (1 << PORTC5);//enable pullups
}
void loop()
{
int dev = 0x5A<<1;
int data_low = 0;
int data_high = 0;
int pec = 0;
i2c_start_wait(dev+I2C_WRITE);
i2c_write(0x07);


i2c_rep_start(dev+I2C_READ);
data_low = i2c_readAck(); //Read 1 byte and then send ack
data_high = i2c_readAck(); //Read 1 byte and then send ack
pec = i2c_readNak();
i2c_stop();

//This converts high and low bytes together and processes temperature, MSB is a error bit and is ignored for temps
double tempFactor = 0.02; // 0.02 degrees per LSB
double tempData = 0x0000;
int frac;

// This masks off the error bit of the high byte, then moves it left 8 bits and adds the low byte.
tempData = (double)(((data_high & 0x007F) << smiley-cool + data_low);
tempData = (tempData * tempFactor)-0.01;
tempData = tempData - 273.15;
Serial.print((int)tempData); //Print temp in degrees C to serial
Serial.print(".");
tempData=tempData-(int)tempData;
frac=tempData*100;
Serial.println(frac);
delay(100);  
}


Is there any reason the code isnt working? i tried using Serial.println to see till what stage the program executes and it stops before

i2c_rep_start(dev+I2C_READ);

doesnt go beyond that
Any ideas?
Also does the 5v version require me to pull-up to 5v or 3.3because thts SMBus spec?
Also the melexis datasheet gives a figure which shows the pin configurations and is labelled "TOP VIEW"
Does that mean it shows the pins coming out of the page or the other way round??
Im confused
Pages: [1]