2019-07-04, 12:27 PM (This post was last modified: 2019-07-04, 03:41 PM by skyeyedoc.)

Hi, beholder,

Ok, here's some notes that might help you too. I reviewed the voltage divider issue with an electrical engineer friend, and suggested that R1 and R2 be 47 kilo ohms and 18 kilo ohms, respectively. With 7 volts in, the output is right at 5.02 volts.

((NOTE!- THE RESISTOR VALUES IN THE LINE ABOVE ARE NOT CORRECT: They disregard the normal working range at A1 on the arduino, which is 0-1.1volts. See the reply below from Sean...))

If I monitor the voltage on the output of the divider, I mostly see 5.5volts there as the motor pulses.

Do you have your current and thermal sensors reporting back to pypilot from the imu correctly? Mine are not working yet. If you modify your motor.ino, please let me know, and I'll check it against this set up.

Thanks again for your notes! They've been a huge help.
Elliott

2019-07-04, 03:37 PM (This post was last modified: 2019-07-04, 03:43 PM by skyeyedoc.)

Hi, Sean,
Beholder77 wrote:
"One important note - according to BTS7960 datasheet CS (current sense) voltage in case of maximum values of current could be up to 7 volts, which is can be deadly for arduino, so i used voltage divider with 50k and 10k resistors"

For the A1 (arduino) to R_IS+L_IS (IBT_2 mcu) connections, my engineeer friend and I didn't know that the normal working range was 0- 1.1v . We only knew that it shouldn't exceed 5v. I'll adjust those resistors accordingly today, and test it. No harm done, I hope!

Hi Skeyedoc,
TMHO. You should connect a 1k resistor from the IBT2 IS to ground that should give a 8.5 ratio from current to Vis (BTS7960 datasheet). So with a current of 15 Amps there should be 1,764 volt (15/8,5) on that resistor (with a max of 7 volt in current limit mode but standard that should be with 43 Amps/8,5=5.05 Volt). Off course you want the Arduino to measure and give the right current. Just for an example According to ohm's law a shunt of 0.05Ohm (one of the options with the Arduino/Pypilot) should give a voltage of 0.75 volt at 15 Amps (that is also what the code in motor.ino measures (low current 20 Amps Max) (1024/1,1(refvolt)=931 x 0,75V = 698,2 x 275 /128 =1500) therefore you could (and should because of the possible 7 volt) use a voltage divider of 100Kohm and 74Kohm that will result in a voltage of 1,764V/174KOhm X 74Kohm=0,7502 volt. So Your measured current should be reasonably right. I hope this will put you in the right direction and off course I can’t give any guaranties as most off the time I have no idea what I’m thinking or doing.
Greetings Rob

(2019-07-13, 04:14 PM)rmvdmrl Wrote: Hi Skeyedoc,
TMHO. You should connect a 1k resistor from the IBT2 IS to ground that should give a 8.5 ratio from current to Vis (BTS7960 datasheet). So with a current of 15 Amps there should be 1,764 volt (15/8,5) on that resistor (with a max of 7 volt in current limit mode but standard that should be with 43 Amps/8,5=5.05 Volt). Off course you want the Arduino to measure and give the right current. Just for an example According to ohm's law a shunt of 0.05Ohm (one of the options with the Arduino/Pypilot) should give a voltage of 0.75 volt at 15 Amps (that is also what the code in motor.ino measures (low current 20 Amps Max) (1024/1,1(refvolt)=931 x 0,75V = 698,2 x 275 /128 =1500) therefore you could (and should because of the possible 7 volt) use a voltage divider of 100Kohm and 74Kohm that will result in a voltage of 1,764V/174KOhm X 74Kohm=0,7502 volt. So Your measured current should be reasonably right. I hope this will put you in the right direction and off course I can’t give any guaranties as most off the time I have no idea what I’m thinking or doing.
Greetings Rob

These notes are extremely helpful! I'd had no understanding of how the measured current worked. I'll try these values soon.

(2019-07-13, 04:14 PM)rmvdmrl Wrote: Hi Skeyedoc,
TMHO. You should connect a 1k resistor from the IBT2 IS to ground that should give a 8.5 ratio from current to Vis (BTS7960 datasheet). So with a current of 15 Amps there should be 1,764 volt (15/8,5) on that resistor (with a max of 7 volt in current limit mode but standard that should be with 43 Amps/8,5=5.05 Volt). Off course you want the Arduino to measure and give the right current. Just for an example According to ohm's law a shunt of 0.05Ohm (one of the options with the Arduino/Pypilot) should give a voltage of 0.75 volt at 15 Amps (that is also what the code in motor.ino measures (low current 20 Amps Max) (1024/1,1(refvolt)=931 x 0,75V = 698,2 x 275 /128 =1500) therefore you could (and should because of the possible 7 volt) use a voltage divider of 100Kohm and 74Kohm that will result in a voltage of 1,764V/174KOhm X 74Kohm=0,7502 volt. So Your measured current should be reasonably right. I hope this will put you in the right direction and off course I can’t give any guaranties as most off the time I have no idea what I’m thinking or doing.
Greetings Rob

Hi, Rob,

I've read your notes time and again since you posted them, but I still need your help to wrap my head around this matter of current sensing/current over-protection. Let me explain exactly what I've got now, then if you (or anyone?) can straighten me out?

I've connected the IBT2 to the Uno as Beholder77 outlined:

Where he has combined R_IS with L_IS going into the voltage divider, I presently have those entering a 47kohm resistor tied to A1, and a 15kohm resistor from A1 to ground. (I chose these values just because I had them lying around and they approximated the need.) If I understand what you've suggested, these values might better be 100kohm and 74kohm, and the reason for that is to get a more accurate estimate of current sensed?

For these, beholder77 mentioned 50k and 10k. I've walked through your calculations above, and confess I get a bit lost. Sean mentioned something about Vref being a range from 0-1.1 v. I think beholder77's R values come closest to limiting a 7 volt input to that range, no? However, you seem to have a handle on this ratio to Vis business that no one else has brought up.

With your R values, should the voltage from IBT2 rise to 7 volts, the divider would hold it at 2.98 v. With beholder77's values, it's capped at 1.17 v. It shouldn't hurt the Uno either way, but I just don't know which logic to follow.

But either way, does this mean that with this particular MCU, there's no need for placing a shunt resistor in the circuit? Somewhere along the way, I got the notion that was necessary to obtain current sense.

You can use the range 0-1.1 or 0-5 for analog readings but all analog readings must follow this range.

So if you decide 0-5v for current sense you need to adjust the resistors for voltage accordingly. One advantage of using 0-1.1 range is higher resolution, the other is that signals from 1.1-5 volts will saturate the reading (same as 1.1) but not damage the arduino so this gives a higher overhead without needing a zener diode.

Hope I can be of some assistance. With this controller there is no need for a shunt resistor (but it is still one off the possible ways to measure the current).

This controller has an output (IS Left and right) that gives a certain current that is related to the current running through the motor.
According to the specs with an 1k resistor from IS to ground the factor to the voltage on IS with this resistor will be 8.5 so with 15 amps going through the motor (and a resistor of 1k between IS and Ground) there will be a voltage of 15/8.5 = 1,764 volt on IS.

As indeed the voltage in current limit mode might be 7 volt and you want to get a good reading on pypilot and keep the arduino alive you should then use a voltage divider. The downside of this is that these resistors will be parallel to the 1 k resistor and will be of some influence (resistance will be lower than 1k) to the 8.5 factor that is why I suggest to keep a high value for these resistors (174k) so you should have a 100K resistor on IS as well in series with a 74K resistor connected to ground.
The point where the 100k and the 74K resistor meet will be the current sense input on the arduino. With these values you should be good if you keep the current up to 20 Amps. Just as in the software low current 20 Amps max will be 1.1 volt (Vref). If you do go above 20 Amps (you do get above the 1.1 Volt) you can use one of the other settings in the software by putting the pins D4/D5 (see motor.ino) high or low and/or chance the voltage divider accordingly.

Off course using a shunt according to motor.ino is another good option as you can use IS but you don't need to.

Beholder77 does not mention the 1k resistor from IS to ground and I doubt if he gets a good current reading without changing calculations in motor.ino (also a possibility to get the readings right)

(2019-08-30, 01:21 AM)rmvdmrl Wrote: Hi Skeyeyedoc,

Hope I can be of some assistance. With this controller there is no need for a shunt resistor (but it is still one off the possible ways to measure the current).

This controller has an output (IS Left and right) that gives a certain current that is related to the current running through the motor.
According to the specs with an 1k resistor from IS to ground the factor to the voltage on IS with this resistor will be 8.5 so with 15 amps going through the motor (and a resistor of 1k between IS and Ground) there will be a voltage of 15/8.5 = 1,764 volt on IS.

As indeed the voltage in current limit mode might be 7 volt and you want to get a good reading on pypilot and keep the arduino alive you should then use a voltage divider. The downside of this is that these resistors will be parallel to the 1 k resistor and will be of some influence (resistance will be lower than 1k) to the 8.5 factor that is why I suggest to keep a high value for these resistors (174k) so you should have a 100K resistor on IS as well in series with a 74K resistor connected to ground.
The point where the 100k and the 74K resistor meet will be the current sense input on the arduino. With these values you should be good if you keep the current up to 20 Amps. Just as in the software low current 20 Amps max will be 1.1 volt (Vref). If you do go above 20 Amps (you do get above the 1.1 Volt) you can use one of the other settings in the software by putting the pins D4/D5 (see motor.ino) high or low and/or chance the voltage divider accordingly.

Off course using a shunt according to motor.ino is another good option as you can use IS but you don't need to.

Beholder77 does not mention the 1k resistor from IS to ground and I doubt if he gets a good current reading without changing calculations in motor.ino (also a possibility to get the readings right)

Hope this gives a bit more explanation,

Greetings Rob

Yes! Sean, Rob, thank you for taking the time to parse that out as you guys have! I'll be testing the current draw on the bench with these values after this annoying hurricane headed (vaguely) this way.