In most old motorcycles there's only a visual telltale for the indicators and as you can imagine, usually the biker forgets about them and this can lead to serious accidents on the road since other drivers may think you are about to turn and may enter the road and you'll end up crashing in to them.
It is now common to find self-cancelling indicators in modern bikes, but for the older ones no system is available. The simplest solution would be to place a buzzer in parallel with the indicator lights so they would buzz with every blink of the indicator but this can be annoying if you turn the indicators too soon and also strange for bystanders .
I came across a patent (already expired) that came up with a clever solution for this. It's a system that would sound a buzzer after 20 (adjustable) blinks of the indicators in case you forget about them (patent attached), but for an absolute begginner in electronics like myself this is black magic and I was wondering if this is feasible with an arduino.
My first idea was to power ON the arduino with the same voltage source as the headlights (they need to be ON during ridding) and then monitor the voltage of the blinker lights with analogRead and count 20 "pulses" (on/off cycle, how many times the voltage entered a threshold?), after that, turn ON a buzzer. Problem is (or maybe not) how to turn OFF the buzzer after turning off the indicators?
Does this sound feasible? What kind of potential issues i'm not considering here?
I doubt any rider with a helmet would hear any buzzer.
Common arrangement , since the 70's at least, has been a cancel system that monitors pulses from the front wheel.
If the wheel is turning, cancel indicator in x pulses.
Before the 70's, there were no indicators, just hand signals...
You can still hear pretty fine actually. There are lots of vehicles (snowmobiles, watercrafts, motorcycles) with buzzers in the clusters. As long as the buzzer as a high SPL (>85dB) you can hear it perfectly unless you're hear impaired.
Honda CB500 2003 no cancel system, no warning sound.
In the 70's there were no indicators (quick search online: BMW R90S 1973, Yamaha XT500 1976, Honda CBX1000 1978 ) What was your point exactly?
Edit: In the 60's: Harley-Davidson FLH Electra-Glide, HONDA CB 450, Honda CB750 Four
Yes it is easily done, i think i could manage using just an ATtiny13a. Main thing is to provide the MCU with decent power, without voltage spikes. I would have the MCU constantly powered if the ignition is on and use Opto-couplers to separate it from the bike's power.
TBC that is a patent application publication. It is not a patent, and I sincerely hope that no patent on such an "invention" was granted, or if any similar idea got a patent it was at least in the previous century.
This solution to a problem ("invention") is obvious to anyone even mildly skilled in the necessary arts.
This is a nice little project and with care would be easy to build.
The code is nearly trivial, or could well be. As pointed out, the larger challenge is handling the mechanical and electrical issues that arise from the rolling environment the device is expected to enjoy.
You could get the software 100 percent done without coming near your bike. Even doing it in the wokwi simulator
It's kind of funny you say that because you choose to come to this topic to provided no help or suggestions whatsoever and instead you were sarcastic and even made little of the idea. In fact, it seems that it was you that didn't like my reply to your "answer".
I belive this is not the spirit of this forum and even less so to have this kind of debate.
You know nothing about me and my intentions and as you can see I am thankfull to those who are willing to help as I am willing to share the results in case I do achieve something worth to share.
Feel free to stay if you have something to add otherwise, thanks for stopping by!
Really?? I can hear the buzzer on my snowmobile while in full snow gear and helmet in a blizzard(since they say we are in one right now)
But hey I'm just a knowbody
Pretty much, well VCC to the MCU needs to be filtered, but yes i would set 1 GPIO pin as INPUT_PULLUP and let it be connecting to the (filtered) GND of the MCU power strip whenever either of the indicators turn on.
When no signal has been received for about 5 seconds, you can reset the counter.
Every signal receives increases the counter.
Until the counter reaches a certain amount and then the buzzer should go off.
Software wise it really is easy enough and will easily fit into the 1 Kb on an ATtiny13.
The hardware side is a bit more complex. If you want to use a 12v buzzer, again you will need to use an Opto-coupler to drive it or a transistor that drives it (the Opto-coupler may not be able to source the required current.)
The MCU should be protected against reverse voltage and voltage spikes. Starting out with a diode on VCC and on GND, putting a sizeable capacitor and after that a simple 5v regulator should suffice though, but don't think you can get away with anything less than that.
If there is an ATiny13 based Arduino board, that would be fun. I like to use the least powerful processsor possible.
If not, you better off to use a board that is easier to program, that is it just hooks up to your PC and the IDE can program it.
None of the boards is so expensive or large that it makes sense to go to the extra trouble of dealing with an IC directly, as satisfying as that would be.
The extra resources on a larger microprocessor can come in handy during development and are available if the project grows wings and gets carried away with features.
I use my Uno as a ISP programmer and stick the 8 pin IC in a socket for that purpose. Load the Arduino as ISP onto the UNO and that does the trick.
You are correct, but in the end you will still need to filter the power supply sufficiently and control the buzzer. I think the trouble of dealing with a bare IC is not the biggest issue. and size wise any board is at least 3x as big.
Even a attiny85 board is twice as big and you will still need to connect the pins somehow to the external signals.
Well yeah, but i don't see what we want to develop here, it is so basic it can be done without an MCU, but only in a more complex way.
I only use those if i need native USB, but in some ways any board will do and even an ATtiny85 is already overkill.
I'm thinking about a DC-DC converter (buck converter?) to power the MCU. To decouple the indicators signals two opto-couplers (VCC from buck converter, and signal from blinkers) and to power the buzzer maybe a relay would suffice. Overkill may be an understatment here but it's something I'm familliar with and it's easy enough to source and implement. Perhaps it has some drawbacks that I'm not seeing and even the durability is questionable...
Regarding SW, this will be my main challenge i would say. your algorithm seems pretty much covers the functionallity of the system. I'm also studing state change detection examples.
The extra resources on a larger microprocessor can come in handy during development and are available if the project grows wings and gets carried away with features.
This is my thoughts exactly, in case I would like to add some more features I already have the barebones of the system in place.
It really is very common for snowmobiles, motorcycles, boats to have buzzers. A buzzer with a high SPL (>85dB) and in a frequency range of 2600-3600Hz would be audible with helmet during operation of the vehicle. It's not by chance that OEMs put buzzers and with these kind of specifications.
Well about that, i think it's is not simplifying things at all. You will need to power it and control it with a transistor at least. A relay will require a minimum of 60mA (usually a bit more) what are the specs of the buzzer you intend to use ?
Considering that the MCU will probably use less than 40mA including the Opto-coupler driving the transistor that drives either the buzzer or the relay, i would just use a 7805 (probably just in a to-92 package) and a capacitor of 100uF on Vin of that and 1uF on Vout, and place those component in between 2x 1N4007 diodes. I know that works. A buck converter is more efficient, but requires more external components, and and such low current, efficiency is not such an issue.
really ? well as said, simple enough and only a few lines of code should do the trick
#define INDICATOR_PIN 0 // these pin nrs are approriate for an ATtiny but not for any board
#define BUZZER_PIN 1 // that has a UART connected to those pins like an UNO or Micro or Nano
#define NR_SILENT_BLINKS 10
#define TIMEOUT_RST 5000 // time after whcih the blink count resets in ms
void setup() {
pinMode(INDICATOR_PIN, INPUT_PULLUP); // both opto couplers can be in parallel connected here
pinMode(BUZZER_PIN, OUTPUT);
}
void loop() {
static uint8_t blinkCount = 0;
static bool blinkState = false; // we have to keep track if we counted this state already
static uint32_t timeOut = millis(); // use this to see if the counter should be reset
if ((!digitalRead(INDICATOR_PIN)) && (!blinkState)) { // one of th indicators has turned on
blinkState = true; // condition won't be true until the blinkstate is false again
timeOut = millis(); // update the last time a blinker came on.
if (blinkCount < NR_SILENT_BLINKS) { // if we are blinking in silence
blinkCount++; // up the count
}
else {
digitalWrite(BUZZER_PIN, HIGH); // Buzz
}
}
if (digitalRead(INDICATOR_PIN)) { // if no indicator is on
blinkState = false; // reset the state and 3wait for the next blink
digitalWrite(BUZZER_PIN, LOW); // stop buzzing (if it was buzzing)
if (millis() - timeOut > TIMEOUT_RST) { // if no Blink has been for the timeout period
blinkCount = 0; // reset the count so the next 10 blinks will be silent again
}
}
}
Ok it was a bit more complex than i thought when i started on it. This compiles easily on an ATtiny13, 24% flash 29% RAM, and i am confident it will work as you want. It's in the comments already, but again for most dev-boards you should use different pins than 0 & 1
The buzzer is a common 12v 8mA buzzer I have lying around.
I'll probably try the 7805 instead of the buck converter. Also, Ill add a fuse in the positive line from the battery (3A?)
I picked up an example of state change detection and created a simple circuit where I simulate the blinkers with a push button. After 10x the buzzer should go off... but it never stops
I'll adapt your code on my circuit on tinkercad
/*
State change detection (edge detection)
Often, you don't need to know the state of a digital input all the time, but
you just need to know when the input changes from one state to another.
For example, you want to know when a button goes from OFF to ON. This is called
state change detection, or edge detection.
This example shows how to detect when a button or button changes from off to on
and on to off.
The circuit:
- pushbutton attached to pin 2 from +5V
- 10 kilohm resistor attached to pin 2 from ground
- LED attached from pin 13 to ground through 220 ohm resistor (or use the
built-in LED on most Arduino boards)
created 27 Sep 2005
modified 30 Aug 2011
by Tom Igoe
This example code is in the public domain.
https://www.arduino.cc/en/Tutorial/BuiltInExamples/StateChangeDetection
*/
// this constant won't change:
const int buttonPin = 2; // the pin that the pushbutton is attached to
const int ledPin = 13;
const int buzzer = 11; //buzzer to arduino pin 9// the pin that the LED is attached to
// Variables will change:
int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 0;
unsigned long timeItWentOff = 0;
// previous state of the button
void setup() {
// initialize the button pin as a input:
pinMode(buttonPin, INPUT);
// initialize the LED as an output:
pinMode(ledPin, OUTPUT);
// initialize serial communication:
Serial.begin(9600);
pinMode(buzzer, OUTPUT); // Set buzzer - pin 9 as an output
}
void loop() {
// read the pushbutton input pin:
buttonState = digitalRead(buttonPin);
// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == HIGH) {
// if the current state is HIGH then the button went from off to on:
buttonPushCounter++;
//Serial.println("on");
timeItWentOff=millis();
Serial.print("number of button pushes: ");
Serial.println(buttonPushCounter);
unsigned long now = millis();
while (timeItWentOff > 0 && now - timeItWentOff < 2000 && buttonPushCounter >= 10)
{
Serial.println("Blinker still on, *Buzzer sound*");
tone(buzzer, 250); // Send 1KHz sound signal...
delay(100); // ...for 1 sec
noTone(buzzer); // Stop sound...
}
} else {
// if the current state is LOW then the button went from on to off:
//Serial.println("off");
}
// Delay a little bit to avoid bouncing
delay(50);
}
// save the current state as the last state, for next time through the loop
lastButtonState = buttonState;
}