I am building an electric bike using only RC parts (bdlc motor, rc esc..)now that it is working i wont to make it smarther by adding arduino.. my primary goal is to make some kind of current-power limiting becouse the rc esc doesn t have any.. so the idea is to control the esc using the servo library(tested, and working great) and monitor the current or the rpm of the motor and not allowing to much "throtle" when the current is higher than x, or not allowing a big difference in actual motor rpm and throttle position..there is no problem when i am only measuring the rpm, but when i add other things in the code the measurment go crazy because it counts micros in a loop each time it reads a magnetic(or any other) switch, because the loop is taking longer for the added code, so i was wondering if there is any way to make some kind of "paralell" loops which dont have any "timing" interference..??

the other thing i want to add is a battery voltage monitor... i am planing of using a led bargraph, 4017 counter, and a voltage divider, but when i add this code to the rpm monitor code it goes even more crazy because of the different dellay times for the 4017 counter...

Now i wont to try measuring the current using a shunt resistor, but i am not sure how to connect all that...

I am new to electronics, adruino and programming, so all this is a great learning experience for me..

this is what i am not sure how to connect.. the voltage divider and the shunt resistorthe arduino is powered by the esc(which have constant 5v power supply) connected to the arduino 5v - this is tested and working fine

if i connect only the divider.. the - to arduino gnd, and + to analog pin i think that it woult work just fine (if the voltage stays under 5v)

if i connect the shunt the same way.. - to gnd, + to analog pin, i think that there is no problem too, it should work (off course under 5v)

but i am not sure in to conecting both at the same time.. maybe i am wrong..

i am not sure what will hapen with the arduino power supply if all that was connected, it would have - from the esc, voltage divider and shunt connected to arduino gnd, + from esc to 5v, and two other + but through analog pins, coming from the same battery...

this is too confusing for me right now so i stoped working on this because i didnt wont fo burn something...

The first thing you need to find out is whether the ground connection from the ESC to the Arduino is connected inside the ESC to the connection from the battery negative terminal. Depending on the answer, it may be easier to put the shunt in the negative battery lead. What voltage is the battery?

If you want help with your code, you'll need to post the code.

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

What is the best way to find out whether the esc ground connection is connected to the battery negative?

The battery is 8s li-po, so the voltage is between 25,6v(empty) and 33,6v(full)

I was having trouble with the code when i was trying to read rpm and using that to "limit" the "power", but now i am trying with the shunt, and it looks ok, so for now i dont need any help with the code... but thanks for asking..The bigger problem is the connection off all that stuff, i will manage the code somehow...

What is the best way to find out whether the esc ground connection is connected to the battery negative?

You could disconnect the battery and use a multimeter to measure the resistance between those two points. If it reads less than 0.1 ohms or so then you can assume they are commoned. Alternatively, with the unit powered up and the motor operating, measure the voltage between those two points. It will be zero if they are commoned. Also, look at the data sheet for the ESC, it may say that they are commoned.

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.