Ducati Cutaway Display

IMHO you need a program that gives the same count for one revolution as there are discrete positions for the encoder. I suspect your decoder produces extra pulses so you can tell the direction - but that is irrelevant for you.

If you can get the Arduino to read the hall-effect sensor that sounds like a sensible option. How many teeth are there on the cam gear - include the half-width teeth in the count.

...R

Hello again,

I took some time to machine an adapter for a small dc motor to turn the motor over vs using the starter. The dc motor all helped slow down the revolutions.

I am currently trying to use the stock ducati hall effect sensor to detect position within a revolution. These sensors have the hall effect sensor plus a magnet built into one housing. The sensor is then placed within a few millimeters of the camshaft gear to count the teeth. There are 48 teeth on the gear with 2 teeth being half the height of the others ( the height difference produces a large gap so the hall effect sensor has a reference point).

Here is the technical specs on the particular sensor:
Technical Data
Supply voltage.....................................4.5 > 24 Vdc
Nominal sensing distance............................1.5 mm
Max be increased in proportion to pick up size
Current (typ) .................................................1 0 mA
Current (max) ...............................................20 mA
Enviroment sealing................................... IP67
Weight............................................ ..............30 g
Temperature range ........................ -30 > + 130 °C
Tightening torque........................................... 6 Nm
Output............................................ ...........PNP
Output sink voltage ............................0.4v Max
Trigger type........................................... ferrous

Supplying the sensor with 5 volts and allowing the motor to turn over will output -3 to +3 mV. Will the board be able to see these low voltage numbers?

Currently I am trying to understand what code is needed to:
-detect each tooth
-assign an led to turn on/off at a particular tooth count

Through the web I have only found code examples to measure rpm by using a magnet passing over a hall effect. I have yet to find code that is particular this example. Some of the code I have experimented with has been reading analog voltage signal from sensor, turn led on/off if it detects a high/low voltage signal.

Any suggestions would be appreciated.

Here is a link to a short video of the current state of the engine. Once the code and lights have been incorporated and work as needed, more detail will be spent on beautifying the cutaway.

Through the web I have only found code examples to measure rpm by using a magnet passing over a hall effect. I have yet to find code that is particular this example. Some of the code I have experimented with has been reading analog voltage signal from sensor, turn led on/off if it detects a high/low voltage signal.

It looks like you can run this sensor at a 5v supply level which will create output appropriate for input to the Arduino.

Given the description as PNP output, I would expect that this sensor will provide a digital output, but it will require a pull down resistor on the line going to the Arduino. 4.7K looks like it would be a good value if I'm reading the typical output current correctly at 1 ma.

Have you tried running the sensor at 5v with a pull down on the output?
What led you to be reading this sensor as an analog device?

Through other examples of hall effect sensors.

I am currently running the sensor off 5V from the board. I measured the milli voltage output through a voltmeter. How should a pull down be configured on the output?

How should a pull down be configured on the output?

Place a 4.7K ohm resistor between the line going to the Arduino digital input and ground. Write a simple sketch using digital read on the input pin and see if you see transitions 0>1>0 when you rotate the gear.

Thank you for the simple diagram. The wiring is a copy of the diagram with the code below being used. All that registers are "0" no matter how close a ferrous object in moved past the sensor (i removed sensor from its location so i could easily move an object in front of the sensor to ensure clear output values).

int hall = 12;
int val = 0;
void setup() {
  // put your setup code here, to run once:
pinMode(hall, INPUT);
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
val = digitalRead(hall);
Serial.println(val);
}

Are you certain that you have properly identified the supply, ground and output wires from the sensor?

You might also consider operating this device at more than 5V since that is near the bottom of the spec. You will need to be careful in your testing to avoid damaging the arduino.

You could try operate the sensor from a 9v battery or some other dc supply (12v wall wart?) higher in the 4.5 - 24 vdc range. I would try measure the output voltage with a meter and not connect it to the arduino. You should see the sensor switch between the supply voltage and 0 v

If you can actually see the sensor working, then you will need a voltage divider on the output to condition the output signal for the arduino.

Based off the symbols on the sensor for (+ - S) I have them hooked up correctly.

Keeping the wiring the same and with same code, I applied a 9v bat to the sensor and read the milli volts. There will be a fluctuation from - to + (visa versa) every time a ferrous object interferes with the magnetic field. I am not seeing full supply voltage in a stable state (no object) nor when an object is moved near by.

I am wondering if I need to amplify the signal output for arduino.

Do you have any additional specifications on the Hall sensor? Do you have a wiring diagram for the Ducati which shows has the sensor in connected to the ECU and the schematic of the ECU?

Is the sensor known to be good?

I am wondering if I need to amplify the signal output for arduino.

I have never seen reference to any kind of Hall effect gear tooth sensor which would require that. I believe that the small voltage you see is an indicator of some sort of problem, rather than how the device normally works.

I have attached a ducati schematic of the wiring with the RPM Sensor (hall effect) located in the bottom right. I do not have a schematic of the internal wiring of the ecu.

I will try tonight to wire the sensor back to the ecu and check voltages, drops, etc as the engine turns.

The sensor has worked in the past when I had it connected to the ecu to fire the coils in hopes show live spark while engine was turning. Without it connected, the coils wouldn't fire.

The sensor is a magnetti marelli SEN 8I3 phase sensor.

I'd probably take a simple approach here.
The engine is for display purposes and will be rotating at a relatively low speed and leds will be illuminated to show the various engine phases

It is probably only necessary to identify when a cylinder is at top dead center and the rotational speed of the engine to work out when the engine phase leds should be illuminated, according to a time line. That is, it is not necessary to use a rotary encoder. The identification of top dead center can be taken from the existing electronic ignition timing sensor (if that is still present on the display model) or from a sensor on a camshaft.

( Since the Ducati motor has an offset cylinder arrangement, I'm not sure if both cylinders are simultaneously at exactly the same phase in the cycle but let's ignore that complexity for the minute.)

I think that the gear tooth sensor may not be using a Hall Effect sensor, but rather is a Variable Reluctance sensor and will indeed require signal processing. Your low signal +/- measurements may indeed be what the sensor is putting out. The signal will be the smallest at the low speed you are using.

http://www.daytona-twintec.com/tech_sensors.html

There a clue other than your measurements that this might be the case. The wiring diagram you attached in the previous post shows a shielded pair going to the ECU which might indicate a low voltage signal.

I could definitely use a timed sequence to light the leds since the motor is spinning at 2rpm currently. I will then need to use a different sensor in place of the oem crank sensor or as suggested above off the camshaft. It would then be used to trigger the sequence and start the sequence over to ensure proper timing of the lights (within a few seconds).

Cattledog i believe you are correct about the sensor may not be a true hall effect because the +/- wires are wrapped with bare wire and then connected to ground. Could be why there was no information relating to my exact case. :slight_smile:

When I first wrote the code for the encoder to sequence one cylinder, I used the delay function. Going forward I do not think that may be best with timing two cylinders. Would the millis function be a better program?

For a quick demo on one cylinder, you can get away with delay() statements because only one LED will be lit at any one time.
For two cylinders, you can't because the LEDs will be interleaved and any delay used to keep one LED lit, will prevent another from being lit.

I would simply make a table which represents 1 full turn of one camshaft (it doesn't matter which), using degree offsets to mark the On/Off LED Events. From the degree offsets, you can calculate elapsed times proportional to engine speed.

This is only an example because I dont know the Ducati engine, and the phase difference between the two cylinders, but it could look like this:

phaseMap.PNG

You can divide the time (mS) for a complete rotation of the camshaft by 360 to get the amount of mS per degree rotation and use such a table to control the LED on/off periods.

How would I create a table for the arduino to access?

I have been researching the use of timers to hopefully control the led on/off states but a little lost. Not sure how to turn on/off a led based upon a certain time interval and what code is needed to say:

0<x<3000ms
digitalWrite(ledint, HIGH)

Seems that interrupts are an important part of timers so both cylinders can animate their sequence of leds.

I don't think timers are the simplest way to proceed. I'd do something like this to control the LEDs during a full rotation of a camshaft, based on a table similar to the one posted earlier

// if we are at zero degrees, record offset to millis() and calculate mS per degree.
if ( we are at cycle start ie zero degrees ) {
     offsetMs = millis() ;
     msPerDegree = (offsetMs - offsetMsLastCycle) / 360 ;  
     offsetMsLastCycle = offsetMs ;   // save for next cycle
}

//calculate current position of camshaft in degrees
camshaftDegrees = ( millis() - offsetMs ) / msPerDegree ;


switch (camshaftDegrees ) {
   
     case 0 :  digitalWrite( C1SparkLed, HIGH ) ; Break ;
     case 2 :  digitalWrite( C1SparkLed, LOW ) ; Break ;
     case 5 :  digitalWrite( C1PowerLed, HIGH ) ; Break ;   
     case 8 :  digitalWrite( C2CompressionLed, HIGH ) ; Break ; 
     // etc etc.  
}

Hi,
Your circuit that your posted form the Ducati manual, shows the RPM sensor as TWO WIRE device with a GND shield wire.

This would make your Ducati sensor a reluctance sensor.
When you use a DMM in resistance mode across the leads what readings do you get?

http://www.eraspares.com/ec/TabelloneCategoria.asp?IdCategoria=502&Pagina=12

Tom.... :slight_smile:

The sensor reads 705ohms. The link did not work TomGeorge.

I am trying to fully understand the code written above by 6v6gt. Attached is a table showing the sequence of the opening and closing with degrees, seconds, etc.

Please correct me if I am wrong:
-we are setting the current time as a variable of "offsetms"
-then we assign msperdeg as a function of current time minus last saved time / divided
-save time interval for loop

-camdeg is equal to current time minus saved time from above / msperdeg

Switch function runs each case independently after the previous one as long as the break is implemented?
Case # is the degrees associated with triggering a led?

Ducati sequence table.numbers.pdf (31.3 KB)

Hi,
try this one.
705Ohms is what it should be as an inductive pickup, it is a passive device, its output will not be high enough at the display speed to work reliably.

http://www.eraspares.com/ec/print.asp?IdComunanza=6107

Tom... :slight_smile:

Manderioli:
. . .
Please correct me if I am wrong:
-we are setting the current time as a variable of "offsetms"
-then we assign msperdeg as a function of current time minus last saved time / divided
-save time interval for loop

-camdeg is equal to current time minus saved time from above / msperdeg

Switch function runs each case independently after the previous one as long as the break is implemented?
Case # is the degrees associated with triggering a led?

Just before I address these points, I'll try and make a couple of general points about the code design.

  1. That code runs in the loop probably 1000's of times per second.
  2. It is designed so the main logic (represented as a switch/case construct) is in "camshaft" degrees and not milliseconds, because milliseconds are dependent on the engine speed which you may want/have to change and you don't want to have to change your code each time. I guess you've built the same sort of formula into your Excel table.
  3. It is in two main parts. Part (a) to detect the current period of the engine cycle (over 720 degrees) and build a conversion factor milliseconds to degrees. Part (b) is a sort of look up table degrees to LED events (on/off) appropriate to the current state of the camshaft.

So to your questions:

-we are setting the current time as a variable of "offsetms"
Exactly. The function millis() is a counter which starts as soon as the Arduino is started, counting milliseconds.
offsetMs is the value of millis() at the beginning of the engine cycle (camshaft at zero degrees) so by the calculation ( millis() - offsetMs ) we can work out how far into the engine cycle we are.

-then we assign msperdeg as a function of current time minus last saved time / divided [by 360]
Exactly. The the difference between the millisecond counter at the beginning of the current cycle (offsetMs) and the last cycle (offsetMsLastCycle) gives the length of the current cycle in milliseconds. We divide this by 360 to get the conversion factor milliseconds per degree (msPerDegree).

-save time interval for loop
That whole code section runs in the loop. The two calculations above are only done, however, when Zero degrees is detected and should be done only once per cycle. In the loop we know exactly what the current state of rotation of the camshaft is (camshaftDegrees) by the number of millisececonds we are into the current engine cycle. Once we know that,
we can switch the LEDs on/off. As I guess you know, a digitalWrite() which is used to change the state of a LED here, retains it state until the next digitalWrite().

-camdeg is equal to current time minus saved time from above / msperdeg
camshaftDegrees is the current state of rotation of the camshaft, calculated based on the time (mS) required for a complete revolution of the camshaft and the time (mS) we are into the current cycle. So for example, if a camshaft revolution takes 30 seconds, and we are 15 seconds into the current cycle, the camshaft is calculated to be 180 degrees.

Switch function runs each case independently after the previous one as long as the break is implemented?
Case # is the degrees associated with triggering a led?
Yes. A switch/case statement is like the classic if/then/else construct. So for example

case 270 :  digitalWrite( VCOMP, LOW ) ; Break ;

Means if the camshaft is rotated 270 degrees, change the state of LED VCOMP to LOW. The break just exits the Switch/Case statement, and it will be reentered at the next iteration of the loop.