Robin2:
1.333 kHz
I strongly advise against fiddling with the control system of a 155mph car if you do not have the necessary professional engineering qualifications. If you were so qualified you would not need to seek advice from unqualified folk on the internet.
Get written approval from your automobile insurer before you make any changes.
...R
About the value format, I'm sorry, in Brazil we use . (dot) as Thousands Separators and , (comma) as Decimal Separator, so the value 1.3kHz (USA) is equal to 1,3kHz (Brazil) and 1,333Hz (USA) is equal to 1.333Hz (Brazil). Then, this information was not wrong info, just a conversion fault on my part. Follow the link for a better explanation.
Regarding your advising, I appreciate it, however, as I said above this is a resto-mod car project, so the start car state is a 1970s car without any electronics embedded. Everything desired on this project will be made by myself, that is the proposal. The ECU mentioned by me is a programable EFI system by Fueltech (that is a Brazilian company). Here is very common to convert carburated cars to injected cars. This ECU has a TC that I want to use as well, but the number of input pins is limited and I can't lose 4 pins just to use this feature, for this, I'm creating this "wheel speed controller". The ECU already accepts this signal (from the rotation sensor), for this reason, I'm concerned to have exactly the same output signal format from my controller.
Btw, I solved this challenge guys. As I said I don't have experience using Arduino, however, I have a large experience building systems. I followed the same steps, just reading the official documentation. I used the ISRs to count the wheels' pulses. I simulated it on tinkercad and that is working. I really appreciate @Blackfin help, he gave me the north to follow using CD74HCT126 IC to switch the output signal based on my signal key to select the faster wheel speed. That really worked!
Bellow a simple code just to take the speed of one wheel. I made this code just to validate my hypothesis using ISRs. I simulated this code using an oscilloscope to generate the square signal input.
// Car definitions
#define RELUCTOR 48 // Number of teeth
#define WHEEL_DIAMETER .65 // In meter (m)
// Program definitions
#define CYCLE_SIZE 500 // Take calculated each 500ms
#define WHEEL_INPUT 2 // Digital pin 2
volatile int pulses;
int speed = 0;
int rpm = 0;
unsigned long timeold;
void wheelPulse()
{
pulses++;
}
void enableInterrupts()
{
attachInterrupt(digitalPinToInterrupt(WHEEL_INPUT), wheelPulse, RISING);
}
void disableInterrupts()
{
detachInterrupt(digitalPinToInterrupt(WHEEL_INPUT));
}
void setup()
{
Serial.begin(115200);
timeold = 0;
pulses = 0;
pinMode(WHEEL_INPUT, INPUT);
enableInterrupts();
}
int cycle;
void loop()
{
cycle = millis() - timeold;
if (cycle >= CYCLE_SIZE)
{
// Disable interrupts
disableInterrupts();
rpm = (60000 * pulses / cycle) / RELUCTOR;
speed = (WHEEL_DIAMETER / 1000) * PI * rpm * 60; // KMH
pulses = 0;
Serial.println(rpm, DEC);
Serial.print(speed, DEC);
Serial.println("Km/h\n");
timeold = millis();
// Re-enable interrupts
enableInterrupts();
}
}
The final code is a little bit more complex. I defined some structs type to represent the wheel and I have created a library to implement the logic to be more generic as possible, allowing me to use this lib to manage wheel speed in pairs according to my necessity. I hope also helped some others with a similar question.
Thank you all and special thanks to @Blackfin