0

Conditional check isn't working appropriately on Pro Trinket
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Conditional check isn't working appropriately on Pro Trinket

by eavery6156 on Sun Jul 07, 2019 11:00 pm

I wrote a sketch for the DRV8833 breakout board that does digital and PWM control of 2 gearbox DC motors. Within the sketch, I wrote a function that will blink SOS (... --- ...) on the onboard read LED if the FLT pin on the DRV8833 board is driven to logic low. The sketch sets up the FLT pin as
Code: Select all | TOGGLE FULL SIZE
pinMode(flt, INPUT_PULLUP);
and I verified it by hooking up my multimeter to the GPIO pin that is setup to read the status of the FLT pin and ground. I get a value of 4.9v.

My loop looks like this:

Code: Select all | TOGGLE FULL SIZE
void loop() {
  if(digitalRead(flt) != LOW) {
    // go through digital control functions
    // go through PWN control functions
    } else {
      SOS();
      }
  }


Unless I am having a complete brain fart here, the conditional check within the loop should keep it from going to the SOS function unless there is an overcurrent/thermal shutdown condition present on the DRV8833.

It only seems to happen when I iterate through the digital and PWM functions within my loop() function. If I disable them, it never makes it to the SOS function.

Can anyone provide any insight into why this is happening?

eavery6156
 
Posts: 25
Joined: Thu Jul 31, 2014 10:53 am

Re: Conditional check isn't working appropriately on Pro Tri

by franklin97355 on Mon Jul 08, 2019 1:46 am

What is pulling the flt pin low?

franklin97355
 
Posts: 21105
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Conditional check isn't working appropriately on Pro Tri

by adafruit_support_bill on Mon Jul 08, 2019 5:55 am

What motors and power supply are you using? With DC motors, the startup condition is electrically the same as a momentary stall condition. And a geartrain adds more friction and inertia to the system, so it takes even longer for the motor to get moving. If your code is starting and stopping the motors, it is possible that you might see momentary tripping of the fault condition.

adafruit_support_bill
 
Posts: 74376
Joined: Sat Feb 07, 2009 10:11 am

Re: Conditional check isn't working appropriately on Pro Tri

by eavery6156 on Tue Jul 09, 2019 12:18 am

@franklin97355 the pin is brought high by the internal pullup and its driven low during an overcurrent/thermal shutdown on the DRV8833.

eavery6156
 
Posts: 25
Joined: Thu Jul 31, 2014 10:53 am

Re: Conditional check isn't working appropriately on Pro Tri

by eavery6156 on Tue Jul 09, 2019 12:20 am

@adafruit_support_bill I thought about that. I don't see any change when my multimeter is connected but it might happen extremely quickly and latency in the multimeter might not be sensitive enough go pick it up.

For each iteration of the loop function, I could write to serial with the line level reading (digital, since it's on a digital GPIO).

What do you think? What's a good way to approach this?

eavery6156
 
Posts: 25
Joined: Thu Jul 31, 2014 10:53 am

Re: Conditional check isn't working appropriately on Pro Tri

by adafruit_support_bill on Tue Jul 09, 2019 5:47 am

Most multimeters average readings over several hundred milliseconds. So they are not great at detecting momentary peaks.

Serial output in your loop would probably catch it. Just keep the output short - or use a high baud-rate so you are not limited by the serial transmit speed.

Another approach would be to use the on-board LED attached to pin 13 as a visual indicator. This code should give you a visible light pulse when the fault pin goes low:

Code: Select all | TOGGLE FULL SIZE
void loop()
{
   if (digitalRead(flt) == LOW)
   {
      digitalWrite(13, HIGH);
   }
   else
   {
      digitalWrite(13, LOW);
   }
}

adafruit_support_bill
 
Posts: 74376
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.