I haven't verified it but the Atmega chips aren't rated for use in automobiles according to a post someone made. They supposedly took the info from the data sheet. Could be they know something.
That's a good thought outofoptions. At some point I may need to accept that the Atmega (Arduino) isn't entirely happy in a car.
Please disregard the question about the battery above. I wasn't thinking straight. I ran out and pulled the plug out of the power port on the Arduino and ran it off Laptop USB power. Same result.
But I have a new suspect. While I thought I had done this before, it may not have been with the engine running. I wiggled the ribbon cable I have on my SRAM board going to my Arduino a bit while the engine was running. Sure enough, I could clock dozens of errors that way. Took apart the cable and found that I must have slightly bent some of the crimping pins on the ribbon cable connector at the SRAM end. I imagine this could have led to a breach of the wires on the cable too. Just as a quick experiment, I tried to clean up the pins a bit with a jeweler's screwdriver and a magnifying glass and then reinstalled it for a test. While I seem to get the same number of errors, it happens on its own on only one byte in each errored packed, I didn't get a single errored packet with > 1 byte bad. And I can still make it error violently by wiggling the cable at the SRAM end.
That cable is very likely toast, I need to get another cable. I'm trying to remember why I didn't just use an old 26-pin floppy cable from the electronics surplus place instead of building one from cable and connectors myself - the pre-built cable should be a heck of a lot more robust and reliable than my hand built one if I can get one in the right length, gender, and without that weird twist they put in those old cables as I remember! I need to go by the surplus place near me and see if they have an old floppy cable that would work.
Consider it in my hands for now until I can prove my cabling is good. Thanks to everyone for reading thus far and helping talk this through with me, I really appreciate it! I feel pretty lame that I posted prior to being 200% sure my cables were rock solid. My apologies for that!
I didn't use a floppy cable because they were 34-pin not 26-pin. Been so long since I've touched a floppy drive I had forgotten how many pins they were. I might need to search for another source of a pre-made 26-pin cable...
monte_carlo_ecm: That's a good thought outofoptions. At some point I may need to accept that the Atmega (Arduino) isn't entirely happy in a car.
Nonsense! A microcontroller is a microcontroller. Silicon is very similar, one family to another.
Rating for automotive use focuses on temperature specifications for modules in the engine compartment and whether the manufacturer feels like warranting this specification. If it isn't in the engine compartment, that is generally not a concern.
It is your business as the designer to condition the supply voltage and all the inputs (and outputs) to their specified values. If you allow those to stray, then no microcontroller (or clearly, any other device) will be warranted to function.
Thanks for the encouragement Paul__B. I'm actually hoping I can get it performing satisfactorily with a new cable. This won't be the first time in my project where I've been reminded that something which isn't completely rock solid may seem to work okay on the "bench" but then act strangely in the field because of the more hostile conditions.
I used to see this in my past life regarding appliance repair. When they started putting computer boards in refrigerators guys would always assume the board was at fault because that is what they least understood so it became their focus. It’s as though they suddenly forgot how to do simple continuity checks on simple components and didn’t check the things they KNEW how to check. Like cable ends? I hope that is your answer.
Well, I bought a proper IDT crimping tool and some new 26-pin IDT connectors. Built a new cable, much better than the one I was working with before, I can wiggle the cable as much as I want and I can no longer produce errors on command.
Unfortunately, and to my surprise and great disappointment, the random errors while the engine is running continue. Back to the same old symptom, often just one byte but sometimes a whole stream of multiple bytes. Same approximate frequency of occurrence as before. I guess my old cable was “good enough as long as you didn’t touch it”; I mean, I’m glad I changed it out because that’s no way to run things, but just to say that it looks like the true underlying issue I’m looking for is elsewhere.
I bought two more connectors than I needed to rebuild the cable, maybe what I’ll do is build a really short cable with those just to run a test to see if it changes anything. Aside from that I’m out of ideas.
Thanks again everyone for your thoughts and ideas so far…
I will suggest it is all about "lead dress" - how you run the leads from one part to another.
Any time you form a "loop" you have a potential for problems; you will generally be better off with all the connections to one part running together.
The ground in particular is important; while it has always been convenient in automotive wiring, to use the chassis as the ground return, that is not appropriate for digital electronics unless you have isolation of communication lines; opto or transformer - and also in general for radios where preferred practice is to operate from a cable pair directly from the battery; though I am not suggesting that here.
So either all the connections to your recorder come directly from the car computer, or vice versa. Having their power supply from different grounds is not appropriate.
Thanks for your thoughts on the power/ground sources Paul__B. I had been putting some thought into that, though I'm not sure how I could do it better. Maybe I can explain how it's done here as succinctly as possible and you could comment on suitability?
I'll start with the car computer. The schematic looks something like this:
Mine is a slightly different model, but most of the pins are the same. Notable differences - Pin 38 is actually ~IRQ not RFDENABLE, and Pin 35 is +5V.
The connector J3 on the left of the schematic translates into the edge connector on the left of this image.
That connector is not used by the car computer, you can even see the shiny plastic layer they coated the board with all over those pins. That has to be carefully scraped off in order to make use of it; I'm confident I did a very good job with that and that my connections are solid there.
So I use a 40-pin edge connector and a few inches of ribbon cable to a 40-pin IDT connector to map the address/data lines as well as Chip Enable, Output Enable, and Read/Write to one port of my dual port SRAM. Pin 35 from the computer powers pin 48 of the SRAM, and similarly, Pin 39 from the computer grounds pin 24 of the SRAM.
The 40 pin connector on the right is where my ribbon cable from the computer edge connector goes. That electrolytic capacitor in the picture has been replaced with a 0.1uF ceramic disc.
The Arduino has different power requirements (7-12V) than the car computer and SRAM, so I built a separate power supply for it from this circuit:
Only difference being I used a 7809 power rectifier in order to get 9V rather than 5V. That circuit is supplied from the car's fuse box and is currently grounded to the car chassis on the opposite side of the car from the computer. Should I have grounded that power supply circuit at the car computer instead? And the 12+V power supply input, should that come from somewhere else? I'm squeamish about integrating power supply stuff with higher voltage into the car computer because my understanding of what will happen is weak, and it's a crap-tonne of work to retrofit that computer to take over the code and move it from ROM to EPROM - if I pop it my heart will be forever broken!
The rest of the Arduino wiring to the SRAM board is pretty straight forward, no power or ground, just digital pins for Address/Data plus Chip Enable, Output Enable, and Read/Write, all on the second port.
Any thoughts on what could/should be changed where I might have a "loop" or other problems?
I hope I'm striking a reasonable balance between detail and succinctness here. Thanks so much for reading, considering, and advising!
monte_carlo_ecm: Should I have grounded that power supply circuit at the car computer instead?
That's what I said.
monte_carlo_ecm: And the 12+V power supply input, should that come from somewhere else?
It should come from the same place as the car computer, and the cables should run together. Obviously you can (should) use a common supply cable to both, splitting it to the corresponding two regulators at the car computer (that is, it supplies the car computer regulator and goes on to the recording computer along with all the other cables). Similarly for the ground, and as long as no other ground connection is made anywhere.
Paul__B: That's what I said.
Thanks for clarifying your suggestion Paul__B. I wasn't sure exactly what you meant by "recorder". In my mind prior to us discussing this, the "recorder" is just the SRAM because the Arduino is connected to a separate port of that dual channel SRAM. You are including the Arduino in the scope of the recorder, I get that now.
Paul__B: It should come from the same place as the car computer, and the cables should run together. Obviously you can (should) use a common supply cable to both, splitting it to the corresponding two regulators at the car computer (that is, it supplies the car computer regulator and goes on to the recording computer along with all the other cables). Similarly for the ground, and as long as no other ground connection is made anywhere.
I'm going to try your recommendations some time in the near future because clearly what I don't know can hurt me. It's a more involved retrofit to redirect the power/ground for that Arduino power supply than, say, replacing a ribbon cable, so it could take me some time. One of the more difficult pieces will be figuring out how to splice into the power/ground at the car computer in a clean and non-destructive fashion.
If you don't mind - can I ask you one more thing so I don't waste your time later? Let me come back to this picture for a second:
That's the car computer again. The 12V ignition power and ground connections come in on one of the two edge connectors on the right (I'll have to refer to the schematic again to find out which pins exactly, I figure it's not important for this question.) The 5V rectifier is under the heat sink at the bottom of the image. If I can figure out a nice way to splice into the ends of the wires that come into the edge connector, is that satisfactory in your mind? Or do I have to splice off the input and ground right at the power rectifier?
Thank you very much for reading/considering my design and providing some tips. I really do appreciate it.
monte_carlo_ecm: If I can figure out a nice way to splice into the ends of the wires that come into the edge connector, is that satisfactory in your mind? Or do I have to splice off the input and ground right at the power rectifier?
When I refer to loops, I mean substantial ones - where the various connections are separated by more than the width of the circuit board. It would be appropriate to splice into the connection to the edge connector.
When you initially referred to a "car computer" using a 6801, I was thinking of an after-market project - this begins to look like standard equipment ("Delco" - the chips have OEM markings, not Motorola - and if anything based on the 680*2* as the 6801 was never a going proposition) built into the loom.
The point is - this computer and your attachment each have their own regulator, you wish to derive common power from the supply that feeds this, not the board itself, and that includes the ground - from the loom.
Thanks Paul__B. I'll try to wire something up soon that's robust enough for a test drive. I fiddled around with a spare edge connector that I pulled from the junkyard a while back and I think I should be able to run a test without too much hacking.
Yes, it's substantially an OEM computer, from a 1987 GM with a computer controlled carburetor. One guy on the car forums that knows entirely too much about this era of GM computers told me it was "based on the 6801 but specifically made for GM/Delco". So far I haven't noticed any difference from a command set point of view, maybe the pinouts are slightly different or something.
There's one significant difference in my computer in that I replaced the 1K EPROM with a 64K EPROM, and built a daughterboard to replace a 74LS138 demultiplexer in order to redirect the ROM range to the EPROM thereby allowing me to add/change the code, and direct an unused address range to that dual port SRAM. It looks like this:
I took that picture a while back - I have since added 0.1uF ceramic disc capacitors between +5V and ground on my EPROM and my demultiplexer and gate chips based on the advise I've been getting here. Also if you look close you'll see that two of the gates on the lower 74LS00 are not wired up in that picture - that has since been resolved.
One day I want to use OSHPark to make some nicer boards. I'm still pretty confident that this piece is working fine though because each time the Arduino gets a checksum error, re-reading gets the right answer. So the car computer appears to be reliably dumping its RAM to SRAM.
I got to wondering last night, seeing as the car computer and SRAM are powered from the same source without a (substantial) ground loop, when I power the Arduino from my laptop via USB and the laptop battery ultimately (and pulling the plug from the extra 9V power source I built), does that still form a ground loop? When I tried that, I got pretty much the same error rate.
Anyway, many thanks once again!
Okay, so I soldered a new cable to the ends of the 12V and ground pins on the edge connector that connects to the car computer. That now powers my voltage rectifier circuit which in turn powers the Arduino.
Test drive gave me the same data error rate as before. I did have my laptop plugged into the Arduino's USB in order to view the Serial monitor to see the nature of the errors. Could a laptop running off its own USB power (not charging from the car lighter or anything) be introducing noise to the circuit? At some point I will of course try it without the laptop plugged into the USB (I have a little 16x2 LCD that shows various measurements from the car memory, as well as the error count) but I'm not hopeful there will be a difference.
The only other idea I have is to get a cheap Mega knock-off and swap it in just to see if maybe my Arduino is flaking for some reason. Since my Saleae Logic analyzer doesn't see any glitches in the periods of time the Arduino gets a bad reading, I wonder if it could be true that the Arduino is somewhat fried? Seems a bit of a stretch in that it generally functions well, but I don't know what else to try! :'(
Any other ideas are of course greatly appreciated! Thanks for putting up with me sorting out my design and build basics!
I was just reading through the forum trying to learn a little more and came across this post from MarkT in the thread “Wiring S-R Flp-flop to arduino”
TTL is not directly compatible with the ATmega inputs - they require 3.0V or more for logic high,
74LS only guarantees 2.7V unless you use a pull-up resistor on the output - I doubt the built-in
pull-ups are strong enough though, I’d suggest 10k external for LS, 1k external for plain TTL.
In my case I’m getting occasional “glitches” from my SRAM chip in the form of both incorrect high and incorrect low, but maybe there is still something to this?
The AM2130 Datasheet isn’t clear about whether the chip is strictly TTL or not. It says “All inputs and outputs are TTL-compatible”.
In the charts about half way through the datasheet it says
Vol1 Output LOW voltage (I/O0 - I/O7) Max 0.4 V
Voh Output HIGH voltage Min 2.4 V (lower than the 3.0 mentioned by MarkT).
I have tried setting the data input pin modes to INPUT and INPUT_PULLUP, I don’t really notice any difference, glitches appear at about the same rate.
Am I barking up the wrong tree here or could there be something to this?
Assuming there could be something here - I only need to read (not write) the SRAM at the Arduino side. Can anyone advise what the simplest way to resolve this might be, assuming I need this style of SRAM chip for the other side of the communication? Should I use something like a CD4505B-EP CMOS HEX VOLTAGE LEVEL SHIFTER FOR TTL-TO-CMOS?
monte_carlo_ecm: The AM2130 Datasheet isn't clear about whether the chip is strictly TTL or not. It says "All inputs and outputs are TTL-compatible".
That is correct. It is TTL compatible, but not CMOS compatible. Its outputs may require 4k7 pull-ups to be CMOS compatible. (The Arduino is CMOS.)
Thank you Paul__B, I appreciate you confirming that. Running these tests is a lengthy process to retrofit and setup so it really helps to know that the effort is worthwhile.
I figure I'll put a 4.7K ohm pull up on just one data line using a couple of test leads and see what happens. I get errors pretty consistently (while still randomly, if that makes sense!) across all the 8 data lines, but my hope is that if this is the issue, the one line with the resistor on the test leads should never contain an error during the test run.
Okay, so I tried the 4.7K ohm pull up resistors on two data lines. Same error rate on those two lines as always. Since I had the test leads already hooked up I also tried 1K ohm and 10K ohm resistors, no difference in results.
I'm back to thinking the issue is entirely related to the very noisy environment with a heavy old 8 cylinder engine running and a high voltage ignition box to boot. I keep wanting to blame the Arduino (ie that I fried it some how, not by its nature) or my design somehow, but then I pinch myself and remember it only happens with the engine running!
I'm going to try a twisted ribbon cable if I can get one at the local surplus place in 26-wire. Shielded too if they have that in 26-wire. I also read that ferrite cores at each end of ribbon cables can improve the situation in noisy environments like cars.
Of course, any other ideas are more than welcome!
I’m hoping someone can help me validate what I think I am seeing in terms of power usage and availability in my project. I’ve tried to do as much homework as possible, but I’m essentially a Noob, so I’m at the point where I think I have something but really need an experienced eye to pass it by for a reality check!
Quick background why I got on to this: While I was picking up shielded cable and ferrites, I decided to grab a 74HCT245 Octal bus tranceiver based on some things I was reading about people wiring up IDE drives in their car over long lengths of ribbon cable and the signal not being strong enough. I’m not using an IDE drive, but it’s the same style cable, and thought it was worth a shot to see if I could change things with a “buffer” of sorts. Easy enough to wire up on a breadboard, I was done pretty quick.
Well, to my surprise it made things worse. I started getting occasional errors at Ignition on but Engine off even. The car computer even rebooted itself at one point. I went for a quick test drive but returned quickly as my Arduino started reporting huge streams of errors and the usual “just reread it and its okay” wasn’t working.
Alright, so I got to thinking about power. I’m powering my SRAM chip (and hopefully temporary 74HCT245) from the car computer’s edge connector. I think I mentioned in a previous post that I want to do it this way because I want everything on that computer’s bus to be powered by the same source; I don’t want the computer crashing because something on the bus loses some alternate power source. So I begin to wonder if the computer’s power circuitry can supply enough power for the computer itself and the extra chips. Here’s where the questions start. Taking a look at the schematic for the power section of the car computer:
It’s not a simple little 7805 mechanism. From what I can tell based on write-ups I’ve seen online with respect to power rectifiers using transistors, it would appear that R2 in that schematic is a current limiting resistor. Is that true?
I’ll assume it is for now and continue with the follow-ups.
VCC is 5V, I know that of course. And if R2 is a current limiting resistor, if I understand ohms law correctly, we go I=V/R, I=5/5.1, so I = ~980mA. Is that correct, and does that mean that VCC is limited to 980mA across the entire circuit?
Again, I’ll assume that is correct and pose the next follow-up for now:
The proprietary CPU in the car computer is some derivative of the Motorola 680x. Apparently 6801. Something close to that anyway, the instruction set is the same for sure. Taking a look at the datasheet I see:
Internal Power Dissipation Pint Max = 1200 mW.
So I think that in order to determine the current requirement I go:
P = VI, therefore I = P/V, I = 1.2 / 5, so I=240mA. Did I get that right? The CPU alone can take about 25% of the maximum available current in the worst case scenario?
Might as well continue, hopefully I’m not way off so far…
Taking a look then at the AM2130 Datasheet for the SRAM I’ve added into this power supply, I see:
Absolute Maximum Ratings…Power Dissipation… 1.2W.
Same formula then as the CPU.
The 74HCT245 is rated at 750mW max. Perhaps I’m pushing an already marginal current limit way over the top adding it to the circuit? I think that’s just a rhetorical question and inferred by answers to the other questions so I’m not bolding it.
If everything above is correct or at least close, then half my available current is gone, and there is still onboard RAM, ROMs, ADC converters, various gates, etc. to power. If that is correct Are my symptoms at all consistent with trying to draw more than the maximum available current?
Final follow-up question for now then, and of course the big one because this is where it potentially gets dangerous what sort of good or bad things will happen if I jump that 5.1ohm current limiting resistor with a, say, 3ohm resistor in order to boost the maximum current by about 25%?
Gosh, I hope I’m at least somewhat on target here, and that some kind soul is willing to help me clear away the fog in my mind! Thanks ever so much for reading and considering!
It looks like I may have been overcomplicating things worrying about current limits or the possible need for a line driver/buffer. I still have a question below but it's much simpler. If anyone is still following my saga here, I'd appreciate tips on how to complete my setup!
Real quick, I made a new data cable out of shielded 26-conductor ribbon cable to run between my SRAM and Arduino. A picture is probably best - top is before, bottom is after.
It took me some time to make this cable because it seems as if the cable itself inside of the outer shielding is stronger; my crimper kept destroying the connectors as I tried to put them on the cable and I had to run back to the electronics store to get a handful more of them! This did not happen with the cable I was first using - the connectors crimped on like butter. With this new cable, the connector has to be very well centered in the crimper and I have to squeeze really slowly and progressively more firmly or the connector pins either crush all over the place or don't cut through.
Anyway, I put the cable in the car and went for a 15 minute test drive. In that amount of time with the previous cable, I would have had 5-10 errored packets easily. With the new cable, zero, none, perfect run.
So it looks like engine noise in cars is even more evil than I imagined. My two remaining questions then:
There is a wire mashed in between the foil shielding and the outer heavy plastic housing on the ribbon cable. I have grounded that close to my common ground on the car computer. Should it be grounded only at that end, or at the Arduino as well?
I bought a ferrite clip for the ribbon cable, I figure I might as well use it since it's mine now. Is there a "correct" location for that to go? ie. at the transmitting end (SRAM), receiving end (Arduino) or somewhere in the middle? The cable is just about 2 feet long.
Thanks to everyone for reading and throwing in ideas, I really appreciate it. I think perhaps my struggles with this may soon be over! I think it's a really cool project. If anyone wants to see some of a fun video of what it does, here's a link to a sample video I made for the car enthusiasts (with the old cable so 40 checksum errors by the time I call for it):
The first 45 seconds or so are pretty boring because I'm waiting for the engine to heat up ("closed loop" in car terms). After the 5 minute mark there isn't much more to see.