Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Arduino w/ PWM expander and DC motor issue

Status
Not open for further replies.
I'm at my daughter's at the.moment and won't be back until Monday. There is a way to "uncrash" the I2C bus which I can post when I'm back. It's just looking at the (I2C) data line and sending clock pulses until it's low.

Opto should work and are fast enough for WPM.

Mike.
Great Mike. Thanks. Looking forward to the I2C release "uncrashing" method.
 
Try adding extra pullup resistors to the I2C lines? eg. 4k7 to 3.3V
It seems some arduinos have some level of onboard pullup and others may rely on the weak pullups within the MCU, which are too high value for proper I2C operation.

And / Or reduce the I2C bus speed, if you have it above 100KHz?
 
To clear the I2C lines at reset, you check SDA (D20) is high, if not clock SCK (D21).

So,
Code:
#define SDA D20
#define SCL D21

void clearI2C(){
    pinMode(SDA,INPUT);
    digitalWrite(SCL,HIGH);
    pinMode(SCL,OUTPUT);
    digitalWrite(SCL,HIGH);
    while(digitalRead(SDA)==LOW){
        digitalWrite(SCL,LOW);
        digitalWrite(SCL,HIGH);
    }
}

Mike.
 
To clear the I2C lines at reset, you check SDA (D20) is high, if not clock SCK (D21).
Mike!
Thanks. That works.
However, I am not sure how I would know when to reset. I2C channel doesn't report back when it falls out of sync. Correct?
 
Try adding extra pullup resistors to the I2C lines? eg. 4k7 to 3.3V
It seems some arduinos have some level of onboard pullup and others may rely on the weak pullups within the MCU, which are too high value for proper I2C operation.

And / Or reduce the I2C bus speed, if you have it above 100KHz?
I've lowered the I2C but speed to 20KHz. No real difference.
I've also added pull-up 4.7K resistors to the I2C lines. Also not helping.
 
Can you post a photo (or phorts) of the entire setup, showing the boards, power supplies, motor, transistor and all wiring?
 
Thanks. That works.
However, I am not sure how I would know when to reset. I2C channel doesn't report back when it falls out of sync. Correct?
The I2C lines get out of sync when they are interrupted during transmission. Normally, this cannot happen but if a random reset occurs by uploading a new sketch then it can. So, the only place you need to clear the lines is when it first boots up I.E. in setup before initializing the I2C.

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top