6 Replies Latest reply on Apr 25, 2015 4:08 AM by cocooi

    problem with i2c in romeo

    cocooi

      first: english is not my ךanguage so mybe my english is not the best....

       

      so i work with this module http://www.dfrobot.com/index.php?route=product/product&product_id=1238

       

      i flush yokto for edison and this work fine,

      i work with eclipse (and not from arduino IDE), so i work with "mraa" library.

       

      so what i try to do is to control on analog pim and the motor, and (suprice!) this not work,

      what i know yet, this the ananlog pin and motor can control with i2c (addapter 1 and address 4), and they connect to atmga8,

      so i connect to i2c but i never get answer and i not can control on motor and recive data from analog pins,

       

      this my code when i try to recive data from analog pins 5

       

      uint8_t bus[] = {0xA5 ,0xA5};

      int Highvalue;

      int Littlevalue;

      mraa::I2c* i2c = new mraa::I2c(1);

      mraa_result_t x = i2c->address(4);

      mraa_result_t z = i2c->write(bus, sizeof(bus));

      Littlevalue = i2c->readByte();

      Highvalue = i2c->readByte();

       

      std::cerr << "adress " << z << " write " << x << " read " << Littlevalue << " and "<< Highvalue << " " << std::endl;

       

      the result is : "adress 0 write 0 read 0 and 0 "

      mybe this not problem of edison and "mraa",  and the problem is in communication of the conroller.

       

      any help very help.

      thank you

        • 1. Re: problem with i2c in romeo
          arfoll

          Hi - so i've never used the romeo boardmy guess is that it would get treated like a miniboard. My guess is what you want to do is instead of the write then two byte read, just do the following:

          i2c->readWordReg(0xA5);

           

          Anyways you might want to check with a logic analysr what you expect to do is what you are doing - if nothing is getting sent there might be a physical issue too.

          • 2. Re: problem with i2c in romeo
            cocooi

            i try to run with :

            i2c->readWordReg(0xA5);

            end this not work....


            i no have logic analyzer so now i stuck.

             

            i read code for i2c of arduino and when before start to write  call to func "beginTransmission()", and when end write call to func "endTransmission()".

            so when i write to i2c with library "mraa" i need to do something like this?

            • 3. Re: problem with i2c in romeo
              CMata_Intel

              Hi cocooi

               

              Do you have updates in this? Have you been able to work with I2C?

               

              Regards;

              CMata

              • 4. Re: problem with i2c in romeo
                cocooi

                dont have any updates.
                i buy logic analyzer but this not help me.
                what i chry to do is  to conntrol on 4 dc motor.
                i use this motor shield of arduino Motor Drive Expansion Shield Board Module L293D for Arduino Duemilanove Mega Uno | eBay
                i have arduino and this work perfect, but when ichry to connect to edison this not work.
                the problem is - for use this shield need to work with library "AfMotor", you can found that here adafruit/Adafruit-Motor-Shield-library · GitHub
                and this library is not optimized for edison, so i try to write new code for the shield but this not work,
                but i think this mistake to chry to work with this shield because is dont work with real protocol and take 9 pins (4 pwm and 5 digtal) for use.
                so maybe you can tell me good way and what need to buy to controll on 4 motor dc?

                • 5. Re: problem with i2c in romeo
                  CMata_Intel

                  Hi cocooi ;

                   

                  Yes, the AfMotor was made for the Arduino and not specifically for the Edison itself.

                  Which PWM pins are you using in the board? Are you sure the pins are available? In the Edison with the Arduino Expansion board the availables by default are the pins 3,5,6 and 9 so you should check which pins for PWM are available in the Romeo board. Have you tried to create your own library/sketch to make this work? You were using MRAA in the beginning have you had better results using MRAA or the Arduino IDE?

                   

                  Regards;

                  CMata

                  • 6. Re: problem with i2c in romeo
                    cocooi

                    helo cMata
                    i change the pins of pwm (i connect pin 11 in shield to pin 9 of edison), i create the pwm in mraa and now i have logic analyzer so i check the pwm and this exactly like arduino,
                    i think the problem is in other pins, i look in code of afmotor and its look like the other pins work like SPI, (have chip select clock and mosi, i dont understand what do the pin fourth).

                    so when i chry to write this in mraa, but I dont was able  to synchronize the rhythm, the minmum rate of mraa is 100us between edge (for example: if i iset pin to low output and i sleep 20us and after sleep the pin set to high output, the real time between edge is 100us and not 20us) and in arduino is 10us,


                    when i go home i upload picture of logic analyzer