View Single Post
Old 05-19-2013, 02:04 AM   #37 (permalink)
Master EcoModder
Join Date: Apr 2013
Location: World
Posts: 385
Thanks: 82
Thanked 82 Times in 67 Posts
Originally Posted by jeff88 View Post
So I can do a single 3-axis board with the VSS or 2 3-axis boards if I cannot get the VSS to work? If that is the case, I might just do 2 3-axis boards, so I don't have to mess with any vehicle parts directly.
That would be like using two measuring tapes; there's no need. A gyroscope (unless that's what you meant) would add additional data. That could work too/instead.

Does this one from the parts list output in I2C or in voltages? I couldn't find out from the datasheet provided. 3-Axis Accelerometer
Says it's analog here:

According to the datasheet for the Accel. 3.6V is the maximum voltage it will accept. So I guess when I run power to the Mega/UNO, I will run the wires from the battery through the diodes into the Vin header. Then I will run a wire from the 3.3V header to the Accel. Does that sound right?

So from what I've read, the 1N4004 will have a voltage drop of about .7V. Is that correct? That means that with 6 diodes (wired in series?), the voltage will drop from battery voltage from 12.6 (assuming fully charged) down to 8.4. That is in the operating range specified, but is that too many diodes? Maybe if I use 4 diodes to get me under 10V, that might be better?
I'd rather put in a few diodes, so I don't accidentally overload the circuits... cheap insurance.
There are a number of ways to get power to the Arduino. They can also be powered via the USB connector, indeed will be while programming. Another suggestion to consider is gutting or using intact a cigarette lighter/accessory socket to USB socket adaptor.

When calculating the "battery" voltage, consider that the alternator will be charging at something more like 14V with the engine running. It would be sensible to check what it is.

Wouldn't it be easiest to have the accel. just be in the correct position, so I don't have to do any other fancy work in the Sketch?
It would make the sketch simpler. It may be difficult to achieve physically.

BTW, do I have to mount the board horizontally, or can I mount it vertically?
You can mount it vertically. That just means that what is nominally the z axis becomes the x or y axis. You just relabel the variables in the sketch to suit.

According to my Haynes manual, "The sensor sends a pulsing voltage signal to the speedometer, which is converted into MPH." Does that help determine the signal output? It looks like there are three wires in the VSS output.
Perfect. It's uses a Hall sensor. It should be 50% duty cycle. That means it will be at 0V for the same angle of rotation as it is at 11V for. With the DMM you can easily check that. With 4 pulses per pinion rotation you should see 11V for 45 degrees of pinion rotation (= driveshaft rotation if they are both rotating together), then 0V for the next 45 degrees and the pattern repeat for the next 270 degrees.

You will tap into the "11V" signal wire. You can do that at the VSS or, more easily, at the ECU (especially if the ECU is in the cabin). Easiest is simply to splice into the signal wire but I don't like cutting into the harness.

When doing things like this I will make a patch harness. Find a wreck (junkyard) and cut off the terminal connector of the equivalent ECU or VSS harness with ~6-8" of the wire still attached.

Unpin the VSS ECU wire or use the VSS connector intact and replace it with the salvaged wire + pin socket or connector. (Be careful not to damage the terminal if unpinning - practice on the wreck).

Solder a pin (same diameter as that which is used on the ECU) or terminals (for connection at the VSS) to the 6-8" of wire (cut it shorter to suit) and attach the vehicle terminal or connector to that. Use heat shrink to protect the terminals against a short circuit.

You can then splice into the new wire without damaging the car wires and return the wiring to stock when you remove the accessory.

You will need to modify the signal on the splice before feeding it into the Arduino. It needs to be between 3V and 5V, not exceed the current limit for the Arduino pin and not pull the signal down so far it affects the VSS input to the ECU.

The way to do it is to put a voltage divider in the splice wire, which is connected to earth. The signal to the Arduino is taken from between the two resistors. The ratio of each resistor to the total resistance is such that the voltage drops give 5V at the point between the two resistors.

The total resistance should be as high as you can use and still get the Arduino to detect the speed input. Total resistance too low will pull the VSS signal to the ECU down. I would start with 10M Ohm and 8.2M Ohm 0.5W resistors (the closest that you can buy to the 8 Ohm a simple V=IR calculation would suggest) and go progressively lower if the Arduino doesn't work with that.

Don't go below 600 Ohm between the VSS signal wire and the Arduino (that will limit the current into the Arduino to < 10mA). Also check that the VSS signal to the ECU is still ~11V. Also check that the VSS signal voltage is actually 11V with the engine running (i.e. with the alternator supplying ~14V). If it goes higher with the engine running you will need a different ratio in the voltage divider to get the 5V.

I would build that circuit on a piece of veroboard (or similar) and put it in a potting box.

Here for reference:

Arduino - PulseIn

Arduino - Constants

Voltage divider - Wikipedia, the free encyclopedia

Is that a generic question? If it is, I don't know the answer.
Just that someone else using an MPGuino in the same model will have solved the problem before.


A few more questions:
The Arduino boards have analog and digital input pins. Which is better and which should I use? For the accel. board, do I run 1 wire from each x,y,z sensor to 1 input on the Arduino, or does each sensor wire get its own input (1 for X to pin 1, 1 for Y to pin 2, 1 for Z to pin 3)?
Each output - x, y and z - from the analog (i.e. not I2C) 3-axis board needs a separate analog pin. You might want one more of those reserved if you anticipate multiple switch inputs. You're going to run out of pins if you want to use gyro and linear accel. with analog inputs, and want to use a voltage divider on an analog pin for multiple switch inputs as well. You can still use the other pins as digital inputs for switches. You do have 6 pins already used by the LCD module.

Are the pins' input and output combined into the same pin? If so, how does the Arduino know if it is an input or an output, or does it matter? Will that be something I design in the Sketch ("If this happens, then run signal through pin X")?
analogRead() is implicitly an input command.

Would a gyro help me in this endeavor at all? Gyro, or is it not necessary?[/LIST]
You might be able to use a gyro to "dead reckon" the angle i.e. integrate angular acceleration (as for the linear accelerations) to get the total angle moved from a reference point. The integration in Arduino can't be a perfect sum of the accelerations so you would need to reset periodically back to a known starting angle avoid a creeping error.

You might use a situation where there is no change in any of the accelerations for a period of time, like 5 seconds, and/or the vector sum is equal to 1g to indicate the car is stopped. Then use the fact that the linear acceleration will only be that due to gravity when at rest. If you're on a slope in that situation you would use trig. to determine the angles.
  Reply With Quote