IFC Engine- & enviroment analog sensordata to NME2000 bus through Teensy3.6 (marine application)

Lin4Fun

New Member
Hello,

I am working on a DIY project to interface a lot of signals to a NMEA2000 bus to be able to controle an older analog engine and other sensors with a new multi function display.

To do so I am using Arduino / Teensy microcontroller together with a NMEA2K library. I started to design the PCB with EagleCAD and face now a couple of challenges.

The Teensy 3.6 have 3.3 v analog inputs with 13 bit usable resulution. To read the sensors values like oil pressure, engine coolant temperatur, rudder angle and so on I need to interface the 0-12 VDC (0-14.4 VDC max during battery loading) down to 0-3.3V DC.
I know that this could be simply done by resistor voltage deviders but I want to seperate the 12 V part from the controller. Liniar optocouplers?
Also is the difference between 12v and 14.4v 20% which will be also a huge difference in the value getting from the sensors.

So may question is how can I seperate the sensor 12V (14.4V) and shift them down to 3.3V max? How can I handle the 20% of extra voltage to get always the same accuracy. Thought to use here a voltage regulater like LM7812 to garanti to have always the same voltage provided for the sensors but the most Voltage regulators I could find needs always 15V minimum as input voltage.

Most sensors are hall sensors and liniar resistors of different kind like temperatur tank volume.
Is it possible to design this universary like I can use a hall sensor which deliver a sensing value 0.5V to 4.5V as well could use a sensor with sensing value from 0-12V on same input without need to make any hardware change or adjusting any potetiometers? It would be ok to have some kind of sensor voltage mode switches (DIP) "0- 5V / 0 - 12V" where I can choose 5V sensors or can switch to 12V sensors for each input separately.

So which parts are here possible to use for the analog input part and how could this be designed (schematic).

Every idea is welcome and thanks a lot!

dknguyen

Well-Known Member
So it sounds like your sensors are ratiometric analog outputs? You didn't specify because there are some other analogs that exist out there.

You would typically use resistive divider followed by an op-amp buffer. Since they are ratiometric and are on a different supply voltage than your microcontroller/ADC, then you should also step down tthat 12V battery similarly and feed it do the ADC as well so you can account for the ratiometricness. You could either used a fixed reference and treat the battery voltage as a separate channel and perform math on it to normalize the other readings, or you might be able to use it directly as a reference to the ADC.

Do you *NEED* to isolate it? Because isolating analog signals can be a huge PITA. Takes lots of parts or the parts are difficult to find and expensive.

1. You can directly expose the ADC and use a digital isolater to separate the ADC from the MCU.
2. You can DIY or find a component that modulates the analog signal into some digital form and reassembles it on the other side. This is a lot of complexity. It's enough complexity and expense that you almost never see it unless it's absolutely required and the ICs that take care of everything in one shot are insanely difficult to find and real expensive when you do find them (like $10+ or$15+ for a single channel).

Most sensors are hall sensors and liniar resistors of different kind like temperatur tank volume.
Is it possible to design this universary like I can use a hall sensor which deliver a sensing value 0.5V to 4.5V as well could use a sensor with sensing value from 0-12V on same input without need to make any hardware change or adjusting any potetiometers? It would be ok to have some kind of sensor voltage mode switches (DIP) "0- 5V / 0 - 12V" where I can choose 5V sensors or can switch to 12V sensors for each input separately.
Making it automated would require adding in things like transistors/switches or programmable gain amplifiers and programming the MCU to detect the battery voltage and make the appropriate selection. Or a comparator circuit that steps down both 5 and 12V low enough so that the comparator can measure both based on it's regulated voltage (probably 3.3V or 5V) and control a transistor to connect the appropriate resistive divider.

If you don't want to adjust potentiometers, add both resistive dividers into the circuit and make a jumper or switch to select the resistive divider that is to be used.

Last edited:

Lin4Fun

New Member
Hello dknguyen!

The point of isolating the sensors from the MCU was to make some kind of idiot proof. It is not neccessary but would be nice to have since the teensy 3.6 isn´t so cheeap and the channels fast destroyed.

The 90 degrees angle hall sensor I currently use gives an output voltage from 0.5v to 4.5v independently from the supply voltage. I could messure here some small differences (up to 50mv) but I think so precise that this would matter it don´t need to be. But it is a huge difference if I have a difference of 20% from the tank sensor at 300L of gasoline for example. So for the resistive sensor ( I guess it was from 30-190 ohm) I need to stabilze the supply voltage.

How would a LM7812 react if it gets just 12.6V as example?

For stepping down the input voltage to 0-3.3v I think I agree and just use a voltage devider together with switches to change the resistance of the devider for the different input voltages. May I could secure the input by using a z-diode, but I am not yet 100% about the schematic here. (do some research) For the 1005 resistive sensors like RTC and fuel I could also just put 3.3v as supply voltage which would be the easiest way.

I have read that it is possible to step down an input voltage by using an OP amplifier. Would this work propotional to the input voltage?

But with all of this I face one hugge problem. All analog gauges should also work and like I know all of them are quet low resistive and are using 0-12V as input value. Do I need to seperate them from the MCU analog inputs (Teensy3.5/3.6) or can they be used just in parallel? Ok, since this came now into my mind, I can not go down with the supply voltage. It have to be 12v here.

What do yu think?

MikeMl

Well-Known Member
Isolation is not required in an automotive environment, because the engine block/car frame is the reference ground, and it is also used as the power ground. Sometimes reading sensors must be done differentially to solve common-mode and ground-loop noise problems.

A simple way to account for sensor readings that are ratiometric with respect to car's electrical bus voltage is to devote an ADC channel to read the bus voltage, and do the calculation to factor out bus voltage variation inside the micro.

Most car sensors are just a varying resistance, so the voltage vs parameter curve is non-linear. The absolute accuracy of these sensors is very poor, usually only within a few %, so your 13bits is way overkill. A simple resistive voltage divider (referenced to micro's Vss) is all that is required to reduce the amplitude to prevent it from exceeding the micro's Vdd. If the tap on the divider is bypassed with a suitable capacitor, you automatically get anti-alias filtering and satisfy the requirement that the ADC input pin be driven from a low impedance source.

A lot of the sensors in automobiles are for timing (Hall sensors). You don't care what the actual trip point is; what you care about is the timing of the rising or falling edge of a periodic signal. It is inappropriate to sample such a waveform at a high sampling rate using an ADC just to find when the signal crossed a threshold; it is much more appropriate to use a Schmitt-trigger whose output causes an interrupt to the micro so you can record the precise time it happened.

Basically, every sensor has to be handled on a case-by-case basis. There is no magic bullet solution that will work for all sensor channels. I know this because I have designed micro-processor engine controls during my working career.

Lin4Fun

New Member
Just to clarify, I design this for marine application use. And in my case I have a complete analog engine without any CAN bus (yet). I am going to implement the NMEA2K bus which is CAN based.

The 13 bit is for most cases overkill, I agree. But some like ruder position there I need more than "just" one degree of accuracy since this sensor will as well be the source for the autopilot.
How ever, you helped me a lot! I decided to go for simple voltage divider with capacitor like you advised. By doing so it is also simple for me to make the sensor voltage switchable by switching the divider.

ClydeCrashKop

Well-Known Member
For oil pressure & temperature you can add your own resistive sensors to the engine. There are usually extra threaded holes. You can "T" into the oil pressure if necessary. Run your own wires and use the common ground. You can intercept a signal from their tachometer wire (gray?) using a high resistance and a 3.3v zener diode. Their tach won't notice. If your micro controller is being a tachometer, it will spend most of its time doing that and only check other sensors between tach readings. G.M. 3 wire sensors like MAP (manifold absolute pressure, vacuum) are 5 volt. Maybe they would work on 3.3v. Its worth a try. You can get all the sensors you want cheap at a junk yard.
Update: A GM MAP sensor does work on 3.3 volts. I tried it on an Arduino.

Last edited:

dknguyen

Well-Known Member
I have read that it is possible to step down an input voltage by using an OP amplifier. Would this work propotional to the input voltage?
Only if you want it to. That's what I was talking about when I said resistisve divider followed by an op-amp buffer (an op-amp wired as a buffer)

But with all of this I face one hugge problem. All analog gauges should also work and like I know all of them are quet low resistive and are using 0-12V as input value. Do I need to seperate them from the MCU analog inputs (Teensy3.5/3.6) or can they be used just in parallel? Ok, since this came now into my mind, I can not go down with the supply voltage. It have to be 12v here.

What do yu think?
The gauges are easy enough...just use high value resistors such as 10k+ in the resistive divider so they have minimal impact on the gauges wired in parallel. If that's still not enough you can always put an op-amp buffer on the front of the resistive divider as well to isolate it. Those op-amps would have to be higher voltage op-amps capable of tolerating the direct high voltages of the automotive systems (14V or higher) possibly with some diodes clamps to protect against voltage spikes.

Lin4Fun

New Member
Hello!

Regarding the old gauges, after I posted the question I thought about and yes since they are so low resistant it should not be any problem.
All the now existing engine wirering I have done by my self last summer. So there I have full control about.
The RPM sensor could easily be a hall sensor placed at the wheel where the generator and raw waterpump is connected to. On that wheel I have a place where a hole is inside the wheel which I could use to count the RPM's.

I ordered today a sensor from China, hopefully not to cheap produced but I will see. This flow sensor generates pulses per xL/Minute (1-30L). This is perfect and easy to map.

I would like to build an ultrasound based tankvolume sensor. Any idea which ultrasounder I could use for this application?

I started to design the hole PBC now based on resitive voltage dividers together with a DIP switch so I can switch between 5 + 12 V / 3.3V. To secure the inputs I use z-diodes with 3.3 volt and a nominal current rate of 1.5 A. This should be enough to secure the inputs I guess.

Since I don have 12 V stabelized from the system and since I don't have 15V for the LM7812 I got the advice to look at LDO's. I have to do some research about them. Didn't used them before.

MikeMl

Well-Known Member
...
Since I don have 12 V stabelized from the system and since I don't have 15V for the LM7812 I got the advice to look at LDO's. I have to do some research about them. Didn't used them before.
I would normalize all of the sensors to a well regulated voltage somewhere between 5V and 10V. The normal car's electrical system ranges from ~8V (during starter cranking), to 11.0V (dead battery), to 12.5V (good battery, but sitting long time), to 14.0 -14.7V (alternator charging).

There are LDO linear regulators that are specifically rated for automotive environments, including transients.

Lin4Fun

New Member
I would normalize all of the sensors to a well regulated voltage somewhere between 5V and 10V. The normal car's electrical system ranges from ~8V (during starter cranking), to 11.0V (dead battery), to 12.5V (good battery, but sitting long time), to 14.0 -14.7V (alternator charging).

There are LDO linear regulators that are specifically rated for automotive environments, including transients.
Hey Mike,

this is a boat and differs a bit from car. Basicly the same yes. Since a lot of the sensor are already in place and the old gauges shell be used as well can´t I just screew down the voltage of the sensors.

Regards..