Oddness driving motors with Orangutan / Baby-O

I think I may have a problem with my Orangutan, but I’m not sure.

In testing out some interrupt-based PWM code on my Orangutan, I’ve had wildly asymmetric behavior forward and backward. The interrupt-based code was supposed to fix the asymmetry, so that struck me as odd. Today I tried just turning the input pins to the H-bridges on and off, and the asymmetry is still there.

The kicker was when I re-ran both sets of code on my Baby-O. Completely symmetric behavior in both cases.

Sooo… I know it’s possible to blow an H-bridge so it’ll go in one direction and not the other. But it’s as if it goes fine in one direction and erratically in the other.

Any chance I’ve damaged the H-bridge chip so the thermal cut-out keeps kicking in or something when I go in one particular direction?

Better yet, any tests I can do on the H-bridge to find out if I’ve damaged it?

And since I’m a pessimist, assuming I did damage it, any chance I can get it repaired? Hate to have to replace the whole Orangutan for this.

Thanks,

Tom

Since they share components and are wired the same, the only other thing I can think of that might make H-bridge code work on your Baby-O but not your big O would be the external resonator. If you switch the fuses in the baby O to use the internal clock, does it still work?

Also, could you post your code? I only have a Mega8 Orangutan at the moment but I could test it and see.

If your h-bridge (and only your h-bridge) is busted, you could conceivably replace it yourself, if you want to get into surface-mounting. After a quick check Jameco and Digikey don’t seem to stock these, but if you can get a single replacement and a nice fine-tip low-temp soldering iron it’s not a huge leap from through-pin soldering.

Radio Shack stocks some very nice thin silver bearing solder, but the real trick is in de-soldering the bum chip. With the SOIC chip package you can just fit a loop of wire-wrap wire (28-30) under a single foot of the chip. With the iron temperature set fairly low (you might check the component datasheet for limits) heat the foot and pull it up with the wire. Repeat 13 more times and the chip is off. There will probably be enough solder left on the pads for the new bridge, but you might want to pre-tin the feet of the replacement chip.

Alternatively you could look on the bright side. An Orangutan with no h-bridge is an Orangutan with four extra I/O lines!

-Adam

Argh! Sorry for the very late reply on this, Adam.

The short answer is I still have an Orangutan without the four extra I/O lines. :wink: The longer answer is I talked to Jan on the phone, and he was kind enough to help me out. I sent my Orangutan back for repair, and picked it up from the post office yesterday. (Turns out it had been misplaced at the post office, and had actually been there for a whole week. Ah well… I can’t gripe too much.)

Anyhoo, here’s the code I was running:

// The Orangutan is an 8MHz device

#define F_CPU 8000000UL

// The Baby-Orangutan is a 20MHz device
// So is the Orangutan-X2

// #define F_CPU 20000000UL


#include <avr/io.h>

#include <util/delay.h>


// Initialize our relay-style routines for our motors:
void motor_init() 
{
	// Set up the data direction registers so our four control
	// pins are outputs:

	DDRB |= (1 << PB1) | (1 << PB2); 
	DDRD |= (1 << PD5) | (1 << PD6); 

	// Set both motors to coast (all four pins low)
	PORTB &= ~(1 << PB1);
	PORTB &= ~(1 << PB2);
	PORTD &= ~(1 << PD5);
	PORTD &= ~(1 << PD6);
}


// Motor B uses PD2 and PD6:
void motor_a_fwd(void)
{
	PORTB |=  (1 << PB2);	// IN3=1
	PORTD &= ~(1 << PD6);	// IN4=0
}

// Motor B uses PB1 and PD5:
void motor_b_fwd(void)
{
	PORTB |=  (1 << PB1);	// IN1=1
	PORTD &= ~(1 << PD5);	// IN2=0
}

void motor_a_rev(void)
{
	PORTB &= ~(1 << PB2);	// IN3=0
	PORTD |=  (1 << PD6);	// IN4=1
}

void motor_b_rev(void)
{
	PORTB &= ~(1 << PB1);	// IN1=0
	PORTD |=  (1 << PD5);	// IN2=1
}

void motor_a_coast(void)
{
	PORTB &= ~(1 << PB2);	// IN3=0
	PORTD &= ~(1 << PD6);	// IN4=0
}

void motor_b_coast(void)
{
	PORTB &= ~(1 << PB1);	// IN1=0
	PORTD &= ~(1 << PD5);	// IN2=0
}

void motor_a_brake(void)
{
	PORTB |=  (1 << PB2);	// IN3=1
	PORTD |=  (1 << PD6);	// IN4=1
}

void motor_b_brake(void)
{
	PORTB |=  (1 << PB1);	// IN1=1
	PORTD |=  (1 << PD5);	// IN2=1
}


// Delay for N seconds
void delay_sec(unsigned char sec)
{
	unsigned int cycles;

	// Delay 25ms at a time (38.4ms is the most we can delay with a
	// 20MHz processor, unfortunately.  See the delay.h include file
	// for more info.)

	for(cycles = 0; cycles < (sec * 40); cycles ++)
	{
		_delay_ms(25);
	}
}


// And now for our main routine:
int main(void)
{

	// Initialize the relay motor routines:

	motor_init();

	// Motors are stopped when we initialize them, so there's
	// no need to do that after the init routine.

	// The endless loop

	for(;;)
	{
		// Both motors forward
		motor_a_fwd();
		motor_b_fwd();
		delay_sec(2);

		// Coast to a stop
		motor_a_coast();
		motor_b_coast();
		delay_sec(2);

		// Both motors reverse
		motor_a_rev();
		motor_b_rev();
		delay_sec(2);

		// Coast to a stop
		motor_a_coast();
		motor_b_coast();
		delay_sec(2);

	}

	// We never get here, but return a zero if we ever do.
	return(0);
}

Not much to it, really. No PWM, no timers, no nuthin’. Just on and off.

Tom

Silly post office. The Campus mail system here sits on USPS materials for an extra day at least, and usually more like 3 or 4.

is your Orangutan behaving better with the the new H-Bridge and this code, or are you still having the same problems?

-Adam

Yes, as I’ll bet you suspected, your posted code works fine with my Orangutan (although it did make me notice that one of my Baby-O H bridges is now kaput, most likely due to the soldering iron tip crater I put in it…). Did you have a wonky H-bridge to start, or do you think you did something bad to it?

-Adam

Oh no, I’m almost certain I did something goofy to it. My workbench got a little too crowded with different projects, making accidents a little too easy. I’ve since cleaned things up and neatened up all the breadboard wiring I had going on.

I still haven’t been able to test it, unfortunately. I’m down sick, drugged up, and have the attention span of a gnat at the moment. I don’t trust myself with electronics for now. Hoping things improve by the middle of the week.

Tom

Good news is the new H-bridge works beautifully in both directions. (Finally had a chance to sit down and test it.) Big big mahalos to Jan and company!

Tom