Good morning to everyone. I am a new user of Arduino and my English is very poor: sorry and thank you for your patience. I am very happy to discover Arduino, it can be used in a lot of situation, solving the problems of weliding a lot of wire with the op amp sketch. My bike use the fuel injection and I want to build a sistem that show me the fuel consumption of the bike. The injector signal is a square wave with variable period ( the rpm of the engine ) and variable duty cycle ( the amount of fuel injected each turn of the engine ) This signal contains both the informations about the speed of the bike ( lineary connected with the rpm ) and the amount of the fuel ( the Vrms of the injector, an RC in few words) 1) first problem: I understand that the minimum time in Arduino is micros, 4us of resolution. This is a poor resolution for the time I want to measure but maybe enought. For this reason I need a very fast program. It is not a problem if the system works in "hide" situation and give me the result every one second. 2) My programming experience is only a little bit more than zero, I know only the basic of ms dos.... Yes, this is the real problem. I am not ( yet!) confident with Arduino sintax and for this I ask for your help.
I write the program I have in my mind in mix betwen basic and Arduino sistem to show you what I mean.
10 digitalRead (pin12) 20 if pin(12)=hight goto 10 - I am cheking if the injector start to open - if the signal is low the injector works so I - can go on with the program, othewise I - return up waiting for the change of the - state of the pin(12). No time is waste.
30 T_start= micros - I have the first time for my calculation 40 digitalRead (pin12) 50 if pin(12)= low goto 40 - same situation written before but in this - situation I am waiting fot the end of the - signal. 60 T_end=micros - The injector was opened fot T_start-T_end - us
70 digitalRead (pin12) 80 if pin(12)=hight goto 70 - I am waiting for the next cycle 90 T_cycle= micros At this point I have all the informations I need. T_start - T_cycle is the time of one turn of the engine that is 1/speed of the bike T_start - T_end is the time in which the injector was open so it contains the information about the amount of gasoline. My question is: how can I force the program to stay stopped in one point waiting for an event? Does exist in Arduino an istruction like goto that make the program read up and not dow? Tahnk you very much again Pietro PS: I already made this with two external IC that convert in a tension the informations and it works fine. But I want to learn how make it in a completly digital way.