Community
cancel
Showing results for 
Search instead for 
Did you mean: 
WDobr
Novice
1,825 Views

Romeo for Intel® Edison Controller problem with i2c communication with integral motor driver L298P

Hi,

I am working with Romeo for Intel® Edison Controller (With Intel® Edison). On this board there is integral motor driver L298P.

I am running motors with library https://github.com/ouki-wang/remeo4edison ouki-wang/remeo4edison - C++ - GitHub with success.

I was trying to run my motors without this library direct via i2c bus. it does not work for me. I used same i2c command as is in this library.

Can someone suggest me what is wrong with my code ?

I want to run motor1 with max speed 255

# include

 

void setup() {

 

Wire.begin();

 

Wire.beginTransmission(4);

 

Wire.write(0x55);

 

Wire.write(0xaa);

 

Wire.write(0xc1);

 

Wire.write(0xff);

 

Wire.write((unsigned char)(0x55+0xaa+0xc1+0xff));

 

Wire.endTransmission();

 

}

void loop() {

 

}
10 Replies
Sergio_A_Intel
Employee
145 Views

Hi wdobrzyc,

Are you running your code in the Arduino IDE, when you say you want to run the code without the library you mentioned do you still plan to use the Arduino IDE? When you say it does not work for me does that mean that the motor is completely unresponsive or do you get an error message if so, what errors do you get?

You also say you are running several motors, remember that the Romeo only has 1 I2C interface. Make sure you are powering using the correct power supply. Look at for details https://www.dfrobot.com/wiki/index.php?title=Romeo_for_Edison_Controller_SKU:_DFR0350 Romeo for Edison Controller SKU: DFR0350 - Robot Wiki

Sergio

WDobr
Novice
145 Views

Hi Sergio,

Yes I still want to run my 2 motors in Arduino IDE for now (without library). My next plan is go to mraa but first I want to resolve this problem.

My 2 motors are working OK(in Arduino IDE) when I run them with library. If I want to run them direct via i2c bus all motors are completely unresponsive. There is no error message.

Power is correct

I think I am sending wrong bytes or I am sending bytes in wrong sequence. I took this this example of code from library. I have no documentation what should I send to Atmega8.(this processor is managing motordriver L298P).

I need documentation or example of correct code to send commands via i2c bus. Do You know how can I gat those informations ??

BR

Wojciech

GPrab
New Contributor I
145 Views

The DFRobot page mentioned a bug with I2C communication and had an updated firmware

"Download the https://github.com/Arduinolibrary/DFRobot_Intel_Edison/raw/master/NG%20V1.2.zip Atmega8 firmware V1.2 (The newest firmware V1.1+ fixed IIC communication bug)"

Did you have this firmware version? See Atmega8 Firmware Upgrade

GPrab
New Contributor I
145 Views

There's some more debug options that you can pursue I suppose - You can upload a modified Atmega firmware (NG.ino) with DBG define set to 1 so that on receipt of I2C bytes, it will put it out on the Serial UART connected to Pin2 and Pin3 of J36 header. Probably you will have to use the ISP to flash the Atmega.

WDobr
Novice
145 Views

Hi, I will try to update my Atmega firmware with DBG = 1 to see more logs and I will back with any news

In spite of all I am thinking that I have already correct Atmega firmware because I can run my motors with DFRobot library. This library is using i2c communication. Can You confirm this speculations ?

GPrab
New Contributor I
145 Views

I just checked around the code in the Motor.ino and the WiringAnalog.cpp files in the repository

void Forward(){

motor.wheelEnSlv(ClockwiseM1);

controlMotor(M1, speedLeft);

motor.wheelEnSlv(AntiClockwiseM2);

controlMotor(M2, speedRight);

}

And the wheelEnSlv function uses the following format in the WiringAnalog.cpp library

void DFrobotEdison::wheelEnSlv(uint32_t cmd)

{

Wire.begin();

Wire.beginTransmission(4);

Wire.write(0x55);

Wire.write(0xaa);

Wire.write(cmd);

Wire.write(0);

Wire.write((unsigned char)(0x55+0xaa+cmd+0));

Wire.endTransmission();

}

So after the command, there is a zero byte that's being sent and not an FF - Can you check more on this side of the code?

WDobr
Novice
145 Views

Hi, I was trying with zero but it not help. One more odd issue I found in internet some example of code for scaning i2c. This program shows me 0 i2c devices So first I will try to update my Atmega firmware.

# include

void setup()

{

Wire.begin();

Serial.begin(115200);

Serial.println("\nI2C Scanner");

}

void loop()

{

byte error, address;

int nDevices;

Serial.println("Scanning...");

nDevices = 0;

for(address = 0; address <= 127; address++ )

{

// The i2c_scanner uses the return value of

// the Write.endTransmisstion to see if

// a device did acknowledge to the address.

Wire.beginTransmission(address);

error = Wire.endTransmission();

if (error == 0)

{

Serial.print("I2C device found at address 0x");

if (address<16)

Serial.print("0");

Serial.print(address,HEX);

Serial.println(" !");

nDevices++;

}

else if (error==4)

{

Serial.print("Unknow error at address 0x");

if (address<16)

Serial.print("0");

Serial.println(address,HEX);

}

}

if (nDevices == 0)

Serial.println("No I2C devices found\n");

else

Serial.println("done\n");

delay(8000); // wait 8 seconds for next scan

}

Sergio_A_Intel
Employee
145 Views

Do you have any updates on this case? Were you able to update the firmware and use the motors?

Sergio

WDobr
Novice
145 Views

Hi, Now I have firmware updated. This code for motors is OK. All clue is in methods "begin" and "beginTransmission" which are overwriten by dfrobot library.

I am debuging it. I will back with full answer soon

BR

Wojciech

WDobr
Novice
145 Views

Hello,

I think problem was with last byte sending via i2c to atmega. This is byte with check sum. Below I put example of correct code to run DC motor (in mraa):

var m = require('mraa'); //require mraa

x = new m.I2c(1) // bus address

x.address(0x04) // atmega i2c address

buf = new Buffer(5)

buf[0] = 0x55

buf[1] = 0xaa

buf[2] = 0xc1

buf[3] = 0xff

buf[4] = 0xBF // check sum = 0x55+0xaa+0xc1+0xff

console.log(buf.toString('hex'))

x.write(buf)

BR

Wojciech

Reply