Peacepirate
New Member
One question remains:
What do you connect to ELECTROMAGNET_PIN 4?
What do you connect to ELECTROMAGNET_PIN 4?
Riding a tuned or deristricted EMTB is not a trivial offence and can have serious legal consequences. Also, many manufacturers can detect the use of a tuning device or deristricting method and may decline a repair under warranty if it was modified from the intended original specification. Deristricting EMTB's can also add increased loads for motors and batteries. Riding above the local law limit may reclassify the bike as a low-powered bike, requiring insurance, registration and a number plate.
Be aware of your local country laws. Many laws prohibit use of modified EMTB's. It is your responsibility to check local laws. Ignoring it, has potential implications to trail access, and risk of prosecution in the event of an accident.
We advise members great caution. EMTB Forums accepts no liability for any content or advice given here.
You can leave that line of code in place and simply make no connection to Pin4.One question remains:
What do you connect to ELECTROMAGNET_PIN 4?
Hey there,You can leave that line of code in place and simply make no connection to Pin4.
Hey there,
when i tried the first time to test your code it didnt worked out but i wanted to check everything before proclaiming that and be sure that this wasnt caused by a wrong edited code. i dont need a variable multiplier but just a fixed value of 2.0 and i dont need a setup mode either so i deleted that part. To exclude these potential sources of errors i uploaded your code again with the changes you talked about:
#define REED_SENSOR_PIN 2
#define SETUP_PIN 6
#define ELECTROMAGNET_PIN 7
#define REDLED_LOWPRESSCOUNT_PIN 5
#define A1A 4
#define A1B 3
byte ButtonState;
byte LastButtonState;
byte Trigger = HIGH;
byte SetupState;
double LastPress = 0;
double CurrentPress = 0;
double EndMagnet = 0;
double MagnetDuration = 0;
double Delta;
double DeltaStatic;
double ActivateMagnetStart = 0;
double ActivateMagnetTemp = 0;
double MultiplierOut = 1;
double MagnetOnTime = 0;
double MultiplierCutOff = 1398; //1398 = 6kph/3.5mph
int Pressed = 0;
int PressCount = 0;
int MagnetSwitch = 0;
int MagnetOn = 0;
////////////////////
//change this MultiplierOut to alter max assistance speed. MultiplierOut 1.4 gives: 25kph * 1.4 = 35kph new max assitance
double MultiplierIn = 2.0;
double SetupDelay = 513;
double SetupWidth = 47;
void setup() {
pinMode(ELECTROMAGNET_PIN, OUTPUT);
pinMode(REED_SENSOR_PIN, INPUT_PULLUP);
pinMode(SETUP_PIN, INPUT_PULLUP);
pinMode(REDLED_LOWPRESSCOUNT_PIN, OUTPUT);
pinMode(A1A, OUTPUT);
pinMode(A1B, OUTPUT);
LastButtonState = digitalRead(REED_SENSOR_PIN);
SetupState = digitalRead(SETUP_PIN);
}
void loop() {
SetupState = digitalRead(SETUP_PIN);
//if we're in setup mode, run the consistent pulsing
if (SetupState == LOW) {
delay(SetupDelay);
//activate coil
digitalWrite(ELECTROMAGNET_PIN, HIGH);
digitalWrite(REDLED_LOWPRESSCOUNT_PIN, HIGH);
digitalWrite(A1A, HIGH);
digitalWrite(A1B, LOW);
delay(SetupWidth); //pulse width
//deactivate coil
digitalWrite(ELECTROMAGNET_PIN, LOW);
digitalWrite(REDLED_LOWPRESSCOUNT_PIN, LOW);
digitalWrite(A1A, LOW);
digitalWrite(A1B, LOW);
}
//outside of setup mode, function as normal
if (SetupState == HIGH) {
ButtonState = digitalRead(REED_SENSOR_PIN);
if ((ButtonState != LastButtonState) && (millis() - CurrentPress > 100)) {
//Button pressed
if (ButtonState == LOW) {
LastPress = CurrentPress;
CurrentPress = millis();
Delta = CurrentPress - LastPress;
Pressed = 2;
digitalWrite(REDLED_LOWPRESSCOUNT_PIN, HIGH);
if ((PressCount < 5) && ((CurrentPress - ActivateMagnetStart >= Delta) || PressCount > 0)) {
digitalWrite(ELECTROMAGNET_PIN, HIGH);
digitalWrite(A1A, HIGH);
digitalWrite(A1B, LOW);
Trigger = HIGH;
ActivateMagnetStart = CurrentPress;
MultiplierOut = MultiplierIn;
MagnetOnTime = millis();
MagnetOn = 1;
}
}
//Button released
if (ButtonState == HIGH) {
EndMagnet = millis();
MagnetDuration = EndMagnet - CurrentPress;
digitalWrite(REDLED_LOWPRESSCOUNT_PIN, LOW);
if (PressCount < 5) {
digitalWrite(ELECTROMAGNET_PIN, LOW);
digitalWrite(A1A, LOW);
digitalWrite(A1B, LOW);
MagnetOn = 0;
}
PressCount = PressCount + 1;
}
LastButtonState = ButtonState;
}
//if travelling slowly, fire coil 1:1
if (millis() - ActivateMagnetStart > MultiplierCutOff) {
PressCount = 0;
}
//If wheel stops on magnet after travelling slowly, turn off the coil after 2seconds
if ((MagnetOn == 1) && (millis() - MagnetOnTime > 2000)) {
digitalWrite(ELECTROMAGNET_PIN, LOW);
digitalWrite(REDLED_LOWPRESSCOUNT_PIN, LOW);
digitalWrite(A1A, LOW);
digitalWrite(A1B, LOW);
}
//Record one Delta to avoid continual changes to interval during multiplied interval below
if ((Trigger == HIGH) && (Delta > 0)) {
DeltaStatic = Delta;
Trigger = LOW;
}
//setup multiplier ramping
if (PressCount >= 5) {
if (PressCount < 10) {
MultiplierOut = (((MultiplierIn - 1) / 5) * (PressCount - 4)) + 1;
} else {
MultiplierOut = MultiplierIn;
}
if (millis() >= ActivateMagnetStart + DeltaStatic * MultiplierOut) {
if ((millis() < ActivateMagnetStart + DeltaStatic * MultiplierOut + MagnetDuration * MultiplierOut) && (Pressed > 0 )) {
//Magnet On
if (MagnetSwitch == 0) {
ActivateMagnetTemp = millis();
}
MagnetSwitch = 1;
digitalWrite(ELECTROMAGNET_PIN, HIGH);
digitalWrite(A1A, HIGH);
digitalWrite(A1B, LOW);
MagnetOnTime = millis();
MagnetOn = 1;
} else {
//Magnet Off
digitalWrite(ELECTROMAGNET_PIN, LOW);
digitalWrite(A1A, LOW);
digitalWrite(A1B, LOW);
ActivateMagnetStart = ActivateMagnetTemp;
Trigger = HIGH;
Pressed = Pressed - 1;
MagnetSwitch = 0;
MagnetOn = 0;
}
}
}
}
}
i tested the L9110 before without an arduino connected to it and could measure with my multimeter either +12v and GND on the motor out pins when i put on GND on A1A or -12v and GND if put gnd on A1B. So the h-bridge works as expected.
When i connect arduino and hbridge together AND DO ANYTHING ELSE after powering on this is the output of l9110:
- YouTube
Enjoy the videos and music that you love, upload original content and share it all with friends, family and the world on YouTube.youtube.com
Here you see voltages of the arduino pins 3/4 View attachment 141256
View attachment 141257
Not using this method I'm afraid! More recent firmware revisions from Bosch have patched this hole.so no solution atm for deristrict magnet rim bosch cx race ?
sad newsNot using this method I'm afraid! More recent firmware revisions from Bosch have patched this hole.
I was thinking of giving this a go, but looking at the most recent comments, looks like it doesn't work, is that right? Does it cause an error?
I'm not sure if you've tried yet, but I was wondering if instead of a fixed multiplier you could instead simulate a lower gear ratio so that the cadence and wheel pulses match an feasible gear ratio (because I think Bosch builds up a histogram of likely gear ratios over time)
Does anybody know on what motor firmware it stopped working? I am on
Europe: 8.16.0 with latest app
Are the version Numbers country dépendant?For completeness, I'm on v5.17.0.
Are the version Numbers country dépendant?
Bosch have a patent on this method, so they either do it now or could do in the future.I was wondering if instead of a fixed multiplier you could instead simulate a lower gear ratio so that the cadence and wheel pulses match an feasible gear ratio (because I think Bosch builds up a histogram of likely gear ratios over time)
My Son has an Bosch performance cx with a continuous Enviolo drive! So a min. max. and all in between …Bosch have a patent on this method, so they either do it now or could do in the future.
I've tabulated the gear ratios in a spreadsheet and worked out good values for multipliers. The gear steps are not always exactly the same (since tooth counts are confined to integers) but they come out pretty close. Multipliers are either 1.18 or 1.39 (corresponding to one or two gear steps at the high end of the cassette). Seems to work for me but I'm not running too many kms on it to guard the warranty.
Just because they have a patent doesn't mean they will do it, or even intend to. It could be just to stop other people doing it (or to throw derestrictor makers off the scent!)So a min. max. and all in between
Sorry Swiftier, not any more. If you review my post a few above, you'll see the motor firmware version means it might not work for you I'm afraid.@megabobra hello! Are you still selling pre assembled chip? I cant send you a private massage(i havent reach 10 posts)
Howdy Robby,
Sadly it's not working on later/current Bosch motor firmware. Bosch seem to have tightened requirement of the magnetic field it's looking for meaning the simple electromagnet coil is no longer sufficient.
My unit is still running OK after ~1500km now but I'm back on firmware ~5 or so.
I do have a fix that I've been waiting to test but I'm not keen on updating my own motor in case it fails.
I'm keen to chat with anyone in Aus that has a smart system with up to date firmware and who is willing to have a go at a quick tria
I'm in Perth mate, have latest fw on rail 9 gen3 after eplus advanced sent me into error mode (auto speed on, 50kph limit, ~900kms)
I'd be happy to test yours out of you're still looking.... I still got two get out of jail free cards left
Rotor magnetBrilliant thanks. Is it a rim magnet setup though? Or Rotor magnet?
Ahh ok gotcha. So the one I want to test is for is the rim magnet. For the rotor magnet, I'm pretty confident the existing megaboba tutorial will work - you should just position the electromagnet on the speed sensor rather than on the motor!Rotor magnet
For those of us with an attention deficit, is their an updated short version of where things are at with this? I’d love to get one if it will work with my Crestline (Rim Magnet/CX Race).
The World's largest electric mountain bike community.