I'm attempting to create a revmatching box that essentially matches the engine rpm with the rpm the gearbox is spinning depending on the gear (perfect down/up shifts). Inputs would include : clutch switch, 6 gear position switches, rpm (12v pulses), speed sensor (12v pulses) and throttle position (there are two on my car for some reason. One that ranges from 0.5v to 4.5v, the other from 0.2v to 2.3v) It would need to output (via the pwm) the two throttle position signals. I'm quite a noob when it comes to microcontrollers but after reading reviews and such this seems to meet the requirements. I think I have a handle on the programming aspect but I'm not sure the built in analog in/out will be able to handle the signals. Is the Arduino Mega a good microcontroller for this project? Would I need to buy stronger a stronger dac or adc? Open to suggestions!
Sounds like a reasonable project for a Arduino. The I/O count you listed might even be met with a 328 board rather then the more expensive Mega1280. However you may end wanting to use more user interrupts then 2, so the Mega is probably a safer choice upfront even if you don't end up needing the extra I/O and memory.
Most of those switch inputs and your stated speed pulses will might end up being 0/12vdc (you stated the speed pulses were 0/12vdc) so you will need some small amount of external components to make sure all input signals are 0/5vdc, via voltage divider resistors or zener clamping diodes, etc.
Be sure you understand what a PWM output signal is, it's not a pure analog 0-5vdc output voltage unless you do some external low pass filtering on the PWM signal. So you will need to know what the receiving devices is expecting of your analog output signals.
Good luck on the project
Lefty
Thanks for the response!
Do you have any recommendations for voltage dividers or low pass filters?
something like this active filter? :-/
I honestly have no clue when it comes to electronic components (anything more than analog volts). More of a programmer but I'm learning.
would a 5v Voltage Regulator (LM7805) work to lower the voltage for the rpm and speed, or would it overheat/not regulate fast enough being pulsed? Would a pwm + capacitor react too slow as well? Would a digital potentiometer be quicker?
use an opamp to amplify it down to 5V!
Alec
Well in the industrial world most speed pulse inputs wire to a comparator type op amp so that the threshold switching valve can be set (either fixed or adjustable) and the output cannot go over the +5vdc of the comparators +5vdc Vcc.
Lefty
would a 5v Voltage Regulator (LM7805) work to lower the voltage for the rpm and speed, or would it overheat/not regulate fast enough being pulsed? Would a pwm + capacitor react too slow as well? Would a digital potentiometer be quicker?
A regulator has much too much minimum input current requirement for use as a signal processor, speed issues also.
PWM output conditioning is a separate issue, you first need to know the input signal requirements for where the signal is being wired to.
Digital pot would work, with additional parts, but much too complicated for the simple task of lowering signal voltages to 0-5vdc range. Just two resistors make a simple voltage divider that would work fine. Or use a comparator op amp.
Lefty
So I should use two resistors to lower the 12v pulses down to 5v? Then use a low pass filter for pwm output back to the throttle position inputs of the ecu? I don't have any technical specs for the signal requirements, any way to test? If the ignition is turned on and 0.5v/0.2v is not present it throws an error code and disables the sensor inputs. I imagine this will be easier to test when my arduino mega arrives.
So I should use two resistors to lower the 12v pulses down to 5v?
Yes two series resistors wired from the signal to be converted to ground and then the voltage measured at the junction of the two resistors and ground would be wired to the Arduino. Example, two equal 10k ohm resistors would divide a 12v level to 6 volt, still too high to wire to the Arduino max is +5vdc. You could also just use a 10k ohm potentiometer with the the signal to one fixed terminal, ground to the other fixed terminal and the wiper terminal adjusted and wired to the Arduino digital input terminal.
Then use a low pass filter for pwm output back to the throttle position inputs of the ecu?
Probably, a simple low pass filter is just a resistor and cap wired in series to ground and the filtered signal available at the junction of the resistor and cap.
Lefty
You've been extremely helpful! Would the two resistors in a series not put strain on the 12v pulses?
:-/....I am willing to paypal someone $20 if they help me figure this out (and it works!)
Would the two resistors in a series not put strain on the 12v pulses?
That depends on the output impedance of the device generating the speed pulse. The higher the ohms of the resistors the less load it places on the signal. I suspect anything at or above 10k ohms would be OK. The signal is going to a digital input that doesn't require a perfect voltage, just above the switching threshold of the digital input, around 2.5v I think. It's not a analog measurement, just a on or off digital pulse with the pulse frequency being relative to the RPMs.
Lefty
So a 15k and a 30k to be safe or a 10 and 20? That would give me 4v pulses?
I would start with a 7K and 5k in series, with the 5K at the ground end.
Again a small trimmer pot of 10K or so would work fine and would be adjustable: http://www.allelectronics.com/make-a-store/item/MTPS-10K/10K-MULTITURN-TRIMMER-POT/-/1.html
Lefty
I'll just save myself the hassle and use the trimmer pot. If you could point me out a suitable low pass filter I'll be all set (and leave you guys alone)
Thanks again
If you could point me out a suitable low pass filter I'll be all set (and leave you guys alone)
That's not quite as easy. The R/C values of the resistor and cap depends on the switching frequency of the PWM signal of 490hz, the input impedance of the the device receiving the signal and how much signal ripple your device can handle. I've used a 5K resistor and a 10MFD cap in series with the cap going to ground and measured pretty clean analog voltage values, but I don't know if that filter value would respond quick enough for your device receiving the signal. You will have to experiment some, unless someone else has a better guess.
Lefty
I'll just buy a couple filters and see what works. The less lag the better.
Update: My mega came yesterday and I wired it up to test to see if PWM would be sufficient. It worked about 10% of the time. Kept throwing a check engine light and a "throttle voltage too low" error code. When it did work it was extremely smooth and responsive. My question is would a 50v 10mfd cap and a 5k 1/4 watt res work as a good testing starting point or am I way off? (don't want to break my new mega or my ecu)