Hi everyone. So, I am designing this circuit, where I have basically 2 inputs and one output in my Arduino.
I have a microcontroller that is sending a signal to a device (let's call it DEVICE1) based on a sensor input (let's call it SENSOR1, goes between 0 and 5V). The output signal to DEVICE1 is always the same (5V), but it has different durations depending on the input from SENSOR1. The higher SENSOR1 is, the longer the signal will be.
The issue is, this microcontroller only sends values based on a 3V range, so if the sensor goes over 3V, the microcontroller will keep sending the same signal, up to 5V.
Basically, with the Arduino, I need to take the signal from this microcontroller, and pass it along as long as it is below 3V. When SENSOR1 goes over 3V, I need to extend this signal and make ir last longer.
So as I understand this the sensor voltage output can range from 0 to 5V; however the microcontroller only has an input range of 0-3V.
The microcontroller represents the voltage as a pulse duration.
If that is the case, and you need a different range, you must scale the input so that 0-5V becomes 0-3V.
Then you will need to scale the time signal- so measure it with an arduino and produce a similar pulse of the required duriation.
No, the microcontroller can read all 5v, but it's programmed to change the output from 0 to 3v, but when it gets to over 3v, it's programmed to just keep the same value it was outputting at 3v.
Since I cannot change the original microcontroller, I must use the Arduino as a piggyback system.
For all those wanting to know what everything is, SENSOR1 is a MAP sensor, DEVICE1 is a fuel inyector. The microcontroller is an ECM.
You certainly can measure Vin with an arduino ADC and use that data to extend the pulse length - but it also depends on the INTERVAL between pulse that the "DEVICE1" expects.
You could reach a state in which the pulse never goes low.
What do you mean to what end? To inject more fuel.
This is an NA car that is now getting a supercharger installed.
Whenever the ECM sends the HIGH signal, I need the Arduino to send the same signal, and then extend it for X amount of time based on a function. How can I do that?
From that description I would think
inputsignal from ECM -30ms long--->-----ATTiny85------ATTiny85--immidiate -signal ---but make the signal -----7 x 30 = 210 ms-long
But above you write something different:
30 ms input pulse 30 ms pulse
then start a pulse train 30 ms ON 30 ms OFF repeat this 7 times
I think you should draw a timing diagram that shows how the input signal and the output-signals shall look like
Yes, you are right, and it has been considered, since bigger injectors have been installed.
Also, about the AFR, obviously the ECM will adjust for that, but the idea is that it will stay at 14:1, which is why I need to modify it in the first place (to accommodate for the larger air volume).
Maybe intercepting the signal is not the best? Maybe I should tap it, measure it, and then extend it once it finishes?
Either way, I need a way to time it. How can I do that with Arduino?
Well this would be more of a super simple and minimalistic Fuel Ignition Controller, not really an ECM.
I mean, all you need to do is modify timing and injection based on MAP input. I know the ECU won't like it but we'll see how much once it's running.
I'd still like to know, is there a way to start a timer or something when the signal starts so then I can extend it when it ends (or a few moments earlier)?
Sure, but it can't be that complicated. I mean, you can buy FICs online which connect exclusively to the MAP without hijacking the O2 sensor or anything else and work perfectly, so there must be a way make it work, especially on older cars without that many sensors.
This is just a project on a project car, so I'm not concerned with it taking some back and forth.
True. Probably gonna have to simply intercept the signal and extend it accordingly just based on the signal voltage. There will be a minimal delay between the signal and Arduino opening the inyector, but I would be avoiding the stutter.
Am I doing something wrong in the second "if" statement? Why is my delay not working and it closes inmediately?
That's fantastic input, I only needed to change the first "if" to:
if(injV>0 && injState==0)
And now it works as intended, openTime does not update, simply stays on the value that was when first opening, and everything works as intended.
Only issue now is that the signal from Arduino doesn't stay on if the signal is high unless I'm tapping the signal instead of intercepting (because the injState is 0 only once). I'm gonna have to work on that. Maybe another if statement?
I don't follow. I'm measuring with the Arduino itself. When the signal is 5V I start the timer and then stop it when it's 0. There are no other devices in the circuit.