That is at least encouraging ... when I began this thread I thought the 4 months I had into this project of learning PASM and writing the objects I did had produced unusable code. It is good to hear from everyone that I have hardware options I can take advantage of. I started soldering the board that TChap recommended, which I must say is much harder than using a breadboard or that I anticipated it would be, but I had to stop before I could finish as it was time to go on vacation for a week. When I get back, I'm excited to hopefully find that with the recommendations in this thread, I'll be able to have my code work in the car, just like it does when I have another propeller simulating the car on the bench.
So you think I should have a decoupling cap on the main power supply line? What about pull downs on the pins I have counters set up on that are measuring the ac --> converted to dc signal?
Exactly where did you connected the power supply leads to feed your prototype when it is being tested it in the car? Have you ever tried to get +12V power directly from the battery terminals using jaws?
Have you added a huge (at least 2 amps foward current capacity) diode in series with the positive power lead and at least two (1000 uF + 1uF) low ESR capacitors ( at least 50V rated, I do recommend 63V) setup filtering just after the diode catode? With the negative leads of the capacitors connected to the point where ground enters the circuit.
Use one "where goes the cow, ox follows" rule to route power coming from battery till it reaches the on board regulators and continue to follow it through your entire logic.
If there are any high current actuator being driven by your circuit, get its power from the point where the leads coming from battery enter your setup and you surely will enjoy repeating the (diode+caps) setup in this path too, paying attention to the current consumption of the (driving + actuator) circuit to get the diode and bigger capacitor rated, obviously provided that switching will be referenced to ground.
Search, point and annihilate any ground loops (write the power path in a sketch and check for the existence of end around connections).
As an example, if you connect the ground lead to a metal shield in a point and extract ground to feed any circuit, logic or not, in another then you can get a ground loop, an antenna or both.. Surprised? But its true.
In case of doubt you can think ground electron flow as water distribution in pipes. Write down a sketch or simply connect cheap aquarism grade air tubing, with suitable Ts and Xs, and fill that setup with color blended water or alcohol. If it mimics your power setup, you will see "liquid electrons" flowing exactly as they will flow in your circuit.
Every previous suggestion to ground and shield everything strongly holds. Forever and ever.
Think your logic as a island of organization in a chaos. Design, route and shield it accordingly.
In the mean time, do two things, please:
1- Keep sharing your ideas, sketches and pics.
2- Pray God and pass the ammunition.
Your efforts will be gracefully rewarded and we will learn together!
And if you connect directly to the car battery do put a fuse in the line else one little short will instantly vapourize your wiring and possibly start a fire.
Great first post, thank you! I am getting ground and 12v from the ecu ground and 12v, as I was hoping it would be at least partially clean before it even reached the ecu.
I do not have the diode/capacitors that you speak of yet. There is a lot of great information in this thread and I will try to incorporate all of it, the only problem is that it seems like I cannot use a breadboard for prototyping it which makes it much harder.
If you all keep offering advice, I'll keep posting circuits . Can you explain in more detail or possibly draw a crude/quick drawing of the two different states described here?
As an example, if you connect the ground lead to a metal shield in a point and extract ground to feed any circuit, logic or not, in another then you can get a ground loop, an antenna or both.. Surprised? But its true.
I would like to make sure I understand you correctly in what you are saying there. I think you mean if I piggy back or tee into the ground going to the shield, for a solenoid ... but I'm not sure.
@Heater ... I definitely fuse all direct battery connections, I learned that when I was still in high school
Exactly where did you connected the power supply leads to feed your prototype when it is being tested it in the car? Have you ever tried to get +12V power directly from the battery terminals using jaws?
Have you added a huge (at least 2 amps foward current capacity) diode in series with the positive power lead and at least two (1000 uF + 1uF) low ESR capacitors ( at least 50V rated, I do recommend 63V) setup filtering just after the diode catode? With the negative leads of the capacitors connected to the point where ground enters the circuit.
Use one "where goes the cow, ox follows" rule to route power coming from battery till it reaches the on board regulators and continue to follow it through your entire logic.
If there are any high current actuator being driven by your circuit, get its power from the point where the leads coming from battery enter your setup and you surely will enjoy repeating the (diode+caps) setup in this path too, paying attention to the current consumption of the (driving + actuator) circuit to get the diode and bigger capacitor rated, obviously provided that switching will be referenced to ground.
Search, point and annihilate any ground loops (write the power path in a sketch and check for the existence of end around connections).
As an example, if you connect the ground lead to a metal shield in a point and extract ground to feed any circuit, logic or not, in another then you can get a ground loop, an antenna or both.. Surprised? But its true.
In case of doubt you can think ground electron flow as water distribution in pipes. Write down a sketch or simply connect cheap aquarism grade air tubing, with suitable Ts and Xs, and fill that setup with color blended water or alcohol. If it mimics your power setup, you will see "liquid electrons" flowing exactly as they will flow in your circuit.
Every previous suggestion to ground and shield everything strongly holds. Forever and ever.
Think your logic as a island of organization in a chaos. Design, route and shield it accordingly.
In the mean time, do two things, please:
1- Keep sharing your ideas, sketches and pics.
2- Pray God and pass the ammunition.
Your efforts will be gracefully rewarded and we will learn together!
Ok, I've tried to incorporate what everyone has advised, how does this look as a starting point?
@Pedward, I found your site while searching ... you are quite the jack of all trades and where I'd like to be!
Put the circuit in a metal enclosure, add a noise filter to the power input, use an optoisolator for the input signal.
Series resistance is always good, we often use a PTC 'fuse' and a decent Zener, as both series resistance, and protection.
For frequency inputs, a schmitt buffer with a RC IP filter is always good to remove 'out of range' signals.
If you want to add isolation, a Logic opto coupler like the H11L1 is widely sourced, and includes the Schmitt action.
Two obvious problems. One is that a breadboard is a big antenna, much more 'wire' beneath the surface. Next, the absence of bypass caps. I would have .1uf all over a breadboard, even a pcb. Each ic needs one on it's power, each input needs one to gnd unless it is some highspeed signal then a smaller value. Every slow signal put a .1 to gnd. All power to prop add more caps.
You should convert at least to a perf board, all soldered connections.
Also consider feedthrough caps. Also careful attention to grounding of the enclosures.
I would have .1uf all over a breadboard, even a pcb. Each ic needs one on it's power, each input needs one to gnd unless it is some highspeed signal then a smaller value. Every slow signal put a .1 to gnd. All power to prop add more caps.
Polarized is just a negative side effect requirement with some type of caps and nothing one should "look" for.
Ceramic caps don't have this side effect and with 0.1uF you should definitely go with Ceramic (and up to and including 10uF)
And you should also make power and gnd connection wires just thin enough to handle the board requirements, as bigger is not better in this case.
Place .1uf ceramic(non pol) on all power grids, not a bad idea to add 1 to 4.7uf polarized on the power grids. You have a lot of unsheilded wire including breadboard wire runs. A metal enclosure with gnd to the enclosure would help
I have found the LM1815 chip to be quite effective at converting AC auto signals into nice square waves, even in dirty environments.
I would replace the input 100k with a 1k, then at the input to Q1 pull that low with 100k.
Well I'd always put such noisy input signals through a schmitt trigger anyhow, 74HC14 is popular for this - CMOS schmitt triggers have about Vdd/2 hysterysis IIRC which ought to nail all but the most extreme interference. 100pF to ground of course at the input to suppress RF.
Given the incoming signal may be attenuated by the 100k and the possiblity of differing ground potentials I'd consider ac-coupling the input (that way if the square wave ends up being more like 2..10V peak to peak it won't read as constantly high. Alternatively use a resistor divider to bring the 12V range down to 3V.
I have used the small inductors (don't recall exact values) that resemble 1/2 watt resistors to add filtering to circuits in noisy environments. In a 12V system they have the added benefit of reducing the power dissipation of the regulator since they also have some resistance. If you use an optoisolator for the signal you could use a PI filter for the power and ground to reduce noise on both.
Where is the AC signal coming from? I assume you are using the crank position sensor for this? If this is the "standard" CPS, then it is a Variable Reluctance Sensor and you can't use your simple circuit to interface properly. If you use level triggering on a VRS you will get variable timing at different speeds because the signal intensity varies with speed. As suggested before, using an LM1815 is a good solution for this interface, since it's designed for interfacing to a VRS.
VRS type sensors are very noise resistant, but only if you follow the proper interfacing procedures. You must use a shielded cable, with the shield connected at the PCB ground side, preferably as close to the power supply ground as you can, to create a low impedance path.
If you follow proper decoupling, grounding, and interfacing guidelines, and use the LM1815 (with the reference circuit they provide), you should be able to see the signal with very little noise.
You still need to implement filtering and recovery in your code to prevent signal hiccups from torching your process.
If you have this already, you can craft your own filter/schmitt.from here, with small changes.
* Add a capacitor across D1, start with around 1nF - exact value depends on signal overdrive amplitude.
* Join the Q1.Q2 emitters, and insert a resistor to ground, R4.
* Skew the values or R1 and R3, with R3 smaller.
A lower R3 gives a higher emitter voltage when Q2 is on, and as Q2 turns off, the falling emitter voltage is positive feedback to Q1, so you get a schmitt action.
If R3 is 4.7k, and R1 is 10k, then R4 = 220 ohms, will give about 140mV of hysteresis, from a quick calc.
Easy to run this up on spice.
Exactly where did you connected the power supply leads to feed your prototype when it is being tested it in the car? Have you ever tried to get +12V power directly from the battery terminals using jaws?
Have you added a huge (at least 2 amps foward current capacity) diode in series with the positive power lead and at least two (1000 uF + 1uF) low ESR capacitors ( at least 50V rated, I do recommend 63V) setup filtering just after the diode catode? With the negative leads of the capacitors connected to the point where ground enters the circuit.
Use one "where goes the cow, ox follows" rule to route power coming from battery till it reaches the on board regulators and continue to follow it through your entire logic.
If there are any high current actuator being driven by your circuit, get its power from the point where the leads coming from battery enter your setup and you surely will enjoy repeating the (diode+caps) setup in this path too, paying attention to the current consumption of the (driving + actuator) circuit to get the diode and bigger capacitor rated, obviously provided that switching will be referenced to ground.
Search, point and annihilate any ground loops (write the power path in a sketch and check for the existence of end around connections).
As an example, if you connect the ground lead to a metal shield in a point and extract ground to feed any circuit, logic or not, in another then you can get a ground loop, an antenna or both.. Surprised? But its true.
In case of doubt you can think ground electron flow as water distribution in pipes. Write down a sketch or simply connect cheap aquarism grade air tubing, with suitable Ts and Xs, and fill that setup with color blended water or alcohol. If it mimics your power setup, you will see "liquid electrons" flowing exactly as they will flow in your circuit.
Every previous suggestion to ground and shield everything strongly holds. Forever and ever.
Think your logic as a island of organization in a chaos. Design, route and shield it accordingly.
In the mean time, do two things, please:
1- Keep sharing your ideas, sketches and pics.
2- Pray God and pass the ammunition.
Your efforts will be gracefully rewarded and we will learn together!
This used to be a big problem (still is actually) with running low signal strength "high impedence audio" through cables for any distance. The input pin on the prop has a very high input impedence and the length of wires make a good antenna. The trick will be to lower the impedence for the wire run and then step it back up at the prop.
As others have mentioned there are ready made line driver chips that do this for you. That combined with twisted pair wires, shielding, etc will help keep the noise out. If the noise is of a much higher frequency than what you want to measure a cap from the input pin to signal ground can help.
Turbo,
Have you looked at the crank signal on a scope? I just built a injection system on my airplane. It's a rotax 914 turbo. It has a VRS sensor for the crank also. The signal isnt AC as you would think of a sine wave AC. It is a positive pulse as the sensor sees the metal aproach then back to 0 then a negitive pulse as the metal leaves the sensor. My problem was that when cranking the pulses were only about 2 to 3 volts and when running at rpms around 4 to 5K the pulses were up to 20 volts. That would be fine but if you trigger at the 2 volt range and the run at 4K rpm the noise spikes were over 12 volts and caused false triggers. You need a very good circuit to read reliably at all speeds. I gave up on mine and installed a seperate hall effect sensor to get a constant square wave. I dont read the cam do to the engine has no sensor on the cam and too much trouble to try to install one without modifing the block. The ignition on these engines uses the wasted spark desingn and fires the spark on both compression and exhaust strokes.
Since I gave up on the VRS I don't have any solution for you because I gave up on that type of sensor.
You will find noise on the sensor input is a real problem. Let me know if you find the way to get a good reliable signal off the VRS sensor. I know it can be done since they are used on a lot of engines.
Just for information I have the system up and running and at the point now of tuning in the fuel table to run at all throttle settings better. I used the carbs as throttle bodies and can run on the injection or the carbs switching over while flying.
The signal isnt AC as you would think of a sine wave AC. It is a positive pulse as the sensor sees the metal aproach then back to 0 then a negitive pulse as the metal leaves the sensor. My problem was that when cranking the pulses were only about 2 to 3 volts and when running at rpms around 4 to 5K the pulses were up to 20 volts. That would be fine but if you trigger at the 2 volt range and the run at 4K rpm the noise spikes were over 12 volts and caused false triggers. You need a very good circuit to read reliably at all speeds.
When given a 'nasty, but simple' sensor like this, one approach is to use a Set/reset latch that triggers on the Positive then negative pulses.
'Bonus' trailing ringing, and wide dynamic ranges, then do not affect the rate.
If the impedance is low enough, two opto couplers could be a solution, with either an external SR latch, or a SW SR latch.
That sounds awesome! I want to use a factory sensor, so when I do get it going I will let you know. Mine runs at low voltage when cranking and up to 15v (I think when at higher rpms) . Are you controlling injection with the prop as well?
Here are my scopes, I'm going to use thumbnails so that I don't litter the thread with a ton of pictures
Turbo,
Have you looked at the crank signal on a scope? I just built a injection system on my airplane. It's a rotax 914 turbo. It has a VRS sensor for the crank also. The signal isnt AC as you would think of a sine wave AC. It is a positive pulse as the sensor sees the metal aproach then back to 0 then a negitive pulse as the metal leaves the sensor. My problem was that when cranking the pulses were only about 2 to 3 volts and when running at rpms around 4 to 5K the pulses were up to 20 volts. That would be fine but if you trigger at the 2 volt range and the run at 4K rpm the noise spikes were over 12 volts and caused false triggers. You need a very good circuit to read reliably at all speeds. I gave up on mine and installed a seperate hall effect sensor to get a constant square wave. I dont read the cam do to the engine has no sensor on the cam and too much trouble to try to install one without modifing the block. The ignition on these engines uses the wasted spark desingn and fires the spark on both compression and exhaust strokes.
Since I gave up on the VRS I don't have any solution for you because I gave up on that type of sensor.
You will find noise on the sensor input is a real problem. Let me know if you find the way to get a good reliable signal off the VRS sensor. I know it can be done since they are used on a lot of engines.
Just for information I have the system up and running and at the point now of tuning in the fuel table to run at all throttle settings better. I used the carbs as throttle bodies and can run on the injection or the carbs switching over while flying.
Those signals are a heck of a lot cleaner than mine were. Probably a better sensor than the ones on mine. You know the cheap parts they put on $30,000 engines!!
Yeh, I'm using a prop. Right now using seven cogs. Although mine is a lot simpler than a car. I don't have to wory about accel or decel and changing speeds a lot. In the plane the throttle is opened slowly to 100% and backed off to 75% then adjusted for cruise and left there for long times. After leveled off and stable, manually lean mixture till to lean and then increase a little for best fuel ecomomy. No sensors except crank, throttle pos and manual mixture control pot.
If you want an adrenalin rush try testing yours taking off a runway climing at 400 ft over the end of runway hoping the injection doesnt quit. Not enought time to switch over to carbs there.
Yeah, that's why I don't know if I'd say it's a lot simpler! .
I'll stick to my 4 wheels and pavement!
Mine is a 36-2, is that what you were using? Not realizing it when I started this project, I needed to learn PASM to have the speed I needed to read the 36 teeth and do all of the calculations I needed. I also want to control the variable cam, which is based on a pwm signal that controls hydraulic pressure, which is based on crank angle and target cam phase angle. I am inefficiently using all 8 cogs at the moment. I have a better example on how to use the counters to save at least 1 cog, but I cannot implement it until I get the rest of this working reliably and properly, as a baseline.
Ok, I have added that, does everything else look like it is there? I ask because I'm about to do a parts order from Mouser.
Oops, not quite. The 2.7k needs to replace the 100K on the DIODE side, as that is what needs the 1.6mA ( or lower than 2.7k, if your source is < 5V, and has an internal impedance) and the 5V power to the H11L1 needs to be direct to 5V.
RL on the H11L1 output does not need to be as low as the often quoted test values, ( you are not pushing MHz speeds) so 2.7k is fine there too.
Here are my scopes, I'm going to use thumbnails so that I don't litter the thread with a ton of pictures
So that looks like a missing tooth scheme, to indicate where you are in phase ?
If determining that missing tooth phase position matters, then I'd go for a symmetric Dual Opto scheme (just reverse connect the two IP Diodes) - probably easiest to just use two pins on the Prop, and then you can easily halve the widest time, to get an exact reference time.
By using a dual Opto, any threshold variations with speed, and opto levels, are then spread evenly either side of the true reference point.
Probably will be able to remove the LM1815, and the H11L1's can power from 5V, but have the pull-up wired to 3.3V for direct Prop drive.
The reason I chose 100k is because I do not want to affect the factory ecu's ability to use the crank signal. In the past I've had issues with this. At this point I just want voltage values with as little current siphoned off as I can get away with, unless that idea is destined not to work. Can I get away with that? Maybe things are different with the opto isolator? The crank sensor voltage ranges from ~1v to upwards of +/-15v by the way.
So that looks like a missing tooth scheme, to indicate where you are in phase ?
If determining that missing tooth phase position matters, then I'd go for a symmetric Dual Opto scheme (just reverse connect the two IP Diodes) - probably easiest to just use two pins on the Prop, and then you can easily halve the widest time, to get an exact reference time.
By using a dual Opto, any threshold variations with speed, and opto levels, are then spread evenly either side of the true reference point.
Probably will be able to remove the LM1815, and the H11L1's can power from 5V, but have the pull-up wired to 3.3V for direct Prop drive.
My code can determine the missing tooth if I can get a clean signal out of it. When I feed the simulated signal from another prop, it works great.
I don't remember talking about a dual H11L1 setup, so I'm a bit behind on that part.
Can we used the circuit as is, since my code does all of the tooth timing and gap detection already, and works properly on a clean signal?
How accurate do you need to nail down that phase point ?
As you can see on the scope it is pretty much half way between the Positive and negative pulses, but you could use more complex software, to derive a modeled threshold (from the duty cycle you observe), and then use that to 'fit' a calculated phase point.
I will try the opto with a smaller value resistor as you've suggested. I guess 2.7k is the largest value I can start with?
If I remember correctly, it's 53% low to 47% high. My code works very well on the clean signal. As long as I can reproduce the signal in digital form, as I am doing with the first posted schematic I am good. If not, I will have to scope the new signal, compare it and then adjust the givens that are in my code. Still not impossible, just a little more work is all.
I will try the opto with a smaller value resistor as you've suggested. I guess 2.7k is the largest value I can start with?
It may be better to add a transistor.
If you feed the Opto Diode from 12V with 2.7k, and then use a PNP transistor 68K to base, to sensor, Emitter to Diode+, Collector to Diode- and BAT-, then you will be using the PNP to short the Diode, and turn off the Opto when the base is below ~ 0.6V, a 'good' PNP with gain over 250, (say typical 350) will combine with the currents, and that base resistor to move the opto threshold to close to 0v (but with hysteresis)
Not sure if this is of any applicable interest or not, but sometime ago I used some little known Wiegand Inductor Coils. Their claim to fame is that a slow change in magnetic field strength is not detected until the level gets to some minimum trigger point and then it flips completely, giving out a pulse from the coil. The coil output level is (nearly) constant regardless of the rate of change in the magnetic field.
These things make a great rotary sensor because the output level is not RPM dependent.
A few thoughts. Nix the opto that you have in the circuit. The LM1815 should be connected directly to the VRS.
I reviewed your schematic and the LM1815 circuit doesn't match the Nat-Semi datasheet I'm looking at. First, nix the 330pf and .01uf caps on the CAS input. Connect the CAS positive (check with side is grounded with a VMM) to the 18k resistor. Next, your output needs tweaking. The LM1815 typical operating voltage is 10v, so 5v may result in operation that doesn't work well with the example components. I would recommend a low dropout regulator to 9v from 12v, then drop the 9v to 3.3v for the prop, bypassing 5v. If you use a proper ground pad/heatsink, you can drop the 9v-3.3v in one step.
You have a 4.7k 5v pullup, but the LM1815 wants a pulldown. Also, you need to level shift the output of the LM1815 or use a dropping resistor to make certain the input voltage to the Prop isn't too high. Using a 1k pulldown, per the datasheet, and a 10k current limiting resistor to the prop input pin, should make it safe and shunt the voltage through the protection diodes, keeping the current through the diodes much lower than required.
The LM1815 fires the output on the negative going zero crossing transition. It uses the positive going pulse to adjust the amplifier. You can also omit the RC components on pin 14, since if you ground 9,11,14, the output is the zero crossing of the sensor, which is what you want.
Something that should be explained, since the poster with the Rotax touched on it, how to interface a VRS sensor.
VRS sensors are good because they provide a differential signal, which helps with noise, since noise induced on one wire appears on the other, which is typically canceled out. The odd/difficult thing that people don't understand is that the voltage varies with speed. This means you can use a level trigger circuit to interface to a VRS, you need to detect the zero crossing point. The only point in the waveform that is accurate is the zero crossing. The LM1815 datasheet has a very good diagram showing how a noisy signal is filtered. You may have a lot of noise riding on the signal, but the large negative going transition is what triggers the output, thus giving you an accurate timing edge while also handling all the induced noise from the environment.
At the time I designed my datalogger Bruce Bowling and Al Grippo seemed fairly certain that NS was discontinuing the LM1815, and this is the reason they didn't include it in the MegaSquirt. Armed with this advice I sought alternative solutions, first designing a level triggered input, then discovering my misunderstanding. I found a single ended zero crossing detector application circuit in the LM139 datasheet. I experimented with the circuit and finally arrived at a very robust and noise resistant interface circuit. The example lacked any noise immunity and would false trigger from ambient noise, so I had to add some filtering to get it to work properly. When done I could read VR sensors even at the slowest possible speed, just turning with my fingers.
One last thing, make certain you have decoupling capacitors on every chip and that they are physically located close to the power pins of the chip. The MegaSquirt power supply circuit is a very good design and has been enhanced from actual field use, so don't be affraid to borrow that design for your board.
It looks like you are using PropScope. I know I'll get trashed for talking about PropScope but here goes. I havent used it and it probably works very good for what it's intended for and the price.
These serial interface scopes tend to clean and correct the waveforms. I use a AstroMed 8Xe digital recorder at work. These are $10K units. We found even these have software and hardware filtering that does not show all the noise. We had problems with a control system and could not find any reason with the astro med. We finialy hooked up a 2Mhz Fluke scope and you would not belive the difference in the noise on the scope. I use a 1Mhz Tectronix at home when working on the propeller. That may be why your signals look so clean.
The prop is running fairly fast and without the right hardware on the input and if the software is picking up the noise spikes your program may work fine on sim but not to good in the noisy car enviro.
If you can find someone with a 1 or 2Mz scope and try to compare the signals might be helpfull. Again not trying to down the prop scope just trying to help a little.
@PEdward
I saw the example in the datasheet, does the lm1815 invert signal? I really need something that mimics the positive portion of the analog version of the signal with a digital signal, else my code is useless. I can't find my scope screen capture at the moment, but it digitally follows the analog positive portion of the VRS signal.
@CRST1
That answers a question I was wondering why I didn't see any noise on the line with the scope, even when I moved the time divisions really high. This also makes me more confident that hardware will fix it. I may try to find a used inexpensive and unfiltered scope on ebay.
Ok, how does this look as far as what everyone was describing? Can anyone recommend any good shielded wire? Mouser only had wire that was $20 a foot???
A few thoughts. Nix the opto that you have in the circuit. The LM1815 should be connected directly to the VRS.
I reviewed your schematic and the LM1815 circuit doesn't match the Nat-Semi datasheet I'm looking at. First, nix the 330pf and .01uf caps on the CAS input. Connect the CAS positive (check with side is grounded with a VMM) to the 18k resistor. Next, your output needs tweaking. The LM1815 typical operating voltage is 10v, so 5v may result in operation that doesn't work well with the example components. I would recommend a low dropout regulator to 9v from 12v, then drop the 9v to 3.3v for the prop, bypassing 5v. If you use a proper ground pad/heatsink, you can drop the 9v-3.3v in one step.
You have a 4.7k 5v pullup, but the LM1815 wants a pulldown. Also, you need to level shift the output of the LM1815 or use a dropping resistor to make certain the input voltage to the Prop isn't too high. Using a 1k pulldown, per the datasheet, and a 10k current limiting resistor to the prop input pin, should make it safe and shunt the voltage through the protection diodes, keeping the current through the diodes much lower than required.
The LM1815 fires the output on the negative going zero crossing transition. It uses the positive going pulse to adjust the amplifier. You can also omit the RC components on pin 14, since if you ground 9,11,14, the output is the zero crossing of the sensor, which is what you want.
Something that should be explained, since the poster with the Rotax touched on it, how to interface a VRS sensor.
VRS sensors are good because they provide a differential signal, which helps with noise, since noise induced on one wire appears on the other, which is typically canceled out. The odd/difficult thing that people don't understand is that the voltage varies with speed. This means you can use a level trigger circuit to interface to a VRS, you need to detect the zero crossing point. The only point in the waveform that is accurate is the zero crossing. The LM1815 datasheet has a very good diagram showing how a noisy signal is filtered. You may have a lot of noise riding on the signal, but the large negative going transition is what triggers the output, thus giving you an accurate timing edge while also handling all the induced noise from the environment.
At the time I designed my datalogger Bruce Bowling and Al Grippo seemed fairly certain that NS was discontinuing the LM1815, and this is the reason they didn't include it in the MegaSquirt. Armed with this advice I sought alternative solutions, first designing a level triggered input, then discovering my misunderstanding. I found a single ended zero crossing detector application circuit in the LM139 datasheet. I experimented with the circuit and finally arrived at a very robust and noise resistant interface circuit. The example lacked any noise immunity and would false trigger from ambient noise, so I had to add some filtering to get it to work properly. When done I could read VR sensors even at the slowest possible speed, just turning with my fingers.
One last thing, make certain you have decoupling capacitors on every chip and that they are physically located close to the power pins of the chip. The MegaSquirt power supply circuit is a very good design and has been enhanced from actual field use, so don't be affraid to borrow that design for your board.
It looks like you are using PropScope. I know I'll get trashed for talking about PropScope but here goes. I havent used it and it probably works very good for what it's intended for and the price.
These serial interface scopes tend to clean and correct the waveforms. I use a AstroMed 8Xe digital recorder at work. These are $10K units. We found even these have software and hardware filtering that does not show all the noise. We had problems with a control system and could not find any reason with the astro med. We finialy hooked up a 2Mhz Fluke scope and you would not belive the difference in the noise on the scope. I use a 1Mhz Tectronix at home when working on the propeller. That may be why your signals look so clean.
The prop is running fairly fast and without the right hardware on the input and if the software is picking up the noise spikes your program may work fine on sim but not to good in the noisy car enviro.
If you can find someone with a 1 or 2Mz scope and try to compare the signals might be helpfull. Again not trying to down the prop scope just trying to help a little.
And on Yours sch You have only one pair of voltage pins of Propeller connected -- Both need be and both sides need one 100nF and at least on XTal side one Tantalum 20-40uF.
Ps. caps to Propeller need be as near its voltage pins as possible!
I connected both pins and added the caps you suggested ... how does this look? Also, are tantalum caps a couple dollars a piece or more? Or am I looking at the wrong thing on mousers site?
Yes, Tant caps can be expensive compared to others. I have some servo drivers that I repair with some tant caps that look like a electrolitic 10uF and they are over $50 apiece.
Comments
That is at least encouraging ... when I began this thread I thought the 4 months I had into this project of learning PASM and writing the objects I did had produced unusable code. It is good to hear from everyone that I have hardware options I can take advantage of. I started soldering the board that TChap recommended, which I must say is much harder than using a breadboard or that I anticipated it would be, but I had to stop before I could finish as it was time to go on vacation for a week. When I get back, I'm excited to hopefully find that with the recommendations in this thread, I'll be able to have my code work in the car, just like it does when I have another propeller simulating the car on the bench.
So you think I should have a decoupling cap on the main power supply line? What about pull downs on the pins I have counters set up on that are measuring the ac --> converted to dc signal?
Exactly where did you connected the power supply leads to feed your prototype when it is being tested it in the car? Have you ever tried to get +12V power directly from the battery terminals using jaws?
Have you added a huge (at least 2 amps foward current capacity) diode in series with the positive power lead and at least two (1000 uF + 1uF) low ESR capacitors ( at least 50V rated, I do recommend 63V) setup filtering just after the diode catode? With the negative leads of the capacitors connected to the point where ground enters the circuit.
Use one "where goes the cow, ox follows" rule to route power coming from battery till it reaches the on board regulators and continue to follow it through your entire logic.
If there are any high current actuator being driven by your circuit, get its power from the point where the leads coming from battery enter your setup and you surely will enjoy repeating the (diode+caps) setup in this path too, paying attention to the current consumption of the (driving + actuator) circuit to get the diode and bigger capacitor rated, obviously provided that switching will be referenced to ground.
Search, point and annihilate any ground loops (write the power path in a sketch and check for the existence of end around connections).
As an example, if you connect the ground lead to a metal shield in a point and extract ground to feed any circuit, logic or not, in another then you can get a ground loop, an antenna or both.. Surprised? But its true.
In case of doubt you can think ground electron flow as water distribution in pipes. Write down a sketch or simply connect cheap aquarism grade air tubing, with suitable Ts and Xs, and fill that setup with color blended water or alcohol. If it mimics your power setup, you will see "liquid electrons" flowing exactly as they will flow in your circuit.
Every previous suggestion to ground and shield everything strongly holds. Forever and ever.
Think your logic as a island of organization in a chaos. Design, route and shield it accordingly.
In the mean time, do two things, please:
1- Keep sharing your ideas, sketches and pics.
2- Pray God and pass the ammunition.
Your efforts will be gracefully rewarded and we will learn together!
Great first post, thank you! I am getting ground and 12v from the ecu ground and 12v, as I was hoping it would be at least partially clean before it even reached the ecu.
I do not have the diode/capacitors that you speak of yet. There is a lot of great information in this thread and I will try to incorporate all of it, the only problem is that it seems like I cannot use a breadboard for prototyping it which makes it much harder.
If you all keep offering advice, I'll keep posting circuits . Can you explain in more detail or possibly draw a crude/quick drawing of the two different states described here?
I would like to make sure I understand you correctly in what you are saying there. I think you mean if I piggy back or tee into the ground going to the shield, for a solenoid ... but I'm not sure.
@Heater ... I definitely fuse all direct battery connections, I learned that when I was still in high school
@Pedward, I found your site while searching ... you are quite the jack of all trades and where I'd like to be!
As others have mentioned there are ready made line driver chips that do this for you. That combined with twisted pair wires, shielding, etc will help keep the noise out. If the noise is of a much higher frequency than what you want to measure a cap from the input pin to signal ground can help.
Have you looked at the crank signal on a scope? I just built a injection system on my airplane. It's a rotax 914 turbo. It has a VRS sensor for the crank also. The signal isnt AC as you would think of a sine wave AC. It is a positive pulse as the sensor sees the metal aproach then back to 0 then a negitive pulse as the metal leaves the sensor. My problem was that when cranking the pulses were only about 2 to 3 volts and when running at rpms around 4 to 5K the pulses were up to 20 volts. That would be fine but if you trigger at the 2 volt range and the run at 4K rpm the noise spikes were over 12 volts and caused false triggers. You need a very good circuit to read reliably at all speeds. I gave up on mine and installed a seperate hall effect sensor to get a constant square wave. I dont read the cam do to the engine has no sensor on the cam and too much trouble to try to install one without modifing the block. The ignition on these engines uses the wasted spark desingn and fires the spark on both compression and exhaust strokes.
Since I gave up on the VRS I don't have any solution for you because I gave up on that type of sensor.
You will find noise on the sensor input is a real problem. Let me know if you find the way to get a good reliable signal off the VRS sensor. I know it can be done since they are used on a lot of engines.
Just for information I have the system up and running and at the point now of tuning in the fuel table to run at all throttle settings better. I used the carbs as throttle bodies and can run on the injection or the carbs switching over while flying.
I think the H11L1 is a 1.6mA threshold, so you will need ~ 2.7k for a ~5V threshold.
When given a 'nasty, but simple' sensor like this, one approach is to use a Set/reset latch that triggers on the Positive then negative pulses.
'Bonus' trailing ringing, and wide dynamic ranges, then do not affect the rate.
If the impedance is low enough, two opto couplers could be a solution, with either an external SR latch, or a SW SR latch.
That sounds awesome! I want to use a factory sensor, so when I do get it going I will let you know. Mine runs at low voltage when cranking and up to 15v (I think when at higher rpms) . Are you controlling injection with the prop as well?
Here are my scopes, I'm going to use thumbnails so that I don't litter the thread with a ton of pictures
1ms samples at idle
5ms samples at idle
10ms samples at idle
Cam at idle
1ms samples at 5000rpm
2ms samples at 5000rpm
5ms samples at 5000rpm
Cam
Yeh, I'm using a prop. Right now using seven cogs. Although mine is a lot simpler than a car. I don't have to wory about accel or decel and changing speeds a lot. In the plane the throttle is opened slowly to 100% and backed off to 75% then adjusted for cruise and left there for long times. After leveled off and stable, manually lean mixture till to lean and then increase a little for best fuel ecomomy. No sensors except crank, throttle pos and manual mixture control pot.
If you want an adrenalin rush try testing yours taking off a runway climing at 400 ft over the end of runway hoping the injection doesnt quit. Not enought time to switch over to carbs there.
I'll stick to my 4 wheels and pavement!
Mine is a 36-2, is that what you were using? Not realizing it when I started this project, I needed to learn PASM to have the speed I needed to read the 36 teeth and do all of the calculations I needed. I also want to control the variable cam, which is based on a pwm signal that controls hydraulic pressure, which is based on crank angle and target cam phase angle. I am inefficiently using all 8 cogs at the moment. I have a better example on how to use the counters to save at least 1 cog, but I cannot implement it until I get the rest of this working reliably and properly, as a baseline.
Oops, not quite. The 2.7k needs to replace the 100K on the DIODE side, as that is what needs the 1.6mA ( or lower than 2.7k, if your source is < 5V, and has an internal impedance) and the 5V power to the H11L1 needs to be direct to 5V.
RL on the H11L1 output does not need to be as low as the often quoted test values, ( you are not pushing MHz speeds) so 2.7k is fine there too.
So that looks like a missing tooth scheme, to indicate where you are in phase ?
If determining that missing tooth phase position matters, then I'd go for a symmetric Dual Opto scheme (just reverse connect the two IP Diodes) - probably easiest to just use two pins on the Prop, and then you can easily halve the widest time, to get an exact reference time.
By using a dual Opto, any threshold variations with speed, and opto levels, are then spread evenly either side of the true reference point.
Probably will be able to remove the LM1815, and the H11L1's can power from 5V, but have the pull-up wired to 3.3V for direct Prop drive.
My code can determine the missing tooth if I can get a clean signal out of it. When I feed the simulated signal from another prop, it works great.
I don't remember talking about a dual H11L1 setup, so I'm a bit behind on that part.
Can we used the circuit as is, since my code does all of the tooth timing and gap detection already, and works properly on a clean signal?
You cannot direct drive an opto from 100K, so will need some form of buffer on the diode side, which will need a power source.
How accurate do you need to nail down that phase point ?
As you can see on the scope it is pretty much half way between the Positive and negative pulses, but you could use more complex software, to derive a modeled threshold (from the duty cycle you observe), and then use that to 'fit' a calculated phase point.
If I remember correctly, it's 53% low to 47% high. My code works very well on the clean signal. As long as I can reproduce the signal in digital form, as I am doing with the first posted schematic I am good. If not, I will have to scope the new signal, compare it and then adjust the givens that are in my code. Still not impossible, just a little more work is all.
It may be better to add a transistor.
If you feed the Opto Diode from 12V with 2.7k, and then use a PNP transistor 68K to base, to sensor, Emitter to Diode+, Collector to Diode- and BAT-, then you will be using the PNP to short the Diode, and turn off the Opto when the base is below ~ 0.6V, a 'good' PNP with gain over 250, (say typical 350) will combine with the currents, and that base resistor to move the opto threshold to close to 0v (but with hysteresis)
Not sure if this is of any applicable interest or not, but sometime ago I used some little known Wiegand Inductor Coils. Their claim to fame is that a slow change in magnetic field strength is not detected until the level gets to some minimum trigger point and then it flips completely, giving out a pulse from the coil. The coil output level is (nearly) constant regardless of the rate of change in the magnetic field.
These things make a great rotary sensor because the output level is not RPM dependent.
Cheers,
Peter (pjv)
A few thoughts. Nix the opto that you have in the circuit. The LM1815 should be connected directly to the VRS.
I reviewed your schematic and the LM1815 circuit doesn't match the Nat-Semi datasheet I'm looking at. First, nix the 330pf and .01uf caps on the CAS input. Connect the CAS positive (check with side is grounded with a VMM) to the 18k resistor. Next, your output needs tweaking. The LM1815 typical operating voltage is 10v, so 5v may result in operation that doesn't work well with the example components. I would recommend a low dropout regulator to 9v from 12v, then drop the 9v to 3.3v for the prop, bypassing 5v. If you use a proper ground pad/heatsink, you can drop the 9v-3.3v in one step.
You have a 4.7k 5v pullup, but the LM1815 wants a pulldown. Also, you need to level shift the output of the LM1815 or use a dropping resistor to make certain the input voltage to the Prop isn't too high. Using a 1k pulldown, per the datasheet, and a 10k current limiting resistor to the prop input pin, should make it safe and shunt the voltage through the protection diodes, keeping the current through the diodes much lower than required.
The LM1815 fires the output on the negative going zero crossing transition. It uses the positive going pulse to adjust the amplifier. You can also omit the RC components on pin 14, since if you ground 9,11,14, the output is the zero crossing of the sensor, which is what you want.
Something that should be explained, since the poster with the Rotax touched on it, how to interface a VRS sensor.
VRS sensors are good because they provide a differential signal, which helps with noise, since noise induced on one wire appears on the other, which is typically canceled out. The odd/difficult thing that people don't understand is that the voltage varies with speed. This means you can use a level trigger circuit to interface to a VRS, you need to detect the zero crossing point. The only point in the waveform that is accurate is the zero crossing. The LM1815 datasheet has a very good diagram showing how a noisy signal is filtered. You may have a lot of noise riding on the signal, but the large negative going transition is what triggers the output, thus giving you an accurate timing edge while also handling all the induced noise from the environment.
At the time I designed my datalogger Bruce Bowling and Al Grippo seemed fairly certain that NS was discontinuing the LM1815, and this is the reason they didn't include it in the MegaSquirt. Armed with this advice I sought alternative solutions, first designing a level triggered input, then discovering my misunderstanding. I found a single ended zero crossing detector application circuit in the LM139 datasheet. I experimented with the circuit and finally arrived at a very robust and noise resistant interface circuit. The example lacked any noise immunity and would false trigger from ambient noise, so I had to add some filtering to get it to work properly. When done I could read VR sensors even at the slowest possible speed, just turning with my fingers.
One last thing, make certain you have decoupling capacitors on every chip and that they are physically located close to the power pins of the chip. The MegaSquirt power supply circuit is a very good design and has been enhanced from actual field use, so don't be affraid to borrow that design for your board.
Some mods from my side for mobile use.
It looks like you are using PropScope. I know I'll get trashed for talking about PropScope but here goes. I havent used it and it probably works very good for what it's intended for and the price.
These serial interface scopes tend to clean and correct the waveforms. I use a AstroMed 8Xe digital recorder at work. These are $10K units. We found even these have software and hardware filtering that does not show all the noise. We had problems with a control system and could not find any reason with the astro med. We finialy hooked up a 2Mhz Fluke scope and you would not belive the difference in the noise on the scope. I use a 1Mhz Tectronix at home when working on the propeller. That may be why your signals look so clean.
The prop is running fairly fast and without the right hardware on the input and if the software is picking up the noise spikes your program may work fine on sim but not to good in the noisy car enviro.
If you can find someone with a 1 or 2Mz scope and try to compare the signals might be helpfull. Again not trying to down the prop scope just trying to help a little.
I saw the example in the datasheet, does the lm1815 invert signal? I really need something that mimics the positive portion of the analog version of the signal with a digital signal, else my code is useless. I can't find my scope screen capture at the moment, but it digitally follows the analog positive portion of the VRS signal.
@CRST1
That answers a question I was wondering why I didn't see any noise on the line with the scope, even when I moved the time divisions really high. This also makes me more confident that hardware will fix it. I may try to find a used inexpensive and unfiltered scope on ebay.
Ok, how does this look as far as what everyone was describing? Can anyone recommend any good shielded wire? Mouser only had wire that was $20 a foot???
I still don't see any caps around Propeller.
And on Yours sch You have only one pair of voltage pins of Propeller connected -- Both need be and both sides need one 100nF and at least on XTal side one Tantalum 20-40uF.
Ps. caps to Propeller need be as near its voltage pins as possible!
I connected both pins and added the caps you suggested ... how does this look? Also, are tantalum caps a couple dollars a piece or more? Or am I looking at the wrong thing on mousers site?