1st Arduino Project

Complete novice here. Both projects are car related, 12v DC, one will be used to shift gears on an automatic transmission when the selector is in "sports" mode. The other project is a little more difficult, getting my steering wheel audio controls to function.... this one I'm still trying to get my head around - will update when I have more information.

My plan is to use the cruise control stick on the steering wheel. Which has 12v going in and outputs a different voltage depending which action is used on the cruise control stick.

The transmission shifter has three micro switches used in sports mode. I'm yet to check the voltages at each switch but believe they are all 12v in/12v out. The first switch tells the transmission ECU (TCU) that is in sports mode and to listen for signals (on/off) from the remaining micro switches. The remaining switches tell the transmission to shift up or shift down.

The way I see this working is with an Arduino unit a changeover relay and two on/off relays.

What I need help with is building a shopping list of everything I'd need to complete the job. Including which Arduino would be best and a suitable enclosure for the Arduino unit.

Okay... So, I'mn pressing on with this. The first stage anyway. I've created a wiring diagram, if that helps.

The first thing you'll need to do is sort out signal level translation, the Arduino only works with 5v, outputting 12v or 7v through it will kill it (Shift_Down)

I guess the best thing to do would be to feed the output from the selector (I'm not sure why it's labelled as Audio?) through a voltage divider to divide it by 3, giving the maximum voltage as 4v. Analog pins can cope with the variation below this fine.

outputting 12v or 7v through it will kill it

No it won't. It won't be possible, but no harm will come from trying.

PaulS:

outputting 12v or 7v through it will kill it

No it won't. It won't be possible, but no harm will come from trying.

My mistake, but the problem remains as it won't shift down either!

spynappels:

PaulS:

outputting 12v or 7v through it will kill it

No it won't. It won't be possible, but no harm will come from trying.

My mistake, but the problem remains as it won't shift down either!

I mis-labelled things in my drawing - sorry. The "audio controls" are part of another project. The switch arrangement I'm using in this project is the Cruise Control Switch, which I've mistakenly copy+pasted the Cruise Control ECU item. The two switch assemblies enclosed in a border are the two switch assemblies on the cars steering wheel.

The cruise control switch outputs a maximum of 9.7 volts from one of its actions. The rest are; 0.4v, 5.5v and 7.4v. I was looking to use the 9.7v and 7.4v actions to control the transmission. If the 5 volt issue existed I was going to use a voltage divider to bring these signals down to 5v max.

The 5v issue not being so I would plumb the output from the cruise control switch to the Arduino unit. From there to the two up/down relays.


The second Arduino project is to use the Audio Control Switches with an aftermarket stereo. Currently the audio control outputs voltages of; 7v, 6.8v, 6.75v, 6.6v, 6.5v and 6.4v. The deviation in these signals is not great enough for the stereo to differentiate between each action. My plan was to have the Arduino unit "spread" the difference more noticeably for the stereo. For example; 7v = 7v, 6.8v = 6v, 6.75v = 5v, 6.6v = 4v, 6.5v = 3v and 6.4v = 2v. I'm just not sure the Arduino could A) work with such slight deviations, and, B) can the Arduino output a range of voltages like this through a single outlet.

I know you can get a device to do this Audio Controls job already, I just thought I'd give the Arduino a shot first.

5_Fingers_Left:
The cruise control switch outputs a maximum of 9.7 volts from one of its actions. The rest are; 0.4v, 5.5v and 7.4v. I was looking to use the 9.7v and 7.4v actions to control the transmission. If the 5 volt issue existed I was going to use a voltage divider to bring these signals down to 5v max.

The "5 volt issue" does exist. Whatever confusion has previously been caused (you cannot generate more than 5V from the Arduino with its 5V Vcc), you do need to scale the voltages so that no more than 5V is applied to either an analog or digital input. If the resistances in the switch are more than a few hundred ohms, you need an op-amp to perform the voltage division with resistances at least 20 times those in the switch, to feed the Arduino.

5_Fingers_Left:
The 5v issue not being so I would plumb the output from the cruise control switch to the Arduino unit. From there to the two up/down relays.

You can use a voltage divider. Use resistor values of between 1 and 10k so that the input impedance to the analog pin is less than 10k, but ensure that there is more than 1k between your voltage input and the Arduino pin to ensure no more than 5 or 6 mA (and preferably a lot less) could flow into it.

5_Fingers_Left:
The second Arduino project is to use the Audio Control Switches with an aftermarket stereo. Currently the audio control outputs voltages of; 7v, 6.8v, 6.75v, 6.6v, 6.5v and 6.4v. The deviation in these signals is not great enough for the stereo to differentiate between each action. My plan was to have the Arduino unit "spread" the difference more noticeably for the stereo. For example; 7v = 7v, 6.8v = 6v, 6.75v = 5v, 6.6v = 4v, 6.5v = 3v and 6.4v = 2v. I'm just not sure the Arduino could A) work with such slight deviations, and, B) can the Arduino output a range of voltages like this through a single outlet.

I know you can get a device to do this Audio Controls job already, I just thought I'd give the Arduino a shot first.

Waste of time and effort. You need a couple of op-amps and some diodes.

The "5 volt issue" does exist. Whatever confusion has previously been caused (you cannot generate more than 5V from the Arduino with its 5V Vcc), you do need to scale the voltages so that no more than 5V is applied to either an analog or digital input. If the resistances in the switch are more than a few hundred ohms, you need an op-amp to perform the voltage division with resistances at least 20 times those in the switch, to feed the Arduino.

Okay, so I have to be sure the cruise control switch sends no more than 5 volts? This can be done with a resistor - 1k or greater? The output voltage is not important as the arduino is used to activate 2 x relays and 5v should be enough of a trigger the relays. The Arduino unit does not interact with the transmission ECU - just the up/down mirco switches. The arduino unit is not used in the cruise control circuit, it is isolated from the cruise control ECU. The signals from the cruise control switch can only go one of two ways at any one time; to the Cruise Control ECU, or, the Arduino.

The 9v, and other signals, from the cruise control switch are not sent to the Arduino unit - the changeover relay switches when the shifter is pushed into triptronic mode; push shifter into triptronic - changeover relay switches and signals from cruise control switch ae sent to the Arduino through a circuit that contains a 1kohm+ resistor - Arduino reads the signals and switches relays.

The audio controls is probably a waste of time, but I dont mind having a shot at it. To me, this would be the same as the cruise control switch - just be sure I send no more than 5v to the Ardiuno input. If the Arduino only outputs 5v or less thats even better - the HU/Stereo accepts a 5v input for steering wheel audio controls. I just program the Arduino to send out signals with greater deviation to the HU/Stereo.

I've jumped the gun anyway and purchased an Arduino 2560 and a few other parts.

5_Fingers_Left:
Okay, so I have to be sure the cruise control switch sends no more than 5 volts? This can be done with a resistor - 1k or greater?

The concept you need to use is a voltage divider.

But what you need to sort out is what the effect of the various switches in the Cruise Control will be, not the same when you disconnect it from its original circuit and connect it to your voltage divider.

5_Fingers_Left:
The output voltage is not important as the Arduino is used to activate 2 x relays and 5v should be enough of a trigger the relays. The Arduino unit does not interact with the transmission ECU - just the up/down micro switches. The Arduino unit is not used in the cruise control circuit, it is isolated from the cruise control ECU. The signals from the cruise control switch can only go one of two ways at any one time; to the Cruise Control ECU, or, the Arduino.

I do hope your relays are within the ability of the Arduino to drive them, that is taking less than 25 mA from the port pins. Generally you need a transistor to drive them, preferably supplying them from the 12V supply instead and including the "back" diode across the coil. (Unfortunately I cannot find a clear and simple explanation of such diode).

5_Fingers_Left:
The audio controls is probably a waste of time, but I don't mind having a shot at it. To me, this would be the same as the cruise control switch - just be sure I send no more than 5v to the Arduino input. If the Arduino only outputs 5v or less that's even better - the HU/Stereo accepts a 5v input for steering wheel audio controls. I just program the Arduino to send out signals with greater deviation to the HU/Stereo.

The Arduino cannot output more than 5V since its supply is 5V. What you do have to be careful about is ensuring that no device to which you connect it as an output, will apply more than that back. Generally, using isolation transistors and/ or relays.

Paul__B:

5_Fingers_Left:
Okay, so I have to be sure the cruise control switch sends no more than 5 volts? This can be done with a resistor - 1k or greater?

The concept you need to use is a voltage divider.

But what you need to sort out is what the effect of the various switches in the Cruise Control will be, not the same when you disconnect it from its original circuit and connect it to your voltage divider.

5_Fingers_Left:
The output voltage is not important as the Arduino is used to activate 2 x relays and 5v should be enough of a trigger the relays. The Arduino unit does not interact with the transmission ECU - just the up/down micro switches. The Arduino unit is not used in the cruise control circuit, it is isolated from the cruise control ECU. The signals from the cruise control switch can only go one of two ways at any one time; to the Cruise Control ECU, or, the Arduino.

I do hope your relays are within the ability of the Arduino to drive them, that is taking less than 25 mA from the port pins. Generally you need a transistor to drive them, preferably supplying them from the 12V supply instead and including the "back" diode across the coil. (Unfortunately I cannot find a clear and simple explanation of such diode).

5_Fingers_Left:
The audio controls is probably a waste of time, but I don't mind having a shot at it. To me, this would be the same as the cruise control switch - just be sure I send no more than 5v to the Arduino input. If the Arduino only outputs 5v or less that's even better - the HU/Stereo accepts a 5v input for steering wheel audio controls. I just program the Arduino to send out signals with greater deviation to the HU/Stereo.

The Arduino cannot output more than 5V since its supply is 5V. What you do have to be careful about is ensuring that no device to which you connect it as an output, will apply more than that back. Generally, using isolation transistors and/ or relays.

Voltage divider answers my next question. I had the day off a couple of days ago and checked voltage and resistances at the cruise control switch. I then took those results away and did the whole V over I/R thing to determine what total resistance was required to drop the switches highest voltage (9.7vdc) down to the Arduino's 5v input.

Action - CANCEL
Resistance - 0.330 kohm
Volts - 9.7 vdc (at switch output)
Amps - 0.0294 calculated

Action - SET
Resistance - 1.000 kohm
Volts - 7.4 vdc (at switch output)
Amps - 0.0074 calculated

Action - RESUME
Resistance - 3.000 kohm
Volts - 5.2 vdc (at switch output)
Amps - 0.0017 calculated

I then took those figures and determined I'd need an additional 170ohm's of resistance between the switch output and the Arduino unit to ensure 5v max. Which would give me voltages from each action as follows; CANCEL = 5 vdc, SET = 1.3 vdc and RESUME = 0.3 vdc.

As far as I can tell there are no signals sent back to the cruise control switch.

The two relays I've purchased claim to be for Arduino projects and support 12v. Though I cannot find anything (yet) to tell me what current is required to drive them at the trigger end.

Image of the relays

My plan for the Changeover relay, that switches the cruise control switch output, was to use a more readily available relay. Something I could pick up from the local autoparts shop.

ALL of this would be assembled and tested out of the car first so I can check voltages etc. and to be sure I dont nuke anything.

The Audio Controls part of this project has been abandoned essentially. I believe I might be safer to buy a SWI-X unit from the people at Pac-Audio. I just dont like the bitter taste of admitting defeat before I had a shot at it myself.

Turns out the SWI-X is not how would want to have my controls function. The audio controls project is back on the table.

The Arduino board has arrived and in the meantime I've connected an old cruise control switch assembly to the Analog input and directed 5v (from the arduino board) to the switch.

Next question is; how do I get some feedback about the different voltages, sent from the switch, to appear in serial monitor?

Okay. I'm currentl;y very close to getting this to work. I can activate a relay according to an input from the cruise control switch.

But, its only one relay.

How can I set a "Range" for my analogValue figure? I've tried if (analogValue <990) and the relay switches on... great, but how do I get it to ignore signals higher than that?

I did try using AND in there, but that didnt work. I tried just adding the values like this - <990 >1000 but that didnt work.

What am I missing here? Google isnt really giving me an answer I can understand.

Here's the Sketch I'm using - currently just trying to activate one relay. Was wanting to use two relays and only one analog input.
*/

// These constants won't change:
const int analogPin = A0; // pin that the sensor is attached to
const int ledPin = 23; // pin that the LED is attached to
const int threshold = 400; // an arbitrary threshold level that's in the range of the analog input

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize serial communications:
Serial.begin(9600);
}

void loop() {
// read the value of the potentiometer:
int analogValue = analogRead(analogPin);

// if the analog value is high enough, turn on the LED:
if (analogValue < 990) {
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin,LOW);
}

// print the analog value:
Serial.println(analogValue);
delay(1); // delay in between reads for stability

I now have this working on the bench using a 240 to 12v supply. The circuit arrangement I've altered in an attempt to incorporate some safety. I'd like to add more warning and (self)checking into the program though.

The hardware I'm planning to use in the final device is as follows
Layer #1 - Arduino 2560 board
Layer #2 - Relay shield
Layer #3 - Prototyping shield, which will include my resister to earth and zener diode.

What I would like to add is fuses - can I add these as a "solder in" option to Layer #3, or, am I better off adding them in-line as part of my wiring loom to the device?

I've added an active buzzer to my circuit that sounds when I shift up or down, but want to use this same buzzer to warn me of failures. Any input on additional warnings/checks I could incorporate would be appreciated.

Code on PasteBin -> /* Conditionals - If statement This example demonstrates the use of if() - Pastebin.com

Colour wiring diagram on Imgur -> Imgur: The magic of the Internet