Motorized Bicycle Engine Kit Forum
Register FAQ Members List Calendar Mark Forums Read


Search Titles Only

Sponsors
To be a sponsor Contact Us
Our Forums


Go Back   Motorized Bicycle Engine Kit Forum > Motorized Bicycle > Motorized Bicycle General Discussion

Motorized Bicycle General Discussion Topics on bicycle engine kits, help articles, repair and modifications for your motorized bicycles

Any Programmers around here?


Discussion at Motorized Bicycle Engine Kit Forum in the Motorized Bicycle General Discussion forum. Hey guys I have been thinking about making a dyno for my bikes and I have figured out the hardware ...
Reply
 
LinkBack (1) Thread Tools Display Modes
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 11-08-2009, 01:14 PM
Prasinos's Avatar
Motorized Bicycle Elite Member
 
Join Date: Dec 2008
Location: CT
Posts: 144
Default Any Programmers around here?

Hey guys I have been thinking about making a dyno for my bikes and I have figured out the hardware part. I plan on using one or two 45lb plates as a flywheel and they will be spun by the back tire of a bike. I will use a mouse or a keyboard along with a cam that will click a button a number of times per revolution.

So the reason for the title.

I need a program that will record the time between clicks and possibly output them into an excel file. This way I can just use the first derivative to calculate angular velocity, the second derivative to calculate torque and the third to calculate power. It would be able to make some really nice graphs that could show the difference in power from different upgrades, I think it would be really cool.

Anyway I don't think it would be that difficult for someone that knew what they were doing. I have acess to labview, matlab, and c++. So if anyone could lend advice, or ideally write this program, I would appreciate it greatly.
Reply With Quote
  #2 (permalink)  
Old 11-08-2009, 01:41 PM
fall_down_stand_up's Avatar
Motorized Bicycle Elite Member
 
Join Date: Apr 2009
Location: granbury
Posts: 353
Default Re: Any Programmers around here?

Dyno would be great!!!!!I would like to know the actual output of these 2 stroke china girls....
John-John
__________________
IF I CANT FIX IT,IT ISN'T BROKEN!....ummmmmmm so I thought....
Reply With Quote
  #3 (permalink)  
Old 11-08-2009, 02:29 PM
Prasinos's Avatar
Motorized Bicycle Elite Member
 
Join Date: Dec 2008
Location: CT
Posts: 144
Default Re: Any Programmers around here?

yea im confident i can do it i just need the program if i want to have pretty graphs.
Reply With Quote
  #4 (permalink)  
Old 11-08-2009, 06:10 PM
2door's Avatar
Moderator
 
Join Date: Sep 2008
Location: Littleton, Colorado
Posts: 1,896
Default Re: Any Programmers around here?

Huh?
Derivative? Velocity? Excel file?
And I was just starting to understand the chain tensioner thing...
Tom
__________________
Age and Treachery Will Always Triumph
Over Youth and Skill
Reply With Quote
  #5 (permalink)  
Old 11-08-2009, 06:45 PM
Motorized Bicycle Senior Member
 
Join Date: Jun 2009
Location: Canada
Posts: 78
Default Re: Any Programmers around here?

Um yeah, that wouldn't be too hard to do in good ol' fashioned C. Could export the results directly in .csv format too.

The multi-tasking of a modern OS will throw off the timing a hair, just for fair warning.

Last edited by TheE : 11-08-2009 at 06:48 PM.
Reply With Quote
  #6 (permalink)  
Old 11-08-2009, 07:40 PM
Prasinos's Avatar
Motorized Bicycle Elite Member
 
Join Date: Dec 2008
Location: CT
Posts: 144
Default Re: Any Programmers around here?

not to impose, but if i gave you my email could you make the program and send it to me? I dont want to cause you too much trouble and i dont know how complicated the code would be, but if it isnt too hard....
Reply With Quote
  #7 (permalink)  
Old 11-08-2009, 08:39 PM
Motorized Bicycle Senior Member
 
Join Date: Jun 2009
Location: Canada
Posts: 78
Default Re: Any Programmers around here?

I've actually been trying to code it a bit. Turns out that getting any kind of precision timing in C is alot harder than I thought. I'll let you know if I find anything.
Reply With Quote
  #8 (permalink)  
Old 11-08-2009, 09:12 PM
Prasinos's Avatar
Motorized Bicycle Elite Member
 
Join Date: Dec 2008
Location: CT
Posts: 144
Default Re: Any Programmers around here?

hmmm, yea i can only make the flywheel so heavy, if i could get to within like 50 miliseconds i think it would be enough.
Reply With Quote
  #9 (permalink)  
Old 11-08-2009, 09:35 PM
Motorized Bicycle Senior Member
 
Join Date: Jun 2009
Location: Canada
Posts: 78
Default Re: Any Programmers around here?

Welp, I did a bit of researching about something called the QueryPerformanceCounter function which, as the name implies, queries a counter inside the CPU for really high-res timing. Here's my code with it so far (for Visual Studio C++):
Code:
#include "stdafx.h"
#include <windows.h>

#include <winbase.h>
#include <stdlib.h>
#include <conio.h>

int main(void)
{

	
    unsigned long int revs=0;
    LARGE_INTEGER total_time,diff_time,start_time,end_time,TICKS_PER_SECOND;
	char c=0;
	FILE *outp;

	QueryPerformanceFrequency(&TICKS_PER_SECOND);

	total_time.QuadPart=0;
	outp=fopen("output.csv","a");
	fflush(stdin);
	printf("QPC Freq: %I64d\n",TICKS_PER_SECOND.QuadPart);
	

	printf("Press any key to begin capturing.\n");
	
    
	getch();

	printf("Capturing counts to output.csv, press 'x' to quit...");

    QueryPerformanceCounter(&start_time);

	while(c!='x')
	{
		if(kbhit())
		{
		
		   QueryPerformanceCounter(&end_time);
		   diff_time.QuadPart=end_time.QuadPart-start_time.QuadPart;
		   total_time.QuadPart+=diff_time.QuadPart;
		   QueryPerformanceCounter(&start_time);
		   revs++;
		   fprintf(outp,"%ld,%I64d,%I64d,\n",revs,total_time.QuadPart,diff_time.QuadPart);
		   c=getch();
		}
		
	}

	fclose(outp);

	printf("\n\nTotal of %ld revolutions were counted!\n",revs);
	getch();

     return EXIT_SUCCESS;
}
It will tell you how many ticks per second at the beginning, and then append the results into an "output.csv" file in the same directory as the executable(will be created if it hasn't already). You can later multiply (number of ticks * (1/tick frequency)) to get the time.

I really have no idea how accurate it is, and I'm not a professional programmer by any stretch of the imagination. I'm sure someone will chime in with a better solution. Personally I prefer a microcontroller because you can manually calculate it's timing down to the nanosecond, but a general goes to war with the army he's got...

Last edited by TheE : 11-08-2009 at 09:42 PM.
Reply With Quote
  #10 (permalink)  
Old 11-08-2009, 09:48 PM
Prasinos's Avatar
Motorized Bicycle Elite Member
 
Join Date: Dec 2008
Location: CT
Posts: 144
Default Re: Any Programmers around here?

Thanks alot E, il see how this works. I get home around thanksgiving so il let you know how this all goes when i try it ou
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://motorbicycling.com/f3/any-programmers-around-here-12814.html
Posted By For Type Date
Biking Bis - Bicycle Touring and More :: Feed Zone This thread Refback 11-08-2009 07:25 PM


All times are GMT -5. The time now is 06:25 PM.


Sponsors
To be a sponsor Contact Us
Donations accepted!

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Motorized Bicycle Engine Kit Forum