How make a digital “spike” from incoming analog pulse and send it internal ...

Hello there! I’m a newbie on Arduino. I think it’s so fun to experiment with it. I need help. As you can see from the picture I have two pulses. The yellow one comes from my hall effect sensor, (here it’s from my wave generator). The second pulse is that who Arduino makes. I use plcLib (Arduino) who I trigger. I can now make the delay I need. The plan is an ignition module with advance to my old bike. Because the Hall effect sensor is analog output I wonder how I can make a digital “spike” from the incoming signal and send it to the plcLib routine who then makes the pulse, blue one. The plsLib is connected directly to pin A2 reading the signal. I need to make a “spike” for 5v (high) and send it internal to plsLib.

#include <Timer.h>
#include <plcLib.h>

unsigned long TIMER0 = 0; // Variable to hold elapsed time for Timer 0

void setup() {
setupPLC(); // Setup inputs and outputs
}
void loop() {

in(X2); // Read Input A2
timerPulse(TIMER0, 500); // 0,5 second delay
out(Y1); // Output to Output 5
}

Regard
Ola A.

Image from Original Post so we don't have to download it. See Image Guide

And please reduce the size of images before uploading. 640x480 is probably enough for most things

...R

Thanks :slight_smile:

And you have a solution for me? I can take the signal out one pin and send it in another... but it feels stone age.

Olaab:
And you have a solution for me?

No.

I know nothing about the libraries you are using.

Does a Hall effect sensor need to be treated as an analog device if it is just detecting pulses?

I'm not even sure what you are trying to achieve. Do you want the Arduino to detect the short pulse and then delay the start of the long pulse by a certain amount?

What is the frequency of the pulses and how much do you want to defer the start?
What level of timing error is acceptable (in microseconds)?

...R

In a motorcycle is a lot of interference, thats because I want to create a digital signal. The rate is low, 25-200 Hz.
Yes that's right, a short digital pulse to activate a long. I think I have the solution but I want to connect a digital processing, to a long pulse processing, internal, not pin to pin. The ignition is not so picky and when I look at my curves they match with milliseconds.

thanks

/Ola A.

You have not really focused on my questions. I should not have to try to interpret your answers,

It seems to me you are saying

The frequency will vary between 25 - 200 Hz
You do NOT need a delay between the detection of the pulse and the generation of the other pulse.
If the timing is accurate to +/- 1 millisecond it will be acceptable.

Please confirm that this is right, or else tell us the correct version.

What you have not referred to is
the need to treat the Hall effect sensor as an analog device (which makes everything more complex)
why you are using the libraries you are using

You also need to tell us how the length of the long pulse is determined.

...R

OK The advance of the ignition need to change the length of outgoing pulse. From the digital pulse I calculate the time to, length the end appear of the blue pulse. Thats it. There is no delay between the digital pulse and generating of the outgoing pulse. The important thing here is the length for the outgoing pulse. I dont have any problem with this. My problem is the connection between the two processes. Make digital and trigger the outgoing pulse.
I said why the hall effect sensor need to convert to digital. I have spent a couple of days to find nice solution on the Internet, and this one seems to be the best for controlled output.

/Ola A.

Here is a picture of the Excel I calculated for the different advances. The Hz is lower then I said but the advance is on the max at 3200 Rpm and the engine works to 8000 Rpm.
Im not familiar thath forums has so bad suport for pictures.

0026.JPG

Olaab:
I said why the hall effect sensor need to convert to digital.

Where? I have not seen that. To be honest I am not completely sure what you mean by the sentence I have quoted - it seems to be saying what I was saying i.e. that treating the hall sensor as a digital input would be better.

If you want to start a pulse when another pulse is detected I would have code in an ISR like this pseudo code

void myISR() {
   digitalWrite(outPin, HIGH);  // start the new output pulse
   pulseStartMicros = micros();   // record the time
   newPulse = true;
}

and in loop() I would have something like this

if (newPulse = true) {
   noInterrupts();
     newPulse = false;
     latestStartMicros = pulseStartMicros;
   interrupts();
}
// regular code to figure out (using latestStartMicros) when enough time has elapsed so that
// you can do digitalWrite(outPin, LOW)

...R

Nice! I'm going to test it out. Thanks :slight_smile:

There is no difference between analog and digital pulses. If a pulse has suitable voltage you can connect it to a digital input. That is digital. If a pulse has for instance too low voltage, you amplify it with an amplifier. That is analog. The pulse does not know or care what you do with it. You can treat it an like an analog voltage or as well as an digital voltage. You can even mix analog and digital electronics or components if you know how.

That is why talking about analog spike creates confusion.