I have:
NetduinoPlus (Micro Framework v4.1)
Twig I2C Motor Driver http://garden.seeedstudio.com/index.php?title=Twig_-_I2C_Motor_Driver
Using I2CBus class http://forums.netduino.com/index.php?/topic/563-i2cbus/page__p__4156__hl__i2cbus__fromsearch__1#entry4156
Write TWIGMotorDriver class
public class TWIGMotorDriver
{
private I2CDevice.Configuration _slaveConfig;
private int TransactionTimeout = 1000;
public TWIGMotorDriver(byte address)
{
_slaveConfig = new I2CDevice.Configuration(address, 100);
}
public void BothMotorsSpeed(byte speed) {
I2CBus.GetInstance().WriteRegister(_slaveConfig, 0x82, new byte[2] { speed, speed }, TransactionTimeout);
}
public void Motor1Speed(byte speed) {
I2CBus.GetInstance().WriteRegister(_slaveConfig, 0xA1, new byte[2] { speed, 0x0 }, TransactionTimeout);
}
public void Motor2Speed(byte speed) {
I2CBus.GetInstance().WriteRegister(_slaveConfig, 0xA5, new byte[2] { speed, 0x0 }, TransactionTimeout);
}
}
and Program.cs
public static void Main()
{
I2CBus bus = I2CBus.GetInstance();
TWIGMotorDriver motorDriver = new TWIGMotorDriver(0x28);
motorDriver.BothMotorsSpeed(255);
Thread.Sleep(Timeout.Infinite);
}
Motor driver not working, output voltage is 0 for both channels.
Help me please to start this motor driver.
Thank’s
I don’t know about NetduinoPlus (Micro Framework v4.1), you can try with Arduino or Seeeduino first. I think that maybe the I2C library problem; It works fine with Aduino-0019 but I experience some problem with Arduino-0022, and solve the incompatiblity by add delay() at the end of each transmission. You can try adding delay() too.
jimbo.we:
I don’t know about NetduinoPlus (Micro Framework v4.1), you can try with Arduino or Seeeduino first. I think that maybe the I2C library problem; It works fine with Aduino-0019 but I experience some problem with Arduino-0022, and solve the incompatiblity by add delay() at the end of each transmission. You can try adding delay() too.
Motor Driver works fine. They were problem with using I2CBus class.
Right code fot TWIGMotorDriver is:
public enum Direction {
Forward = 0x01,
Back = 0x2,
Stop = 0x3
};
class TWIGMotorDriver {
private I2CDevice.Configuration _slaveConfig;
private int TransactionTimeout = 1000;
public TWIGMotorDriver(byte address) {
_slaveConfig = new I2CDevice.Configuration(address, 25);
}
public void BothMotorsSpeed(byte speed, Direction direction) {
Motor1Speed(speed, direction);
Motor2Speed(speed, direction);
}
public void Motor1Speed(byte speed, Direction direction) {
I2CBus.GetInstance().Write(_slaveConfig, new byte[] { 0xA5, (byte)direction, speed }, 1000);
}
public void Motor2Speed(byte speed, Direction direction){
I2CBus.GetInstance().Write(_slaveConfig, new byte[] { 0xA1, (byte)direction, speed }, 1000);
}
}