Show Posts
Pages: [1] 2
1  Using Arduino / Sensors / mpu6050 on: July 20, 2014, 09:56:18 pm
I'm developing version two of a gyroscope board. i made the board as durable as i could. (other people than just me would be using it) version one is equipped with two mpu6050 gyros that are set to two different addresses. the two mpus share a single set of sda and scl lines for i2c communication. these lines go through a set of logic level shifters that get pulled up externally by a voltage of ones choosing.

for version two i would like to add interrupt support but i'm having a hard time deciphering the data sheet as it relates to what the mpu can handle electrically.

the data sheet describes that the interrupt pin can be configured to an open drain or totem pole configuration. from what i witnessed reading about this mpu it is common to connect the interrupt pin directly to a arduino board.

i would like to make the this board as durable as possible so my plan is to connect the interrupt pin to the gate of a n-mosfet through a resistor. this would allow for any pull up to be used externally.

what i don't know is if this set up would work? what current can the mpu drivers handle, what resistor do i need to the gate of the mosfet to keep the current under control. is there a better way to do what i want?
2  Using Arduino / Networking, Protocols, and Devices / Re: New Communication Library: FastTransfer on: May 31, 2014, 07:28:13 pm
This library was born from using EasyTransfer written by Bill Porter. We have used his library for years on our robot, which is primarily UART based with some full duplex and some half duplex systems. Although the simplicity of this library is simply amazing we ran into some of it's limiting factors.

The first is that EasyTransfer is clunky to use in a half duplex system because the only thing that distinguishes packets is the size. If there are three modules on a single communication line then 6 different struct sizes are needed for all 3 module to talk to each other. FastTransfer improves this by using an module addressing system.

Second, our robot sets up a wireless serial tunnel to and from the control box. When the robot is running in manual mode the control box needs to send it a lot of data but the robot needs to send very little back to the control box. When the robot is commanded to go full autonomous the robot must reply that i got the command like a virtual hand shake with the control box. When the robot is in full autonomous the control box only needs to send an alive message while the robot needs to send lots of feed back to the control box to show that everything is operating correctly. One problem is solved with a variable packet size. The second is solved with the AK/NAK generation. Internally the AK/NAK is generated as soon as the CRC clears or fails to reduce lag. When the AK/NAK message is pulled by the receiveData command a second receiveData command is called recursively in case there is data message sitting behind it in the buffer, again to reduce latency.

As far as performance goes i'm not sure how i could quantify it with a metric. I should operate as fast as the fastest stable baud rate that can be achieved. I preformed my preliminary testing with two UNO board running at 9600 baud. What i found is that i had to place two traps in the code to alleviate a problem where the protocol would try to pull the AK/NAK message out of the buffer before all of it had a chance to arrive. I think we will upgrade the comms on our robot in the next two weeks and we run our comms at 38400. When we are finished i can report on how well the system preformed.

let me know if you have any more questions.

thanks
3  Using Arduino / Networking, Protocols, and Devices / New Communication Library: FastTransfer on: May 31, 2014, 12:50:22 pm
Hi Everyone,

I have put together a new communication library and i am putting it out for people to test.

I call the library Fast Transfer. The library uses an address based system so multiple boards can communicate over a half duplex bus. The library also uses a variable size packet structure. Each piece of data is addressed and the packet can contain from 1 piece of data to 64 pieces of data. The system also incorporates an AK/NAK type response. When a module receives a data packet that is addressed to it (if the feature is enabled) the module will automatically respond with an acknowledged or not acknowledged. If a module receives data that is meant for someone else it will ignore the message.

the protocol also incorporates error checking. Alignment errors, address errors, and failed check-sum counts are recorded and can be retrieved with provided methods.

Documentation and example code are provided within the library which is attached.

The library can also be downloaded from
https://bitbucket.org/vini_i/fast-transfer/overview

please let me know if you have any questions, comment or suggestions.

Thanks
Igor
4  Using Arduino / Programming Questions / Re: passing a struct by reference in a class on: May 27, 2014, 08:34:09 pm
that works

i take it i need to declare the struct before the function the references it.

thanks nice catch..  smiley
5  Using Arduino / Programming Questions / passing a struct by reference in a class on: May 27, 2014, 08:16:44 pm
I'm looking to make some upgrades to a library but i have not worked a lot with classes. The problem i'm having is i have a bunch of ring buffer code that i'm trying to recycle. The ring buffer code works by handing a function a struct by reference, the function then modifies the struct. the code is very flexible this was because a single function can be handed many different structs as long as the structure of the struct is the same. for example..

Code:
void ringBuf_put(struct ringBuf * _this, int data){ some stuff..}

struct ringBuf{
int buffer[10];
int head;
int tail;
int count;
};

struct ringBuf one;
struct ringBuf two;

ringBuf_put(&one, 17);
ringBuf_put(&two, 21);

This code works perfectly fine in arduino environment. Now i'm trying to wrap this same code into a class to use in a library and it's not working. if i try to compile this code in the library or just in arduino i get an error. (this is just test code but the real code is almost identical but much longer)

FastTransferTest:21: error: prototype for 'void fast::otherstuff(fast::test*)' does not match any in class 'fast'
FastTransferTest:7: error: candidate is: void fast::otherstuff(test*)

Code:
class fast{
  public:
  void stuff(int hi);
  private:
  void otherstuff(struct test * hy);
  struct test{
    int th;
    int irm;
  };
 
  test kick;
 
};

void fast::stuff(int hi){
 
}

void fast::otherstuff(struct test * hy){
 
}

void setup()
{
}
void loop()
{
}

but if i compile this code it compiles just fine.

Code:
class fast{
  public:
  void stuff(int hi);
  private:
//converting the struct pointer to an integer is the only change
  void otherstuff(int hy);
  struct test{
    int th;
    int irm;
  };
 
  test kick;
 
};

void fast::stuff(int hi){
 
}
//converting the struct pointer to an integer is the only change
void fast::otherstuff(int hy){
 
}

void setup()
{
}
void loop()
{
}

is it not possible to pass a struct by reference inside a class or am i doing something wrong?
maybe a library that i need to add?
6  Using Arduino / Microcontrollers / Re: adding a new chip to uno board on: April 16, 2014, 08:31:12 pm
United States
Ohio

Why?
7  Using Arduino / Microcontrollers / Re: adding a new chip to uno board on: April 16, 2014, 08:00:27 pm
i've got the boards.txt and the avrdude.conf edited. what i found is i can burn a booloader to both boards with no errors but i can't compile for the 328 w/no P.

i did a thorough reading of the data sheets and the only difference between the 328P and 328 is power consumption. the P is a pico power part.

how can i add the 328 part to the compiler so it compiles like the 328P?
8  Using Arduino / Microcontrollers / Re: adding a new chip to uno board on: April 16, 2014, 08:24:24 am
as i mentioned earlier the boot loader is only a convenience for setting the configuration fuses for a fresh chip. after the boot loader is programmed the first time we program using ICSP the boot loader is erased.

when using ICSP to program avrdude does a signature check every time that's why i need additional entrys in the config and board files.

thanks for positing the changes i need to make. i will make them and try it out this evening. i will let you know how it works.

thanks a bunch
9  Using Arduino / Microcontrollers / Re: adding a new chip to uno board on: April 15, 2014, 08:42:59 pm
we use ICSP programmer to program our boards. (such as an avr pocket programmer or the usbtiny isp)loading the boot loader on a virgin chip is merely a convenience because it also sets the fuse setting in the  process.  

the chips are surface mount packages making them very difficult to replace after they are soldered on.

from what i have read the chips we have posses no less functionality than the native uno chips and i have already successfully run sketches on them. the inconvenient part is whenever i need to go back to an uno board i need to edit my avrdude.conf file to change the signature number.

if it is not possible to have one board with two chip options listed with avrdude then how would i go about creating a custom board entry with all the same tributes as an uno except the signature?
10  Using Arduino / Microcontrollers / adding a new chip to uno board on: April 15, 2014, 07:22:15 pm
i'll say it out right i have some stupid team members.

we are building a robot. in this robot there are 4 atmega 328p chips. all of our boards are custom made. to our dismay after we built up the boards and tried to program the boot loaders they would not program. after some investigation i found that the wrong chips were ordered. instead of 328p we got 328. i found that by changing the signature in the avrdude configuration file from 1E 95 0F to 1E 95 14 for the 328 chip it programs just.

the problem is there are at least 4 people doing development of software and we are using out old robot (which has the correct chips in it) for testing.

my question: is there a way to edit the configuration and board files to allow the IDE to program both chips seamlessly under the uno board moniker without constantly re editing the configuration file?
11  Using Arduino / Programming Questions / Re: logarithmic scaling on: December 14, 2013, 09:59:40 am
the motors we are using are ampflow A23-150. these motors are definitely powerful enough the problem is that the robot weighs 51 kilos. getting that kind of mass moving is tough.

you guys convinced me of the look up table idea. i checked and an int array[255] only takes up a quarter of the uno's memory.

what i did was use matlab to generate a matrix like what el_supremo suggested

Quote
One way to approximate the exponential curve would be to break it into several linear pieces. At the moment, at any point in the acceleration (and, presumably, deceleration) you are using the same linear constant to increase the speed. You could keep track of what stage of the acceleration you are at (as you do now) and map that into one of, say, five constants such as 1, 3, 7, 3 and 1, or whatever is appropriate. If it doesn't take long to get up to full speed I doubt that you'll notice the difference between that and a true exponential.

but i took it to the next level. i generated a time delay value for every motor speed and then i used the current motor speed as an index to look up the dely time.

the pseudo code looks kind of like
if ((currentTime - storedTime) > lookUPtable[currentSpeed + 127]) // the plus 127 shifts the index to align speed with delay
{storedTime = currentTime;
increment motor speed + or - one}



here is a graphical representation of that data set. close to zero speed the delay between steps is long ( 77 milliseconds)
out at the fringes of either reverse or forward the delay between steps is short ( 2 milliseconds).
i also scaled the total delay from stop to full speed such that it was no longer than the linear implementation which was 10 milliseconds. with 127 steps it ends up 1.27 seconds .

if anyone is interested i can share the matlab code
12  Using Arduino / Programming Questions / logarithmic scaling on: December 12, 2013, 08:12:36 am
my team and i built a robot. it is driven via WiFi tank style. we pass it a byte of data for motor speed. stop is zero. full forward is 127 and full reverse is -127. the robot is quite large and the motors can't just be commanded to the desired speed. we use a function that compares the current speed with the commanded speed and then increments and decrements the current speed accordingly. the incrementation is done with a timer. if current time minus the previous time is greater than a preset constant the speed is incremented by one step. this ramp function is linear.

i want to command the motors in a more logarithmic fashion. the closer the current speed is to zero (stopped) the longer the wait time is between steps and the closer it is to full speed the shorter the time between steps is.

for the life of me i can't think of a simple way to do this. one way that i've thought of is to use exponential decay. divide the delay time by a constant to the current speed power. the problem is i don't want to burden the processor with lengthy floating point calculations.

another way is to use an array with all of the delay times precalculated. the problem would be that the array is very large. 255 integers would eat the 328's memory alive.

are there any tricks that can be used to ramp the motor speeds in a logarithmic fashion?
13  Using Arduino / Programming Questions / Re: variable scope arduino vs c++ on: April 30, 2013, 09:41:32 pm
i guess what i'm asking, is there a way to keep variables local to void loop without them being screwed up by a redecoration when void loop repeats?

or is the only good way to work with void loop is using global variables.

(from what i have read about c++; int main is where one would declare local variables and int main does not repeat unless the programmer makes it repeat with some sort of a loop where as long as the variable declarations are kept outside that loop there is no problem and the variables stay local to int main)
14  Using Arduino / Programming Questions / variable scope arduino vs c++ on: April 30, 2013, 09:29:07 pm
i have a few questions on variable scope and the differences between arduino and c++.
first any variable declared outside of all functions is a global variable. i totally get that.

a variable declared inside a function is a local variable that can only be accessed by that function. this is where it gets fussy.

for example

 
Code:
void loop()
{ int bob; // this declares an integer bob
int steve = 5; // this declares the integer steve and sets it to five}

if i were to run this code the declaration of bob as void loop repeats would not affect the value of bob after a value is stored.
but would steve be redeclared with the value 5 every time void loop repeats?

if it does always reset to 5 how can variables get an initial value inside a local scope without declaring them globally?
15  Using Arduino / Sensors / IR sensor as a cheap lidar on: April 25, 2013, 09:50:08 pm
has anyone tried to use a sharp IR sensor as a cheap form of lidar?
i was thinking that if this sensor is mounted on a servo a FOR loop could advance the servo one degree at a time and take a reading from the IR sensor populating an array with the readings.

does this sound like i would work or are there pitfalls that i'm not seeing?
Pages: [1] 2