Looking to do a few projects with my car

I was pretty much directed here by Raspberry Pi folks and for good reason. I have a few simple things I want to control. Ultimately I want to tie in everything with a Pi, touchscreen and a GUI, but we'll see.

I have 2 solenoids that actuate vacuum operated valves, I'd like to activate based on engine RPM. What I need...

#1 ON-4000rpm OFF-6800rpm
#2 ON-4800rpm OFF-6800rpm
They also need to open again sequentially as the RPMs go down. It needs to be up and running with ignition key on, I can provide the 12v for that and a 5v rpm signal. I also want want the Arduino to tell a Pi 3 the status of the valves. That can be a simple on off output for each one.

The solenoids are 12V and operate like a relay, where vacuum does the work of operating the actual valves that open and close.

I am a complete blank slate as far as Arduino goes. I don't own one yet. Recommendations for which model to get, smaller is better, low power is better, whether I'll need particular hat or shield, and very simple programming that can be done by me with a Pi 3 B and/or Windows. I hope this isn't too tall of an order. I can go a different route, a more expensive route to achieve my goals, but I wanted to learn how to do this so I can do other things. I have automotive experience, automotive electrical experience and aviation electrical experience from the Navy. Very little electronics/programming though I also know exactly what I am doing in regards to the car/engine, I am tuning a stock system for airflow through the intake. Which has changed due to an intake and ECU swap. So currently the numbers are a little off and hacking this particular ECU is out, people have tried :smiley:

How does the rpm signal look like? Counting frequencies or so is quite easy to do, lots of examples out there.

If you're very sure the speed can only go up or down you can switch on/off at the exact rpm, otherwise you have to build in a bit of hysteresis to prevent clattering around your switching point.

Switching of the solenoids can easily be done low side using a MOSFET: use an n-channel, logic level type. Make sure to add a flyback diode at the coil.

To communicate the status with the Pi, easiest is Serial. Just sent a message such as "<1>" where '<' is the start tag, 1 is a status code (e.g. 1 = "solenoid 1 switched on", 2 = "solenoid 1 switched off", etc - or make it some simple binary protocol where say bit 0, 1 are for the relay 1 and 2 respective status - just make sure that this number can never be the ascii code of '<' or '>'), and '>' is the end tag of the message.

Ya know I'm not sure. I think it's 1:1, it could also be 2:1, 1:2. I don't have an oscilloscope, I'll do some research on the car forum, needle in a haystack style. The car is not currently running, waiting on the weather to finish the timing belt situation. worst case scenario I can always program 1:1 and see if the valves switch early or late. 4k is what it should read if it shows 2k on the tach or won't flip til 8k I'll know. I may have to set the numbers early if there's a delay on the flipping open.

So you mean it's a kind of block wave? Then just count the rising (or falling) edges, you don't need to know the duty cycle. Just makes sure the voltages are in range. Best use an interrupt for this, most accurate and ensures you won't miss pulses.

If it's one pulse per rotation, it's easy. Measure the time between pulses, and calculate the rpm from that. Or divide that by the number of pulses per rotation you actually get.

The pulse may be square. There shouldn't be valve any chatter, open/closed the valve won't seal completely and vacuum does the actuation. This is normal.

Okay, an interrupt, is this a time delay in the program or something else? Sounds like something resets at a value so it clears to count again from the description?

I'm with you on the simple <1> out to the Pi. All I want the Pi to do is change a rectangle on the screen from red to green when one flips and then an identical rectangle next to it for the second valve. It's not critical information, I want it there for testing manifolds and to know they are working.

An interrupt is code that's triggered by an event - like a pin changing.
See Arduino Playground - Interrupts.

PGTMR2:
Okay, an interrupt, is this a time delay in the program or something else? Sounds like something resets at a value so it clears to count again from the description?

An interrupt is a pin whose activity is ALWAYS going to be seen. It's set up that way, so even if the program is busy somewhere else, the activity on the interrupt pin will cause whatever's supposed to happen, to happen.

It's like the doorbell at your house: you don't need to go to the door once every five minutes to see if someone is there. Carry on with what you're doing, and if the doorbell rings, interrupt what you're doing and go to the door.

The alternative, checking a pin every time through loop(), is the one where you go to the door ever now and then, and someone may have been and gone between your checks, so you didn't see them. That's called polling.

If I use an interrupt will it, interrupt whether the valve opens and closes or does the interrupt only effect the signal to the Pi? Should I use one dedicated pin for each status pin? Since this is the device's only purpose, do you think an Arduino Nano would be good? I'm probably going to seal this from moisture in irreversible ways once this is finished, so the lightest cheapest model necessary will do. Or is there another model I should be looking at?

Your interrupt will be on your input for the rpm, so you don't miss one of those 5V pulses.

Look at the Pro Micro, even smaller and a bit cheaper, but you'll need a separate USB to TTL adapter for programming. Mini or Uno is easier for development.

Oh, right, gotcha! Thank you for catching my mistake! :smiley: If I understand correctly, yes interrupt when a signal is there would be better than loop, (continually checking for a signal at timed intervals.)

Is TTL a plug like micro usb or mini, or pins I have to be able to access?

It's a device that allows you to connect the Arduino to USB over th Serial interface. The Nano has this built in.

https://www.google.com.hk/search?q=usb+to+ttl+adapter

PGTMR2:
(continually checking for a signal at timed intervals.)

Not timed, in the strict sense of the word, as in "every 2 seconds" or whatever, but rather say "frequent". loop() runs as fast as it can, and that speed depends on what it has to do each time. Each iteration will not be the same as the others, if you have any (eg) "if" statements which could divert the flow this time but not the next, so the time between polls will differ.

That makes sense with the interrupt and not using a term that would imply a given time, and the ttl plugs into the narrow end of the Arduino board. Would a micro usb end be just as reliable as 5 pins? Both would have to be exposed a little. The Arduino will probably end up under the center of the dash, maybe I could make a plug for the case that pops in and out like a grommet for some added protection either way.

I bought a Leonardo Pro Micro ATmega32U4 5V/16MHz Arduino Bootloader Micro USB Pro micro. Based on 2 things price and shipping from in the U.S. I don't think I could wait a month and a half for a slow boat from China... literally.

Okay, so I'm pretty excited about getting this project started. It's still winter here, Arduino is in the mail. What software or program am I going to need to program this thing. Language? Seriously I know absolutely nothing. Will I need a shield to protect the Arduino. There's going to be 12v to power the Arduino (should I do 5v instead,) 12v for each solenoid. The tach signal will also probably be 12v safe enough for the car's ECU and tach needle, not sure on this other than I know the ECU itself will not like more than 12v so it should be pretty safe for the Arduino. Precautions?

I was thinking of testing using an ATX power supply and spare solenoids or maybe relays because the relays would click over so I know they're working. Maybe 2 LEDs for the output solenoid active signal?

PGTMR2:
Arduino is in the mail. What software or program am I going to need to program this thing. Language? Seriously I know absolutely nothing.

Download the Interactive Development Environment IDE here.

Then look at the examples here; they're also in the IDE at File > Examples.

Reference manual here.

You can write code and compile it in the IDE without an Arduino; can't run it of course. (Compile meaning conversion from human to machine language, and you can at least check if the compiler is happy with your syntax (although of course no guarantee the program will do what you want :wink: until you can run it)

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html

What are you trying to do with vacuum valves at certain engine RPM?

You need to google Arduino tacho

You will find many many examples of getting a tacho reading from an engine.

Using LEDs on the output idea is a good one for prototyping and gives you a visual indication instead of an audible one.

Tom... :slight_smile:

You guys are awesome, actually so far the whole site is great so far as forums go. I try to remember to look up the basics when new to forums. I will Google Arduino Tacho. It's funny Google is my go to for nearly everything I don't know. This afternoon I did a google search to figure out how to put a laundry dryer drum belt back on.

My engine has a variable length intake manifold, which switches in stages using the solenoids and vacuum actuators. This is a factory system. It moves the torque while the engine goes up in rpm by changing the shape of the intake flow internally. There are 4 different intakes optimized for different rpms and different volumes of air. I have all 4 intakes, the engine is swapped and the ECU is swapped. The solenoids are not currently timed correctly for the intake I'm using.

The original intake was made for lower rpm torque, the current intake is for high rpm torque and the ECU is programmed for a mid-high tq intake. The particular parts combination I have is for maximum hp and tq, naturally aspirated, (AKA NA, no turbo or supercharger.)

The ECU I'm using is not hackable/has not been hacked yet. There are aftermarket solutions at $80 a pop per controller, I'd need 2. Really it's not the money so much as it is that I want to do this, to learn to do this type of programmed controller for cars and other things.

This will just allow me to set the solenoids to the correct spec no matter which intake I install. Later I want do some porting and intake experimenting, so this will allow me to test and tune better as well. If there's any questions about this kind of intake, I can probably answer them.

Film of the intakes at 11:00

Design and with code I found from the tacho search. It looks like it will work and is exactly what I am looking for. It will need some tweaking I'm sure, to remove 2 leds. OR maybe 2 of the four LED pins could be used for the solenoids and the other 2 for led in testing and signal in the finalized version finalized. Additionally I was looking for an IR or light based triggering for possible distributor tweaking in the future!

What I found for this project

The link to this guys code