Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] Bike acceleration calculation problem

Status
Not open for further replies.

ltsharma

Advanced Member level 4
Joined
May 26, 2013
Messages
110
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,306
Location
banglore
Activity points
2,003
hello, I am doing project on motorbike digital meter. I want to calculate acceleration, means 0 km/h to 60 km/h,

i did -
saved minutes and seconds value in eeprom on 0-1 transition of speedometer
like
Code:
 Read_Time(&hours,&minutes,&seconds,&day,&week,&month,&year);
  eeprom_write(0X020,seconds);
  delay_ms(20);
  eeprom_write(0X021,minutes);
  delay_ms(20);
    acnval=1;
and again speed reaches 60
like:
Code:
if(speed==60||speed==61||speed==62||speed==63)
  {
  if(acnval)
  {
  accln();
  acnval=0;
  }
  }
i have saved the minutes and seconds value to eeprom like:
Code:
accln()
  {Read_Time(&hours,&minutes,&seconds,&day,&week,&month,&year);
    eeprom_write(0X022,seconds);
    delay_ms(20);
    eeprom_write(0X023,minutes);
    delay_ms(20);
    }

then showing values like this :
Code:
minutes=eeprom_read(0x20);
  minutes  =  ((minutes & 0xF0) >> 4)*10 + (minutes & 0x0F);
  seconds=eeprom_read(0x21);
  seconds  =  ((seconds & 0x70) >> 4)*10 + (seconds & 0x0F);
  a_Seconds=(minutes*60)+seconds;
  seconds=0;minutes=0;

  minutes=eeprom_read(0x22);
  minutes  =  ((minutes & 0xF0) >> 4)*10 + (minutes & 0x0F);
  seconds=eeprom_read(0x23);
  seconds  =  ((seconds & 0x70) >> 4)*10 + (seconds & 0x0F);
  a_minutes=(minutes*60)+seconds;
  seconds=0;minutes=0;
  
  a_minutes=a_minutes-a_seconds;
  a_Seconds=0;

  inttostr(a_minutes,acln);
  Glcd_write_text(acln),1,3,1);
  a_minutes=0;

Im not getting correct value, what is the problem here?
 

Average acceleration = (Vf - Vi) / t i.e., final velocity minus initial velocity divided by time. Use timer to calculate acceleration and not RTC.
 

Timer is better. Kepp timer running and make it interrupt every 1 sec. get reading of velocity into a variable and calculate acceleration in a function. Initially let us assume velocity is constant so Vf - Vi = 0 so accln = 0. now use another variable to hold previous value of velocity. If speed changes then take the diff of velocities and calculate accln.
 

no i want only acceleration of 0 to 60, and also along with other process like showing speed values on display and also keep counting trip values

- - - Updated - - -

in above shown code, theoretically it must show correct values, but its not... why?
 

there only

Code:
accln()
  {Read_Time(&hours,&minutes,&seconds,&day,&week,&month,&year);
    eeprom_write(0X022,seconds);
    delay_ms(20);
    eeprom_write(0X023,minutes);
    delay_ms(20);
    }
 

where are you calculating aacln? What is the use of eeprom? there is 40 ms delay in eeprom code. It will hinder the accln calculation process. You will get wrong values with delays in your code.


Algo

Time = t1 (say second 2)

speed1 = getSpeed();

Time = t2 (say second 3)

speed2 = getSpeed();

accln = (speed2 - speed1) / 1 ( t = 1 sec )

speed1 = speed2;
 
acceleration means, bike taken time to go 0 km/h to 60 km/h in seconds, that i calculated at last,
first 0km/h time value to eeprom & 60 km/h time value to eeprom,

when i want to show values : read from eeprom transformed hex to int, and converted minutes to seconds,
then subtracted 60Km/h time value with 0 kmp/h time :

eg: 0-1kmph transition on 7hr:30min:41sec
& 60 on 7hr:31min:55sec

i did : (30*60)+41 say 1841
and (31*60)+55 say 1915

1915-1841 = 74 seconds......
 

accln = m/s^2

take difference of the two times in seconds and then divide difference of final and initial velocity and divide by difference of time in seconds.
 

okeyy,, this is good, thanks

But i wanted how much seconds taken by motorbike to rech 0 to 60 Km/h,
 

take difference of the two times in seconds and then divide difference of final and initial velocity

when 0 is crossed note down time and when 60 Km/h is reached note down time. Take difference of time.
 

yahh,, difference of initial & final time is the thing i did before (in program). i gave 30 seconds delay(in simulation) from 0-60 but showing random values like 190,228,,,,
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top