School Project

Plugging in a warm freshly charged battery would probably be the stupid mistake that I made in haste. Sweet. So either I use a regulator, or a weaker battery, or I just wait a little while before plugging in the battery I have, which I’ve been charging on a quick charger at 1.8A, if that makes a difference.

I added the while(1) and return(0) to the code and it now tells me that my delay(1000) is not a recognized command, so I made it delayms(1000) but it says the same thing. so I’m not sure if I’m now screwing up the time delay command.

I’ll look into that regulator form radioshack but for the time and trouble it might be easier to go with one of the new ones I ordered and set this aside for another time.

I’ll keep you posted once the new one gets here.

I wouldn’t call that a mistake at all, the user’s guide specifically says “a 5- to 10-cell NiCd or NiMH battery pack is a good choice”. That’s just my theory of what happened, if you’ve got a voltmeter you can use you might want to take a peak at the fresh-off-the-charger voltage of your pack.

In the meantime, if you want to use one of the Pololu library delay functions, they’re described here.

-Adam

I currently have a 6 volt regulator going from the battery to the servo power and ground. If I were to relocate it to the “beginning” of my system and have the battery be limited to 6V on its way to all three power inputs, (the servo, servo controller, and baby ) would I run the risk of burning something out?

I figure the only thing that could pose a potential threat is when I run all 4 servos at the same time, each with a (relatively) light load and simply try to pull power that isn’t there. My understanding is that I don’t need a regulator for each servo, That regulating the voltage input for all the servos in one regulator would be enough not to cause problems. And since 6 volt limit is within range of the servo controller and baby, and they use so little anyway, it should be fine.

Any thoughts on the matter? could this be the perfect fail safe? or just the perfect fail?

Your 6V regulator can source plenty of power for the servos, you should totally run a line from the 6V output to the VIN pin of your new Baby O. That’s a great idea!

-Adam

I’ll get to dealing with that later today, and my babies should be in the mail. yay!

I was thinking about my servo setup and was wondering if it would be easier to buy a servo reverser like this or this and keep my code simple. Or to stick with controlling everything via the C code and reverse the servo in the program.

I bring it up because I need to run two pairs of servos that face each other so one “side” of the rig will run in reverse.

I did some reading up on it and a lot of people (mostly RC plane forums) say they are terrible and tend to cause heat and noticeable lag. Any experience with this?

Because it would be so much easier for me to just order two reversers and only have to write the code for two sensors and two servos then for two sensors and four servos.

I’ll get to dealing with that later today, and my babies should be in the mail. yay!

I was thinking about my servo setup and was wondering if it would be easier to buy a servo reverser like this or this and keep my code simple. Or to stick with controlling everything via the C code and reverse the servo in the program.

I bring it up because I need to run two pairs of servos that face each other so one “side” of the rig will run in reverse.

I did some reading up on it and a lot of people (mostly RC plane forums) say they are terrible and tend to cause heat and noticeable lag. Any experience with this?

Because it would be so much easier for me to just order two reversers and only have to write the code for two sensors and two servos then for two sensors and four servos.

I have never used a servo reverser, in my opinion they’re pretty pointless. I think you’ll find that once you’ve got one servo working in your code you’ll have an easy time getting the pairs working. You could write a new function that takes two servo numbers and moves them together, but mirrored, by calling the functions you already have. Off the top of my head it would look something like this added to your current code:

void mirror(unsigned char servo, unsigned char servoMirror, unsigned int angle){
	put(servo,angle);
	put(servoMirror,(5500-angle+500));
}

You could also use some of the other command types in Pololu mode, which let you set the neutral position of a particular servo and the direction it rotates, then send the servo pair the same position. This is getting a little more deeply into the Pololu protocol though, but it would make sense, say, if you were using a really weak microcontroller, and you wanted to have the servo controller manage individual servo calibrations so you didn’t have to keep track of them throughout your code.

Finally there’s an electromechanical solution as well. You can run two servos off of a single signal line, and they will move together. To reverse the direction that one rotates in response to a particular signal you can open up the servo and reverse the motor polarity connections and two of the three potentiometer wires. Since you’ve got servo connections to spare, I still think the software solution is the simplest. I’ve only done this for a project using a radio controller, when I wanted one joystick to actuate multiple servos together in opposing directions.

Anyway, I hope that gives you some ideas.

-Adam

Its a bittersweet day for me that I actually got a little excited when I saw the mirror code. Everywhere I looked the advice was similar: if it can be done in code, that that’s usually the best way to do it. I’ve heard about opening up the servo and switching some wires around, but the serviceability factor needs to be along the lines of hot swapping components in a matter of minutes, so needed to custom solder some servos would be a problem. I think the mirror code will serve me well if I can figure out how to use it correctly.

I got my babies in the mail today! I plan on making the changes we discussed earlier and being back up to speed by the end of today.

We’ll change the document to give more of a warning about a well-charged 10-cell pack.

- Jan

I went ahead and emailed pololu regarding the baby-o and seeing if i cant get it repaired or replaced. The new one is up and running. but I still can’t get the mirror command to work. I might have gotten it by accident but I must have changed something and now I don’t know what to do about it. Right now the code is like this

        #define F_CPU 20000000//Baby Orangutan CPU clock
        #define BAUD 9600//baud rate for UART
        #define MYUBRR 129//(F_CPU/16/BAUD-1)//baud rate variable for UART hardware

        #include <pololu/orangutan.h>
        #include <avr/io.h>


       
        void USART_Init(unsigned int ubrr){//Initialize USART hardware & settings for Serial Radio
           UBRR0H=(unsigned char)(ubrr>>8);//set buad rate
           UBRR0L=(unsigned char) ubrr;
           UCSR0B=(1<<TXEN0);//enable transmitter
           UCSR0C=(3<<UCSZ00);//Set frame format for 8bit with 1 stop
        }

     
        void USART_Trans (unsigned char data){//Transmit a byte of data over USART
           while(!(UCSR0A&(1<<UDRE0)));//wait for transmition to complete
           UDR0=data;
       }
       
       
       void put(unsigned char servo, unsigned int angle){
           //servo is the servo number (typically 0-7)
           //angle is the absolute position from 500 to 5500

           //Send a Pololu Protocol command
           USART_Trans(0x80); //start byte
           USART_Trans(0x01); //device id
           USART_Trans(0x04); //command number
           USART_Trans(servo); //servo number
           //Convert the angle data into two 7-bit bytes
           USART_Trans(((angle>>7)&0x3f)); //data1
           USART_Trans((angle&0x7f)); //data2
        }
       
       
       
        void servoOff(unsigned char servo){//turns off a servo
           //(servo will go limp until next position command)
           //servo is the servo number (typically 0-7)

           //Send a Pololu Protocol command
           USART_Trans(0x80);//start byte
           USART_Trans(0x01);//device id
           USART_Trans(0x00);//command number
           USART_Trans(servo);//servo number
           USART_Trans(0x0f);//data1 (turn servo off, keep full range)
        }

        void servoSetSpeed(unsigned char servo, unsigned char speedcmd){
           //servo is the servo number (typically 0-7)
           //speed is servo speed (1=slowest, 127=fastest)
           //set speed to zero to turn off speed limiting
           
           speedcmd=speedcmd&0x7f;//take only lower 7 bits of the speed
           
           //Send a Pololu Protocol command
           USART_Trans(0x80);//start byte
           USART_Trans(0x01);//device id
           USART_Trans(0x01);//command number
           USART_Trans(servo);//servo number
           USART_Trans(speedcmd);//data1
       
          }
     
	int main()
    {
	
	USART_Init(MYUBRR);
		
	while(1)
	{

       servoSetSpeed(0,0x00);
       servoSetSpeed(1,0x00);

	    void mirror(unsigned char servo, unsigned char servoMirror, unsigned int angle)
		{
	   	put(servo,angle);
      	put(servoMirror,(5500-angle+500));
	   }
	     
    	delay(1000);

       put(0, 1500);
       put(1, 1500);
             
		delay(1000);
       
       put(0, 3000);
       put(1, 3000);

	    delay(1000);
       
       put(0, 4450);
       put(1, 4450);

	   	delay(1000);
       
       put(0, 3000);
       put(1, 3000);
	  	
    return(0);
	}
	}

Later I’m going to comment out the return(0); so the code runs in an infinite loop so that I can see how long the battery will last under constant use. (I have a requirement of 45minutes to 1 hour of operation) I wont be running under load, and I will be running four servos with the same command.

How should I be using the mirror command?
like this:

oid mirror(unsigned char servo, unsigned char servoMirror, unsigned int angle)
		{
	   	put(0x00,1500);
      	put(0x01,(5500-1500+500));
	   }

or like this:

oid mirror(unsigned char servo, unsigned char servoMirror, unsigned int angle)
		{
	   	put(servo,angle);
      	put(servoMirror,(5500-angle+500));
	   
       put(0, 1500);
       put(1, 1500);
               }

You can simplify your code a bit by using the code I posted earlier as a function: move it above the main function, then call it by name whenever you want to use it:

#define F_CPU 20000000//Baby Orangutan CPU clock
#define BAUD 9600//baud rate for UART
#define MYUBRR 129//(F_CPU/16/BAUD-1)//baud rate variable for UART hardware

#include <pololu/orangutan.h>
#include <avr/io.h>


void USART_Init(unsigned int ubrr){//Initialize USART hardware & settings for Serial Radio
   UBRR0H=(unsigned char)(ubrr>>8);//set buad rate
   UBRR0L=(unsigned char) ubrr;
   UCSR0B=(1<<TXEN0);//enable transmitter
   UCSR0C=(3<<UCSZ00);//Set frame format for 8bit with 1 stop
}


void USART_Trans (unsigned char data){//Transmit a byte of data over USART
   while(!(UCSR0A&(1<<UDRE0)));//wait for transmition to complete
   UDR0=data;
}


void put(unsigned char servo, unsigned int angle){
   //servo is the servo number (typically 0-7)
   //angle is the absolute position from 500 to 5500

   //Send a Pololu Protocol command
   USART_Trans(0x80); //start byte
   USART_Trans(0x01); //device id
   USART_Trans(0x04); //command number
   USART_Trans(servo); //servo number
   //Convert the angle data into two 7-bit bytes
   USART_Trans(((angle>>7)&0x3f)); //data1
   USART_Trans((angle&0x7f)); //data2
}


void servoOff(unsigned char servo){//turns off a servo
   //(servo will go limp until next position command)
   //servo is the servo number (typically 0-7)

   //Send a Pololu Protocol command
   USART_Trans(0x80);//start byte
   USART_Trans(0x01);//device id
   USART_Trans(0x00);//command number
   USART_Trans(servo);//servo number
   USART_Trans(0x0f);//data1 (turn servo off, keep full range)
}


void servoSetSpeed(unsigned char servo, unsigned char speedcmd){
   //servo is the servo number (typically 0-7)
   //speed is servo speed (1=slowest, 127=fastest)
   //set speed to zero to turn off speed limiting
   
   speedcmd=speedcmd&0x7f;//take only lower 7 bits of the speed
   
   //Send a Pololu Protocol command
   USART_Trans(0x80);//start byte
   USART_Trans(0x01);//device id
   USART_Trans(0x01);//command number
   USART_Trans(servo);//servo number
   USART_Trans(speedcmd);//data1

  }


void mirror(unsigned char servo, unsigned char servoMirror, unsigned int angle){
   put(servo,angle);
   put(servoMirror,(6000-angle));
}


int main(){

	USART_Init(MYUBRR);

	servoSetSpeed(0,0x00);
	servoSetSpeed(1,0x00);

	while(1)
	{

	delay(1000);

	mirror(0,1,1500);
		 
	delay(1000);

	mirror(0,1,3000);

	delay(1000);

	mirror(0,1,4450);

	delay(1000);

	mirror(0,1,3000);
	
	return(0);
	}
}

If you’re not changing the servo speed, you only need to call the servoSetSpeed function once for each servo you want to control, so I moved those function calls out of your while loop. Setting the speed to 0x00 doesn’t make any difference anyway. I also changed the formula inside the mirror function a little, since 5500-X+500=6000-X (not sure why that wasn’t apparent to me earlier).

And doesn’t the code run in an infinite loop anyway? The return(0) line breaks out of the while(1) loop, but then I would think that the whole code would start over.

Glad to hear your new Baby O is up and running!

-Adam

That worked out great. Thanks. I spent some time last night figuring out my mirrored range of values, since the servos respond to something like 1500 - 4450, so not every value worked. I think I’m limited to 1550-4450 now which makes sense. Also I ran an “endurance” test last night to see how long the battery would last. I ran four servos continuously and monitored the time with a time laps video. After 2 hours, I gave up and turned everything off. Then it only died an hour after that when I went back to coding and testing. So almost 3 hours of continuous use. That triples my required time. My only problem was that it was then that I found out my 6V regulator was only rated for 8.4V max input. Well, I’m running a 12V battery through it. Lets just say that over a 2 hour period (and probably long before that) it felt like a few degrees below on-fire.

My solution is to simply remove 3 cells form the 10 cell battery, and cut it down to 8.4 V. if the ratio is linear then 15 minutes per cell (2.5 hrs divide 10 cells) will be 1.75 hrs per 7 cells.

All I have left to do is incorporate the analog1 sample code that I got the bend sensors to work for and figure out how to stick it in this code to work. I figure I’ll need some true/false if statements to limit the range of the bend sensor so it doesn’t register values that will send my servo somewhere it doesn’t belong.

And after all the work for the mirror command, I found our linkages were not symmetrical enough and I ended up with a lot of binding, twisting, and anger servos, both fighting for position. For now we took out one, which seems faster,quieter,less drain on battery (as if that was an issue) and can handle the load without even trying. I found that when the servo is holding a position it is very loud, I know its because its on and fighting to hold a load at a set position against gravity, but is there any way to dampen the sound?

Sorry to hear that the two-servos on one linkage didn’t work out. I think when you do that for long model airplane flaps you usually have a little compliance in the flap material, or a flexible coupling between the servos and the shaft. But if you can get away with just one servo doing the work of two, that’s probably the simplest solution.

I forget if you posted this already, but what kind of servos are you using? Is the bare servo with nothing connected to it loud, or is it holding some heavy load in place? If your servos are straining under the load they’re holding, the only way I know of to quiet them down is to get better servos with a higher torque-rating.

Taking a few cells out of your battery pack sounds like a good plan, will your charger work with 7 cell packs as well? And from the product description I wasn’t sure if your big regulator was linear or switching, but if it is a linear regulator it has to dissipate a lot of energy as heat to drop the output voltage, all of which is wasted. I wouldn’t be surprised if you still got close to three hours of use out of your 7 cell pack, sine the regulator will be wasting much less energy to drop the voltage.

-Adam

I’m using Hobbico CS-170 titanium geared ultra torque dual BB. 250 oz-in @ 0.19sec 4.8V. and 333 oz-@0.15sec 6V. They are way overkill for the load (about 3 lbs max), but with the linkages the transmission of force makes a difference (but not much) I think they are just noisy in general and the linkages are all direct, so it might be trying to twist a little too and we might not notice.

The charger says it will work for anything >900 mAh, and anything in between 6 -12V. One of my group members suggested running 5 of the 10 cells in parallel and knocking down the voltage to 6V and doubling our current to around 3200mAh which sounds like the best option.

I took the shrink material off the battery and it seems the connections were all spot welded. I saw one solution online which involved snipping all of the connection and soldering wires to the ends were I need them instead, then wrapping up the battery again.

We are going to run some testing today and make a final decision whether to use one or two servos. Now that I understand that mirror command, it makes no difference to me how many we use.

Yowzer, those are some nice heavy duty servos!

You’ll probably find you have a hard time soldering directly to the NiMH cells (although it can be done), plus heat is really bad for them, which is why those spot-welded tabs are generally used. Your best bet is to cut the tabs in the middle, then try to solder to whats left of them.

In general I would recommend against hooking up batteries to charge/discharge in parallel. When you get a battery pack with cells in parallel from a manufacturer, those cells have generally been “matched,” or paired for similar charge/discharge characteristics. They also get put together when they’re brand new, and stay in parallel for every charge/discharge, so they tend to wear and age together. The problem with putting used and unmatched cells together in parallel is that they will charge and discharge at different rates. As the voltage on one gets a little higher than the other, you’ll have current flowing just between the two cells. This wastes a little energy as heat, but more importantly it wears out the battery pack significantly more quickly.

Now, that isn’t to say I haven’t done it. You do get a longer lasting battery pack for a while. With NiMH batteries it would work fine, but with some other battery chemicals like Lithium Ion or Lithium Polymer it can be downright dangerous though. Keep in mind that as long as the input voltage is higher than the regulator’s cutoff voltage, you should still get close to the same runtime out of a single-series pack.

Another thing you might consider doing is cutting this pack apart into two separate 5-cell packs. That way you can charge one while running down the other, and you won’t ever be stuck with one big dead pack when you need to run your project!

-Adam

I like that idea, worst case scenario is it doesn’t last as long as I need it too (which, like you said, it should). I have two of these batteries laying around just for that reason, charging and draining back and forth. I want to leave one battery unmolested in case something bad happens, but as long as I have one plug and 10 cells, I can make at least one battery of some configuration.

Like you said, it’s probably easiest for me to start with one 5 cell series and then add more if I need them.

So I managed to get one 5 cell battery done and working. I tried to get back to working on the bend sensor code that I need in order to get the servos to work properly. I checked out the code in this thread. I tried incorporating it into what I currently had and it compiled nicely but the bend sensors are not returning any that actually moves the servo, and half the time when I try to program the controller I get an “fatal error” or “baud rate” error LEDs on the servo controller. The other half of the time I get no errors. Hopefully its just something stupid that I missed, or the values that I used for the bend sensor might be way off. On that note I still haven’t figured out how to do any real-time debuging or datalogging so that I can actually determine the values of the bend sensor. Thanks in advance for any light you can shed on this.

    #define F_CPU 20000000//Baby Orangutan CPU clock
    #define BAUD 9600//baud rate for UART
    #define MYUBRR 129//(F_CPU/16/BAUD-1)//baud rate variable for UART hardware

    #include <pololu/orangutan.h>
    #include <avr/io.h>



    void USART_Init(unsigned int ubrr){//Initialize USART hardware & settings for Serial Radio
       UBRR0H=(unsigned char)(ubrr>>8);//set buad rate
       UBRR0L=(unsigned char) ubrr;
       UCSR0B=(1<<TXEN0);//enable transmitter
       UCSR0C=(3<<UCSZ00);//Set frame format for 8bit with 1 stop
    }


    void USART_Trans (unsigned char data){//Transmit a byte of data over USART
       while(!(UCSR0A&(1<<UDRE0)));//wait for transmition to complete
       UDR0=data;
    }


    void put(unsigned char servo, unsigned int angle){
       //servo is the servo number (typically 0-7)
       //angle is the absolute position from 500 to 5500

       //Send a Pololu Protocol command
       USART_Trans(0x80); //start byte
       USART_Trans(0x01); //device id
       USART_Trans(0x04); //command number
       USART_Trans(servo); //servo number
       //Convert the angle data into two 7-bit bytes
       USART_Trans(((angle>>7)&0x3f)); //data1
       USART_Trans((angle&0x7f)); //data2
    }


    void servoOff(unsigned char servo){//turns off a servo
       //(servo will go limp until next position command)
       //servo is the servo number (typically 0-7)

       //Send a Pololu Protocol command
       USART_Trans(0x80);//start byte
       USART_Trans(0x01);//device id
       USART_Trans(0x00);//command number
       USART_Trans(servo);//servo number
       USART_Trans(0x0f);//data1 (turn servo off, keep full range)
    }


    void servoSetSpeed(unsigned char servo, unsigned char speedcmd){
       //servo is the servo number (typically 0-7)
       //speed is servo speed (1=slowest, 127=fastest)
       //set speed to zero to turn off speed limiting
       
       speedcmd=speedcmd&0x7f;//take only lower 7 bits of the speed
       
       //Send a Pololu Protocol command
       USART_Trans(0x80);//start byte
       USART_Trans(0x01);//device id
       USART_Trans(0x01);//command number
       USART_Trans(servo);//servo number
       USART_Trans(speedcmd);//data1

      }


    void mirror(unsigned char servo, unsigned char servoMirror, unsigned int angle){
       put(servo,angle);
       put(servoMirror,(6000-angle));
    }

	unsigned int val1;
	unsigned int bend1;

    int main()
	{

		PORTC=0x00;
		set_analog_mode(MODE_8_BIT);
		start_analog_conversion(PORTC=0x00);
	

       	USART_Init(MYUBRR);

       	servoSetSpeed(0,0);
       	servoSetSpeed(1,0);
	
	   // mouth center = 2300
	   // mouth closed = 1700
	   // mouth open = 4000

		mirror(0,1,1700);	//close mouth
		delay(800);

		mirror(0,1,4000);	//open mouth
		delay(800);
		
		mirror(0,1,1700);	//start mouth closed
		

		while(1)
		{

		val1 = analog_read(PORTC=0x00);
	    	
		bend1 = ((val1*4000)/255);


		if(bend1 > 4000)  //stop once fully open
		{			
			bend1 = 4000;
		}
		
		if(bend1 < 1700)	//stop once fully closed
		{
			bend1 = 1700;
		}

	
		mirror(0,1,bend1);	//set mouth angle as val1	
		

		}
	   return(0);
   }

Yay 5-cell. Now you can wire power straight to your Baby-O, no problem!

Real-time debugging is quite handy. Serial debugging is probably simplest way to go on the Baby Orangutan, but the logic-level serial signals generated by the Baby O are incompatible with computer serial ports, which use an inverted serial signal at much higher voltages. To connect your Baby O to a computer for debugging you would need a USB or RS-232 to TTL serial adapter. You could also do something creative like connect LEDs and resistors to each pin of a port, and light them up to display 8-bit numbers in binary (I’ve totally done it). You could even just use the built-in LED to do a simple check, having it light up when your sensor returns greater than a certain value. This LED happens to be on the serial transmit line, so you wouldn’t be able to manipulate it while using the USART. On the other hand, you have your servo controller and servos working, which could be a decent debugging tool itself.

But first for a little offline debugging of your code. The “PORTC=0x00;” line isn’t necessary, but it also isn’t hurting anything. The line:

val1 = analog_read(PORTC=0x00);

is a little odd, you don’t need to set the PORTC register at all, just specify the number of the analog channel you want to read from. If you’re wiring hasn’t changed recently, you have your analog sensors connected to PC0, and ADC6, so you would get readings from them by calling:

val1 = analog_read(0);//Read PC0
val1 = analog_read(6);//Read AD6

In any case, the line as written should be checking the analog input value on PC0 anyway.

Another problem I can spot is your scaling function:

bend1 = ((val1*4000)/255);

Val1 is an unsigned int, which on an AVR can have values between 0 and 65535 (2^16-1). Since you just loaded it with a MODE-8-BIT ADC value, it is currently set to something between 0 and 254, which you are trying to scale to a value between 0 and 4000. The problem is that when you multiply val1 by 4000, the immediate result may be more than 65535, in which case you would loose all but the remainder. Since you’re dividing the result of that multiplication by 255, your result will always be somewhere between 0 and 257. For example, lets say val1=255:
Normaly: (2554000)/255=(1020000)/255=4000
But since the intermediate results are limited to 16 bit values: (255
4000)/255=(1020000)/255=(36960)/255=144

There’s a quick remedy for this, however, called type casting. Essentially its telling the AVR to treat (cast) a variable as if it were another type of variable. If you write the formula this way, the AVR will allocate 32 bits (0 to 4294967295) for the intermediate values of the calculation:

bend1 = (((long int)val1*4000)/255);

The only other possible problem I see is that your while(1) loop will be running very quickly. Servo position can only be updated every 20ms anyway, so you might consider adding a delay that long or longer inside your loop, just to give the servo controller some time to react to what you’ve sent it before sending it another command.

-Adam

It alive! It’s alive! It works, its a little jittery and the signals are large enough to incur the if statements setting the max and min, which also work. I added a delay(30); right after the mirror(0,1,bend1); command which seemed to help. One problem I encountered immediately was that when the sensor bends too fast I get baud rate leds on the servo controller and the whole thing fails on me. I have to turn it off and back on to get it working again. This is bad because I need this thing to go as fast as possible, which it was doing fine until I went too fast with the bends. If I have time later I’ll try and set some delays on the bend sensor to only take values every delay(30); Also when the bend sensor is unbend it registers a value less than 1700, which I expected but when it hits the “if” loop I get a done of jitter, can I correct this in the scaling function? If so I can spend some time playing with the numbers until I get something that works.

Also The sensors I bought were advertised as bi-directional but for now they read the same values in both directions. I was hoping one side would be negative and the other would be positive in values since my second bend sensor needs control a servo that will start at a set neutral position and then travel “up” and “down” as the bend sensor bend up and down.

I’ll do some more research and see if I ended up buying the right sensor. these are the ones I bought. The first one the FLX-01. I see now the second one on the list has an increase and decrease in resistance, which is probably the one I should have gotten.

Can I still make these work?

Awesome! Glad to hear that its alive and kicking!

Yeah, looking at the website I agree, if the flex sensor you have does the same thing (decreases resistance) when you bend it in either direction there really isn’t a way for your microcontroller to tell which way you’re bending it. You can scale and shift the values though, so that unbent is at one end of the servo range, and fully bent is at the other. Or you could do something really sneaky like mounting a microswitch underneath the sensor, such that it gets pressed by the bend sensor when you move it in one direction. Let me know if you want to try this, it’s also a good idea to use some smaller resistors (1K or 2K) in line with the switches.

As for the servo jitter, you’re still updating the servo position 30 times a second, which is probably more than you need to. You might try longer delays, or averaging several readings, or using 10-bit mode on the ADC (results 0-1023) just to give yourself more possible positions, or some combination thereof.

As for the servo controller being unhappy with your serial commands, I doubt it actually has anything to do with the software. With those big beefy servomotors my guess is that you’re getting electrical noise on the data lines, either directly (conducted over common wires) or indirectly (electrical charges induced through the air). I would suggest you try running everything the same way, but with the servos unplugged. Can you still get the servo controller baud-rate LEDs to come on? If not it’s electrical noise.

If this is the case, you could try moving the power connection for the servo controller electronics and the Baby O back to the battery side of your big servo power regulator (if they aren’t there already) and adding capacitors between power and ground, on the servo power bus and/or at the power input pins of your servo controller and Baby-O. Here’s a little more info.

-Adam