Show Posts
Pages: [1] 2 3
1  Using Arduino / Programming Questions / Re: brushless rc limitator on: July 14, 2013, 10:09:16 am

I found out that there is no much sense trying to speed up arduino, because the RC controller used is not fast enough to make that quick changes to the motor rpm.. So using the smoothing that Is in the above code is a good solution for any spikes and rough reading.. This is now working just fine for me and is fast enough.. Before this I was measuring current with a hall current sensor but I could not achieve fast enough response to the controller, this now is way faster and precise..

The only problem that I have is that every few times I start or reset the arduino I get a strange bigger reading of the rpmTime of the above code.. In normal condition I get the readinngs from 6000(at 10% throttle) and 600(at 100% throttle), and when abnormal i get from ca 27000 to 21000... which vary... then i reset the arduino and the reading is ok.. sometimes even after resseting a few times the reading is strage every time, and vice versa...

thanks for all the answers... smiley-wink
2  Using Arduino / Programming Questions / Re: brushless rc limitator on: July 02, 2013, 08:51:52 am
Here is the part of the code that is doing this..
Here is part of the answer:
You need to

The only problem that I have in the code is to get good time readings, so I was thinking that this way I can make things more easy to follow and understand than to post the entire 30.000 bytes code of whitch 99% is lcd writing data and changing parameters..

I cutted out all the other things from the 30.000bytes code, and tested it, and it is working the same way... So I now editted the first post, and put there the entire working code...
3  Using Arduino / Programming Questions / brushless rc limitator on: July 02, 2013, 08:10:43 am

I am controlling an brushless rc motor with arduino using the servo library and of course the rc controller for the motor...
I want to able to limit the current as precisely and as fast as possible..

The motor is an outrunner with 14 magnets, so I mounted an hall sensor outside of the rotor and I am able to read each magnet that passes..

In the code I am using interrupt for sensors HIGH state and count the time between two readings..

I then compare the curent motor rpm to the output "angle" to the controller(0-180servo degrees) and with some testing, measuring and mapping I am now able to precisely enough know the current that the motor is pulling.. Knowing the current I can affect the output to the controller thus limiting the current..

The problem is that when I use the raw time measured I get some spike in the reading now and then and the spike is transfered to the controller....

I then tried to smooth out the reading, and now I cant feel any spikes, but the limiting is now slower in response..

Here is the part of the code that is doing this..
#include <Servo.h>

Servo ESC;

const int motorRpmSmooth = 20;
volatile unsigned long motorRpmReading[motorRpmSmooth];
volatile int motorRpmIndex = 0;
volatile unsigned long motorRpmTotal = 0;
volatile long rpmTime = 0;
volatile long rpmLast = 0;
volatile long rpmRaw = 0;
int throttleOut = 0;
int motorRpm = 0;

void setup()
  attachInterrupt(0, motorRpmRead, HIGH);
for (int rpRead = 0; rpRead < motorRpmSmooth; rpRead++)
       motorRpmReading[rpRead] = 0;

void loop()
throttleOut = map(analogRead(2), 0, 1023, 0 , 180);

motorRpm = map(rpmTime, 2330, 704, 31, 180);

ESC.write(min(motorRpm + 20, throttleOut));


void motorRpmRead()
  motorRpmTotal = motorRpmTotal - motorRpmReading[motorRpmIndex];
  motorRpmReading[motorRpmIndex] = micros() - rpmLast;
  rpmRaw = micros() - rpmLast;
  rpmLast = micros();
  motorRpmTotal = motorRpmTotal + motorRpmReading[motorRpmIndex];
  if (motorRpmIndex >= motorRpmSmooth)
     {motorRpmIndex = 0;}
  rpmTime = motorRpmTotal / motorRpmSmooth;

I just want to make sure that i am doing it in the best way.. Would it be better-faster that I write to the controller in the interrupt? Or to keep in the interrupt only the raw measuring, and the smoothing and the controller writing do in the main loop?
4  Using Arduino / Sensors / tm7709 on: June 23, 2013, 08:21:41 am
I am having trouble getting this adc to work..
Is there any library or code that someone tested that work with this adc..
Here is the link..
The code from the link is not working..
Thanks for your time,
5  Using Arduino / General Electronics / arduBMS on: June 05, 2013, 03:18:57 am
I want to build a bms for lithium battery. The key is to measure the voltage of each cell connected in series...

Using voltage dividers for every cell is ok for only few first cells thus the precision of measuring drops for every cell that we add...

My idea is to use some multiplexers and connect one cell at the time to charge a capacitor, and then disconnect the cell and connect the charged capacitor to arduino and measure the voltage... This way arduino could be powered by the same battery pack that he is measuring...
The only multiplexer I found capable of high voltage(72V) is the max14752... Is there any other possibly not smd?

When I have the cell voltages, It is easy to do everything else regarding balancing, voltage protecting, and It can be used for any type of lithium battery by just changing the parameters in the code.... Then I have the possibility to write all the data to some lcd, making graphs.......

Is this Idea any good?

6  Using Arduino / Displays / Re: MCP23008 lcd library on: May 31, 2013, 12:02:21 am
No idea if the library I got from Wide.HK that I modified and enhanced works on the Adafruit LCD, but it works just fine on my Wide.HK LCD's now.

Download link:

I included a demo program with the library examples as well.


This one is working....  smiley-grin

I wonder how fast it is but since is the only one that works I dont even care....

Thanks all for your help...
7  Using Arduino / Displays / Re: MCP23008 lcd library on: May 30, 2013, 11:07:31 am
The first thing that I did when i connected this adapter is that i used the scanner to find the adress, then i tried all the libraries with that adress including few other adresses that i could think of, even if i knew my adress but this was my desperate move...
8  Using Arduino / Displays / Re: MCP23008 lcd library on: May 30, 2013, 04:23:25 am
I2c scanner found device on adress 0x27, I tried putting 0x6E, and both of this adresses just blinks the lcd backlight... With other adresses and other librarys nothing happens, so i think that this is the closest one to get it work...
the library that almost works is [url]this[url]
9  Using Arduino / Displays / MCP23008 lcd library on: May 29, 2013, 02:20:37 pm
i have this lcd i2c adapter but i have a lot of trouble getting it to work with my 16x2 lcd..
I tried every library that i found for the i2c lcd.. i even found two of them claimed to be for mcp23008 adapter... but the best result was that i could turn the lcd led on and off..

is there any library that someone tested with this particular adapter? or have anybody modified one to work?
10  Using Arduino / Project Guidance / mega 2560 power on: May 08, 2013, 04:37:52 am
I am using mega in my car to power some relays(6 of them) like this one and a 16x2, and a few sensors and leds...
What is the best way to power all this?
I was thinking of using a dc/dc like this, set it to 5.0V and power all that including the mega through 5V pin...
11  Using Arduino / General Electronics / Re: ACS756 on ebike on: November 10, 2012, 08:21:00 am
It is connected like this..

The reason that I am measuring the negative side is because I am measuring the voltage of individual cells(with voltage divider for each cell), and for disconnecting the battery i have to disconnect only the common negative side, this is done by a relay... so it disconnects everything... all that components are on the same board, so this was the easiest way to do that...
12  Using Arduino / General Electronics / Re: ACS756 on ebike on: November 09, 2012, 10:46:22 am
I added the capacitors, and the resistor, but the same problem is happening... I tried to move the main wires, and also tried to disconnect the output from the hall going to arduino analog, and that didnt help.. I even disconnected the gnd going to the hall, nothing helped...
Only when i connect the main output wire to the same big pin of the hall current sens that is going "in" , and all other remains connected, there is no problem, but of course there is no measuring either...

I am running out of ideas....  smiley-cry
13  Using Arduino / General Electronics / Re: ACS756 on ebike on: November 08, 2012, 03:26:52 pm
Firstly the issue with the LCD reseting is due to spikes/transients from the motor and its controller.

Everything is working fine if i only bypass the current measuring hall sensor... So I dont think that any spikes or close wiring is the problem... Maybe i am wrong, but i tested that many times, and newer got any problem....
14  Using Arduino / General Electronics / Re: ACS756 on ebike on: November 08, 2012, 02:16:31 pm
My board is already done, and mounted on my ebike, so if i could fix my problem by only adding a couple of capacitors and a resistor it would be much better solution.... It is a easy to try and maybe it will be ok... But I dont know what values to use...
I found this, i would like to be sure that this values is ok??
15  Using Arduino / General Electronics / ACS756 on ebike on: November 08, 2012, 01:03:40 pm
I built an e-bike, with a rc bldc motor, and rc controller, and with arduino i am limiting the current by reading it with a ACS756 hall current sensor.... I connected it without any capacitors or resistors to arduino, and in 90% of the time it is working ok, but in the other 10%... my 1602 lcd resets(like it losses power), and i have strange readings on my other hall switch sensor used to read crank rpm... this happens when there is a quick increase of current to the motor.  I tried to connect the motors controller directly(not throught the ACS756) an everything is fine...

I found that there is a need to use some capacitors, and a resistor, but i was thinking that this is only to smooth the output(which i dont need because the reading is ok for me), or this could fix my problem?
Pages: [1] 2 3