How to add a throttle to a Carrera Vengeance E Spec

Woosh

Trade Member
May 19, 2012
20,381
16,878
Southend on Sea
wooshbikes.co.uk
that PAS pin needs to be pulled out, straightened and put back correctly.
It should line up with the other 3.
 

rajeshtailor

Pedelecer
Jun 5, 2020
170
3
that PAS pin needs to be pulled out, straightened and put back correctly.
It should line up with the other 3.
So thats what i was thinking however thats how the connector has been from day 1 I haven't touched that connector or pin and when i remove the Arduino and plug the PAS back into this male controller connector the bike functions as normal. I am scared that if I pull out this odd pin and correct it what if the bike doesn't function as normal.

So let me paint a different picture. Ultimately the 4 wire PAS female connector plugs into this 4 wire male connector (as it does normally), so to test this odd pin I connected the PAS to the Controller with just the wires so RED to RED, Black to Black, Green to Green, and Yellow to Yellow, then powered on the bike (now this should mirror exactly what the connectors do naturally), however straight away I received an error 21. So I am leaning towards this odd pin being the way it is by design, this odd pin is connected to the red wire.
 

Woosh

Trade Member
May 19, 2012
20,381
16,878
Southend on Sea
wooshbikes.co.uk
am I right in thinking that the bent pin is th green wire going to the controller?
and on thee arduino side, you have a female connector that is correctly terminated?
Let's say I am right. You need to use a thin needle, pierce the insulation of the green wire to reach the conductor and use your multitester to check for continuity between D13 and the green wire.
There is no guarantee that the bent pin connects to D13 when you connect your arduino.
 

rajeshtailor

Pedelecer
Jun 5, 2020
170
3
am I right in thinking that the bent pin is th green wire going to the controller?
and on thee arduino side, you have a female connector that is correctly terminated?
Let's say I am right. You need to use a thin needle, pierce the insulation of the green wire to reach the conductor and use your multitester to check for continuity between D13 and the green wire.
There is no guarantee that the bent pin connects to D13 when you connect your arduino.
The bent pin is the red wire going to the controller.
 

Woosh

Trade Member
May 19, 2012
20,381
16,878
Southend on Sea
wooshbikes.co.uk
bent pin goes to VIN - if you unplug the USB lead, can you confirm if the arduino is still powered, and the LED is still blinking?
If it is, then red wire/bent pin is connected to the VIN pin.
If not, then the contact is no good and your sensors can't get the power it needs.
 

rajeshtailor

Pedelecer
Jun 5, 2020
170
3
bent pin goes to VIN - if you unplug the USB lead, can you confirm if the arduino is still powered, and the LED is still blinking?
If it is, then red wire/bent pin is connected to the VIN pin.
If not, then the contact is no good and your sensors can't get the power it needs.
I can confirm the Arduino is still powered when I unplug the USB lead. Also the LED is blinking yes the red wire/bent pin is connected to the VIN pin. I'm just confused how a bent pin can make a proper contact but for some reason it must be making proper contact.
 

Woosh

Trade Member
May 19, 2012
20,381
16,878
Southend on Sea
wooshbikes.co.uk
let's prove first that the connectors from the arduino are correctly terminated and are making contacts with the sensor and the controller.
To do that, keep the connectors in place but detach the 4 signal wires from the arduino and join the cadence and torque wires straight from sensor to controller, by-passing the arduino.
If your bike works normally, then the fault is in the code.
 

rajeshtailor

Pedelecer
Jun 5, 2020
170
3
let's prove first that the connectors from the arduino are correctly terminated and are making contacts with the sensor and the controller.
To do that, keep the connectors in place but detach the 4 signal wires from the arduino and join the cadence and torque wires straight from sensor to controller, by-passing the arduino.
If your bike works normally, then the fault is in the code.
ok I'll try that so to be 100% I do the correct test I'll connect the following cables:

D13 -> A2 (Connect these directly together they are the green wires (cadence)).
A5 -> A3 (Connect these directly together they are the yellow wires(torque)).

The only wires connected to the Arduino will be red / black from the PAS and Controller. And the cables from the throttle.
 

Woosh

Trade Member
May 19, 2012
20,381
16,878
Southend on Sea
wooshbikes.co.uk
that's correct. We should know where the problem is after the test.
 

rajeshtailor

Pedelecer
Jun 5, 2020
170
3
Ok I tested this setup here are the observations without doing any pedalling:

1)On powering on the bike the motor kicked in briefly about 2secs then the motor went off
2) After 5secs the error 22 (could have been error 21) appeared.
 
Last edited:

Woosh

Trade Member
May 19, 2012
20,381
16,878
Southend on Sea
wooshbikes.co.uk
1)On powering on the bike the motor kicked in briefly about 2secs then the motor went off
it shows that the problem is not in the arduino but in the wiring.

Try this to confirm the state of the connections between the arduino and the controller:

1. connect VIN, GND, D13 and A3.
2. Unplug the sensor.
3. unplug the USB.

can you confirm that the throttle works without the computer?
 

rajeshtailor

Pedelecer
Jun 5, 2020
170
3
it shows that the problem is not in the arduino but in the wiring.

Try this to confirm the state of the connections between the arduino and the controller:

1. connect VIN, GND, D13 and A3.
2. Unplug the sensor.
3. unplug the USB.

can you confirm that the throttle works without the computer?
Do you mean A5 not A3? (So essentially connecting the controller to the Arduino).
 

rajeshtailor

Pedelecer
Jun 5, 2020
170
3
Ok so I tested the next step. Here are the results.

1. Powered on bike with no errors.
2. Throttle works with no issues until I let go and speed drops below 10mph I then get error 22.
 

Woosh

Trade Member
May 19, 2012
20,381
16,878
Southend on Sea
wooshbikes.co.uk
2. Throttle works with no issues until I let go and speed drops below 10mph I then get error 22.
you may need to add a procedure to your code to gracefully exit the throttle part and stop that error 22.

Let's try this first:


replace:
torqueval = torqueval + torqueperc;

with:

torqueval = 76 + torqueperc;

or use my formula.
 

Evian1040

Pedelecer
Jul 7, 2020
75
9
This is where i suspect the cadence needs to match the voltage as the chart showed.
Edit: Yeah, came too late and woosh got it right
 

Woosh

Trade Member
May 19, 2012
20,381
16,878
Southend on Sea
wooshbikes.co.uk
This is where i suspect the cadence needs to match the voltage as the chart showed.
can you remind me the output voltage range of the torque sensor?
The arduino analog range value is 0-1023, 1023=5V so the maximum torqueval needs to be reduced not to cause error 22.
 

Evian1040

Pedelecer
Jul 7, 2020
75
9
can you remind me the output voltage range of the torque sensor?
The arduino analog range value is 0-1023, 1023=5V so the maximum torqueval needs to be reduced not to cause error 22.
Lets get the chart back to the front page for reference, as we can see 4.3 is the max voltage with the max cadence we can produce, so the minimum cadence signal we produce would be 1.5v
41119
 

rajeshtailor

Pedelecer
Jun 5, 2020
170
3
I’ve changed the code I think that was a bug I’ll retest the throttle. I’ve also commented out the pedalon code so that doesn’t interfere in this test but I have a feeling I might need to output a minimum torque value of 76 (1.5v) when it falls into the pedalon function.
 

Woosh

Trade Member
May 19, 2012
20,381
16,878
Southend on Sea
wooshbikes.co.uk
thank you for that.
1.5V = 1024*1.5/5=308
4.3V = 102 * 4.3/5 = 880
A5 needs to be set between those two values when the throttle is in use.
Rajestailor experimentally determined that the throttle signal range is 290-577, to map this range to 309-880, Raj needs this formula:
x = 308 + y * (880-308)/(577-290)
approximately: x =308+ 2* y
x is the value to be written into pin A5, y is the analogRead from the throttle pin A0

Code:
  val = analogRead(A0); // Read the value from the throttle pin A0
  torqueval=0;
  if (val > 290) {
      torqueval = 308 + val * 2;  // approximation of x = 308 + y * (880-308)/(577-290)
  }
you can also write it in short hand like this:

Code:
torqueval = (analogRead(A0) > 290) ? analogRead(A0)*2 + 308 : 0);
 
Last edited:

Advertisers