View previous topic :: View next topic |
Author |
Message |
ad
Joined: 24 Mar 2015 Posts: 14
|
Speed and RPM |
Posted: Thu Apr 09, 2015 1:41 pm |
|
|
Hi, I am doing a project about motorcycle, I need different sensors to measure different things. I make two programs about fuel level and temperature. But I do not know how to do the speed and rpm. A matrix keypad 4x4 for the selection of the parameter to be measured, which will be shown on the LCD touch. I use a PIC 18F4550. If someone have any ideas, I would be very grateful. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Thu Apr 09, 2015 2:18 pm |
|
|
Do a forum search on 'tacho'. |
|
|
Sam_40
Joined: 07 Jan 2015 Posts: 127
|
|
Posted: Thu Apr 09, 2015 2:21 pm |
|
|
ad,
The RPM reading should be very easy, you can do it in so many way, the best and the most accurate is to read one of the sparkplug pulses. You can find a lot of good tutorial on Google.
The keyboard you have to; either multiplex it using 8 IOs or use one analog input with different value resisters!
Hope this help, |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9241 Location: Greensville,Ontario
|
|
Posted: Thu Apr 09, 2015 2:32 pm |
|
|
Speed can be done with a sensor on the front wheel. Just use one from a bicycle 'unit' !
RPM an be done off the alternator output or 'points' if bike has them or loop a wire round a plug. Some math involved based on 2 or 4 stroke, # of cylinders,etc.
I'd build a 'test jig' of another PIC with appropriate outputs to 'simulate' the bikes sensors. A LOT safer than riding and calibrating at the same time !!
Jay |
|
|
ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
|
Posted: Thu Apr 09, 2015 3:12 pm |
|
|
temtronic wrote: | Speed can be done with a sensor on the front wheel. Just use one from a bicycle 'unit' !
RPM an be done off the alternator output or 'points' if bike has them or loop a wire round a plug. Some math involved based on 2 or 4 stroke, # of cylinders,etc.
I'd build a 'test jig' of another PIC with appropriate outputs to 'simulate' the bikes sensors. A LOT safer than riding and calibrating at the same time !!
Jay |
For the speed, I've used an inductive sensor to read the holes on the front disc rotors! That worked well!!
Also some bikes have now coil plugs (like mine) so you can't really measure the spark by induction.
But you can read easily by the coil wire (less than 100V normally). _________________ Regards,
Laurent
-----------
Here's my first visual theme for the CCS C Compiler. Enjoy! |
|
|
ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
|
Posted: Thu Apr 09, 2015 3:15 pm |
|
|
temtronic wrote: | Speed can be done with a sensor on the front wheel. Just use one from a bicycle 'unit' ! |
IMO, it's not really a great idea to clip a magnet (bicycle sensor) or anything to the wheel this will off-balance the wheel and you will have some vibration noticeable over 100 kph. _________________ Regards,
Laurent
-----------
Here's my first visual theme for the CCS C Compiler. Enjoy! |
|
|
ad
Joined: 24 Mar 2015 Posts: 14
|
|
Posted: Fri Apr 10, 2015 3:50 am |
|
|
I do this, I do not want to do it with PWM. I want you to tell me, is that the last part wrong, if I can help. All the while the LCD brand me 0. But the sensor detects.
Code: |
#include <18F4550.h>
#fuses XT,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#include "C:\Users\Jose\Desktop\RPM\flex_lcd420.c"
#include <math.h>
#include <kbd.c>
int16 counter=0;
//*************** INT TIMER1*********************
#int_TIMER1
void TIMER1_isr(void) {
counter=get_timer0(); //Lectura contador TMR0
counter=counter*2*120; //Conversión a rpm
printf(lcd_putc,"%6lu rpm",counter);
lcd_gotoxy(1,1);
set_timer0(0); //Reinicia cuenta
set_timer1(3036); // Recarga a 0.5s
}
//**********************************************
VOID MAIN()
{
//CHAR K,kant='0';
//char PWMH=0,PWML=0;
lcd_init();
kbd_init();
PORT_B_PULLUPS(TRUE);
setup_timer_0(rtcc_ext_l_to_h|RTCC_DIV_2); //Configuración TMR0
setup_timer_1(T1_internal|T1_DIV_BY_8); //Configuración TMR1
set_timer0(0); //Borrado contador
set_timer1(3036); //Carga a 0.5s
enable_interrupts(int_timer1);
enable_interrupts(global); //Habilitación interrupciones
WHILE (1) {
k=kbd_getc();
if (k=='\0') k=kant;
if ((k=='*') || (k=='#')) k='0';
kant=k;
k=k-48;
PWMH=k*28;
PWML=255-PWMH;
for(PWMH;PWMH>0;PWMH--){
OUTPUT_HIGH(PIN_A0);}
for(PWML;PWML>0;PWML--){
OUTPUT_LOW(PIN_A0);}
}
}
|
|
|
|
ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
|
|
ad
Joined: 24 Mar 2015 Posts: 14
|
|
Posted: Sat Apr 11, 2015 4:28 am |
|
|
I will improve any motorcycle 49cc. Yes ELCOUZ you can see differents options and tell me please. Thank you. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9241 Location: Greensville,Ontario
|
|
Posted: Sat Apr 11, 2015 5:37 am |
|
|
DOH, if this is an ON rode ride it HAS to have a speedometer. If it's a 'cable' type, just add YOUR optical or hall encoder to that.
Jay |
|
|
ad
Joined: 24 Mar 2015 Posts: 14
|
|
Posted: Sun Apr 12, 2015 1:42 pm |
|
|
I don't use a encoder, I want to do similar a bicycle, but I don't know how to do the program. |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Sun Apr 12, 2015 1:49 pm |
|
|
whatever else you think you need to do inside the timer ISR -
DONT DO THIS !!!
Code: |
counter=counter*2*120; //Conversión a rpm
printf(lcd_putc,"%6lu rpm",counter);
lcd_gotoxy(1,1); |
I also have grave doubts about the concept you are pursuing....
as there is no schematic of what you are attempting. |
|
|
Sam_40
Joined: 07 Jan 2015 Posts: 127
|
|
Posted: Sun Apr 12, 2015 4:13 pm |
|
|
ad,
I do not know what motorcycle model you have, if you have one with a spark plug cable. It does not matter how many cylinders (you just have to pick one)! what you are looking for is called inductive pickup, you wind a wire around spark plug cable (you have to experience with how many winds), if you have a oscilloscope it will help. one end is free and not connected to the ground or anything, the other end of the wire connected to transistor or a timer chip such as 555 to produce a square pulse for every spark signal, then you use this signal as external interrupt input in your PIC. Now that was the hardware theory (similar to a timing light from the good old days
or if you can pickup the motorcycle computer or the spark plug distributor circuit to generate the pulse.
For more detail on the circuit, just google "inductive pickup tachometer circuit "
You need to program the PIC to read and advance a counter for every interrupt received. then a simple math ad you can display the value as RPM on your LCD.
Build the circuit first so we may be able to help!
Good luck, |
|
|
Sam_40
Joined: 07 Jan 2015 Posts: 127
|
|
Posted: Sun Apr 12, 2015 4:26 pm |
|
|
another way you can pick a pulse is from the alternator before it regulated to DC. This will be more difficult for a motorcycle. The motorcycle that I used to have, they built the motorcycle around the alternator |
|
|
ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
|
Posted: Sun Apr 12, 2015 4:30 pm |
|
|
Sam_40 wrote: | another way you can pick a pulse is from the alternator before it regulated to DC. This will be more difficult for a motorcycle. The motorcycle that I used to have, they built the motorcycle around the alternator |
Easier than that... take the signal from the inductive pickup on the crankshaft
More precise
_________________ Regards,
Laurent
-----------
Here's my first visual theme for the CCS C Compiler. Enjoy! |
|
|
|