View Single Post
Old 05-24-2013, 08:04 AM   #44 (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 will find an IC with both the accel and gyro then. What do you think about the MPU-6050 IC?
That one uses I2C for the output.

I get that when you have a 10M ohm resistor, the R2 will have to be ~8M ohms, but I don't get why you start with a 10M ohm resistor. How would a lower resistor alter the VSS?
The 10M Ohm is arbitrary but a safe place to start without knowing more about the parts of the circuit that are inside the VSS and ECM.

I need to correct my suggestion that the total current is drawn through the VSS. (I knew how it works. I was not thinking about it and just working from left to right on the image). It is the ECM that supplies the current, the VSS sinks it. Conceptually it makes no difference though, other than it being the ECM that sees the total current.

The easiest way to explain what happens to the VSS signal if the resistance in the extra circuit is too low, is to take it to the extreme and place no resistor (R1 + R2 = 0) in the spliced in wire that is connected to earth. The VSS signal is then shorted to ground and never goes high i.e. there's no longer a VSS signal. (That should address your next paragraph also.)

Is 20 cents, not including shipping, an expensive resistor? (Seriously, I have no idea)
Yes (as distinct from an expensive price for that resistor). You can get what you will need for a few cents each (depending upon the quantity you buy). They don't have to be anything special just the correct resistance. 1/2W will be OK.

Not sure how that works. Isn't digital on/off. If I want speed readings, I would need an analog pin to have more than just 1 or 0, right?
As it's a square wave it only has two states: high (= 5V or even ~11V) and low (= 0V). That's a digital signal.

Does it matter which common side LED I use?
You mean which of the two common (cathode) pins on the 7-segment display you connect to ground? Yes. That is what will determine which digit will be on. (You could connect both to ground at the same time and they will each display the same digit.)

Will there be a benefit for a common anode or cathode?
Not really but which one you use will determine whether you want the pin outputs from the 4511 to be high or low. If you want them low (common anode), you'll need transistors for each pin to invert the signal. I think common cathode is more, er..., common anyway.

To figure out how the circuits work, it may help you to look at a few LED circuits (as in discrete LED's). The 7-segment display is just how 7 (+ the DP = 8) LED's are packaged. Even buy a few LED's, resistors and transistors (or just one of each), maybe a switch, and play with them a bit. I'm sure that you can find 4 AA batteries and, connected in series (a battery holder that does that for you is only a couple of dollars), that will get you close enough to 5V to provide the supply.

So I don't get to have both digits on at the same time?
No, but it doesn't matter because you will see both digits as 'on' at the same time. The Arduino can switch the digits on and off faster than your eye can recover from having registered the image. Just like a movie film (where you are only ever shown discrete images) fast enough that what you see is a single image.

Or can I do that, it would just use twice as many Arduino pins?
Not with a dual 7-segment like that one where the LED's are connected inside the display. You could with two discrete single digit 7-segment displays. Twice as many pins, yes. Also twice as many resistors and twice as much space on the shield but why, when you can do it the easy way with two transistors and one additional pin?

Transistors like this?: Transistors Is a dollar a transistor a decent price?
I would use two BC337 NPN's or two BC327 PNP's at about 5 cents each.

Edit: Like this:

Ideally, I would like to have the display show a decimal (say 7.2 or 8.4). The percent would be implied. Because of that, I would like to have the decimal point. So I can just wire it to ground or power and it will always show? A current limiting resistor similar to the 10M or 8.2M ohm ones? I'm confused does the wire between the arduino and LED need transistors or resistors or both?
Both the LED's (in each segment) and Arduino have current limits which determine the allowable current in the circuit. Use whichever is lower. The resistor is what provides the current limiting.

Each LED (of 8) needs a resistor, whether between the LED and Arduino (or4511) or with the LED connected (directly) to the power supply (for a common cathode display). The lowest possible resistance depends upon the supply voltage (5V for us), the forward voltage (Vf) required to light the particular LED and the relevant allowable current (I).


R=(Vs-Vf )/I

Vs is the supply voltage. Vf and I are found from the spec. sheet for the LED or 7-segment display but might be something like 3.3V and 30mA. Or use the current limit for the Arduino (which I think is 20mA supply and 40mA sink per pin and less than 200mA total, for everything connected to it?). Use whichever is the lowest of the current limits.

For a 5V supply and ignoring the Arduino pin limit:

R = (5 - 3.3)/30x10^-3

R = 56.7 Ohms

You might use 100 Ohms to give some margin for error.

You can use a higher resistance than that minimum but the LED will dim. Because you are switching the digits on and off each of them will appear dimmer than they will be when on continuously anyway (for set up).

To multiplex the two displays, you need two transistors and two pins on the Arduino to switch each common pin, to ground for a common cathode display, on and off in turn.

With the integrated dual 7-segments the decimal point will be multiplexed with the other segments. You would have to use an eighth Arduino pin to switch that.

With 2 discrete displays you can hard wire the dp independently of the Arduino (other than the multiplex switching). It still needs a resistor though. Multiplex it with the corresponding digit otherwise it will appear brighter as it would have a duty cycle of 100% vs the 50% of the two digits.

So something like this? 4511 IC Seems a little expensive, but is it the right part?
That price is for 10 isn't it? Yes, that's the one. (Some individual IC's will cost that much or more so it's not a silly question to ask).

I'm not sure what you mean by it being easier, but all I want is a 2 digit screen, not a screen that will display a whole lot of info (that's what my ultragauge is for!). If I decide to do some other project that needs a larger display, then I might consider a larger one.
Absolutely. Do it the way you want it to be. That's just one advantage of building stuff yourself.

The LCD display is easier because once you have the 10 connections made (only 6 of which are the Arduino connections and not supply or ground) it's really easy to display anything that uses ASCII symbols (+ some custom ones); it's adaptable. There's no stuffing around with resistors (other than the display dimming, if you want it). It's much easier to deal with in the sketch too (the LCD library does all the heavy lifting, otherwise the LCD would be more difficult).

FWIW, I was going to use a 7-segment display in another project (that's why I had the breadboard circuit done) but reconsidered it (actually in response to one of your earlier posts when I realised what an LCD display could cost vs all the parts for the 7-segment). It is cheaper to use the 7-segment but not by all that much.

Obviously, that is a lot further down the road, so we can worry about this part later. For now, though, I will still consider theory. I wonder if I should do the Kalman filter to help keep the creep away between resets. Once everything is up and running, I can see if the creep is low enough for a full days trip. Or maybe I can set it up to reset in the morning before I go to work and in the afternoon before I leave work. Or I can do it after those trips (i.e. after parking at work; after parking at home, but still set on a pre-set time). My work days usually require stops at the beginning and end of the trip, but not in the middle. I use the CC almost exclusively, so speed changes won't happen often. Again though, we will have to see how in-depth we have to get once it is all setup.
I'm not sure how relevant the Kalman filtering is (like I posted, it's new to me). I think that the guy that started that thread is using it to control a robot, stabilised using the gyro and accelerometer. I think he is using the filtering to remove signal noise that could be interpreted as a movement. That may not be wholly applicable to this application.

I would have to write some of the sketch to get a sense of how much error will be there. Just intuitively, I expect that a single trip is going to need the reference reset, where it's available. If you don't have a stop on your commute, I do think that a constant speed will be OK.

Noise may be an issue but the inherent drift will be there because the integration is based on the sum of measurements taken a finite time apart and not an infinitesimally small time. It's not a true integration but an estimate.

Thanks for the redone diagram of the wiring. So I will have to solder on some pins that fit into the terminal onto the patch harness. From there, I can splice into the patch wires and essentially make a 'T' or 'Y' splice, one to ECM and one to Arduino.
That sounds about right. You don't have to use veroboard (although you could mount the resistors and the faux ECM terminal pin on that). Doing it in free air and wrapping it in heat shrink tubing will work for this (not tape if you can avoid it; even the good stuff tends to unravel.)

Alternatively, you might find space on the shield to do it there. I suggest also putting a connector in the wire connections to the GDuino so you can remove the GDuino without having to cut wires or unpin the VSS terminal to the ECM.

So R1 will go to the 5V input pin and R2 goes from ground pin to ground? That would put the Arduino in series between the two resistors. The diagram can be a little misleading, I just want to make sure I have that correct.
If I understand you, not quite. One end of R1 is connected to the VSS signal, the other end of R1 to the Arduino input pin. One end of R2 is also connected to the 5V Arduino input pin, the other end of R2 is connected to ground, whether on the car or on the Arduino.

Because the VSS and Arduino will nominally share a common ground potential it shouldn't matter whether you connect the ground end of R2 to a ground on the car or to one on the Arduino.

Because there will almost certainly be small differences in the ground potentials, and you want the potential of 5V to be across the Arduino input and ground pins, it's probably better to make the ground (and check the potential across it and the nominally 5V signal) at the Arduino. Be careful because if you exceed 5V you will be implementing one of the 10 ways to destroy an Arduino.

If you like to put it that way, the Arduino is in parallel with R2, (and together with R2) in series with R1 and the whole lot (Arduino and R1 and R2) is in parallel with the VSS signal to the ECM.

Originally Posted by jeff88 View Post
Do I need to have a ribbon cable, or can I just use telephone wire/CAT5? I feel like that would be more versatile for this application.
If you have to pick one, use the ribbon cable. The solid core is only good for making connections on the circuit board (and prototyping on a bread board).

Solid core is better for the circuit board because it is easy to poke into the holes. The multi-stranded wires in the ribbon cable have the potential to fray and create short circuits as you are feeding them through the holes. You can either be careful when poking them through the holes or twist and/or tin the wire ends with solder before using them. That's a bit more effort to do.

The wiper for the trim potentiometer is in the same hole in the shield as the ribbon cable wire connecting it to the LCD display. That would be virtually impossible to do without tinning the end of the wire first.

The telephone cable was less than $1/ft (more like 50c). The ribbon cable not much more. 3ft is plenty for more than one project.

Flying leads (for a display or sensor remote from the Arduino) won't work very well with the solid core cable; it's too stiff. You'll notice that I have split the ribbon cable (after making the connection at the LCD end). That's because ribbon cable doesn't like being bent or twisted in more than one plane. With the individual wires separated out it's not a problem.

Were the wires longer, I would wrap them in heat shrink or even tape.

You can use a different type of cable. It's very low current so nearly anything will work. Whatever works for you.

What are the capacitors for?
Noise reduction. The provision for them is on the shield and I had them in the parts box. They're only a few cents to buy anyway.

What's the PCB switch for, the switch in picture 4 that turns each segment on/off?
That's instead of the Arduino. I didn't need to test the Arduino's ability to switch the pins, just the part of the circuit that is 'downstream' of the Arduino input. It's very easy to move the switches and see what the 7-segment display does in response.

What does the LED do? Just a signal that the board is on?
Yes. It's a duplicate of the one on the Arduino UNO board that gets masked (a bit) with a shield in place. That and the 1k resistor are also from the parts box. You can leave them and the reset switch off if you want to.

What kind of solder should I use (I assume solder for copper pipes is different )? I have another project that I have to solder some wires to some solar modules, so if there is a solder I can use for both that would be beneficial (e.g. cheaper).
Resin cored solder suitable for electronics. It comes in 2 wire diameters (that I know of) but is sold by weight. If you only buy one thickness, the thinner one is easier to control and to melt but you have to feed it in a bit faster (not that you have to feed it in very fast anyway).

You can get lead free solder (tin based) but the melting point is higher so it's a bit more difficult to use. Don't mix that type and leaded solder though i.e. use one or the other type consistently.

Is the solder wick/braid for when I make a mistake? (which will inevitably happen )
Yep, that's what it's for. Be patient if using it. If the solder join is not fully melted and you try to pull the component off the board or you put too much heat into the join (wait for it to cool before repeat attempts), you can pull the metal layer off the board. Sometimes it helps to add a bit of solder (and the flux in the solder core) to the wick when you are trying to remove the part. It is better not to make the error in the first place. Lay out everything before you start to solder.

So I need a breadboard/open shield between the Arduino and display? I can't wire them directly, with components in-line? If I use the 4511, I guess I will need the shield to mount it on, right?
The bread board is for quick prototyping only. It doesn't require solder, making for quick circuit connections, and it's easy to break circuits back down to try an alternative. You don't use it to make the final circuit.

If you are using the 4511 and the resistors there are a few too many parts and connections to make the circuit in free air. The use of an IC means you'll need some sort of board anyway. In addition to that, wires soldered together without a board to support them tend to break. If you want to mount the 7-segment display separately from the Arduino, you will probably want a small circuit board to do that on

Veroboard is the correct stuff to use. It's like the prototype shield and has the holes with the metal layer around them that you can solder onto (you make the connections/form the circuit with the leads bent over on the back of the board before you solder anything).

What do you mean the switches are doing what the Arduino will do? Turning each segment on and off? So it is a manual number at this point, just to test the circuit?
Yes. Once you understand what those switches are doing you understand what microcontrollers do (even if not how they do it).

Are these pics on Photobucket or similar, so I can see them larger?
They aren't but when I get some time I'll try reposting with images that are closer to the upload size limit (and maybe in a different file format).

It may help in seeing how the bread board circuit is connected if you realise that the bread board comprises part of the circuit. As the image is displayed the centre part has columns of 5 sockets. Each column is a single connection; they are joined inside (under) the board. The 2 rows of 5 column wide sockets, top and bottom are likewise connected into the groups of 5 sockets. The rows are used for supply and ground, top and bottom, each group of 5 sockets daisy chained on the top of the board to the next.

The supply and ground are connected back to an adapted phone charger (5V, 1A) connected in at the top right corner.

The capacitor is to smooth out any ripples in the supply.

Last edited by Occasionally6; 05-27-2013 at 02:43 AM..
  Reply With Quote