Quadruped controlled by quadruped

Status
Not open for further replies.

clawsoon

Member
I'm designing my first Teensy project of any complexity, and I would love to get feedback before I make any foreseeable mistakes. It's a quadruped robot controlled by a small imitation of itself: Robot has four legs with a hip and a knee attached to servos; controller has four legs with a hip and a knee attached to resistive position sensors. At the end of each leg will be a weapon motor, controlled by a corresponding switch. The goal is to build an antweight combat robot.

Here's the controller schematic:

quadruped-controller.png

The wires from the controller to the pots and switches will be about 10cm-30cm (4"-12") long.

Here's the robot schematic:

quadruped-actuator.png

The wires from the battery/controller to the servos and DC motors will be about 50cm-150cm (20"-60") long.

I expect the DC weapon motors to be electrically noisy. They draw a fair amount of current for a tiny motor (18A at stall) and the brushes throw off lots of sparks. They're one of the models of 130-size motors used for Nerf gun modifications.

Have I made any obvious mistakes in the schematic?

Are there any subtle problems I might run into with these circuits?

I'm a bit worried that the position sensors and the wires to them will pick up noise, causing jitter in the signal and corresponding jitter in the servo positioning. Should I be worried about that? If so, is there anything I can do about it?

The voltage regulator on the robot is a switching regulator. If I need to add an external regulator to the controller, am I correct to assume that I should use a linear regulator instead of a switching regulator in order to get more consistent signals from the position sensors than a switching regulator would provide?

Is the number of sensors and motors involved too much for a single Teensy? Should I divide the workload among a couple of MCUs?

All thoughts and suggestions welcome, including advice on making the schematic more presentable. It's the first one I've made for public consumption, so I'm sure there are things that could be improved on in it from both an electronic and an aesthetic point of view.

Thanks!
 
Hi There,

this is quite a general post, so I'll throw some general pointers.

When you use a voltage/pot combo like this, any noise present on the power supply will make it's way through to the analog input. If this poses a problem, throw some decoupling capacitance on the inputs. 100nf is a go-to value, not that I've done any maths, but it's a good place to start. You also want capacitance, bascially everywhere. Every motor should have a decent one, and every chip. You can have too much capacitance, but this max value should be on the data sheet for whatever regualtors you use.

PWM is pretty resistant to noise, so I wouldn't be concerned about the servos. Having enough noise to cause enough jitter to meaningfully present on the servo would be pretty crazy.

Yes a switching regulator will add more noise to the system, but with some beefy brushed motors in the corner, switching noise is unlikely to be significant. I assume this is a battery powered robot, so you'll probably want the effiency of a switched regulator. One mistake in the schematic, you can't enable a regulator by a micro controller it's supplying. You probably want to either wire this to a switch or tie it permenantly on. Sending the power good signal to the micro is also a bit redundant, becuase if the micro is reading it, then the power must be good. Wire it to an LED would be my suggestion.

A13 I dont think has digital capability.

The teensy will be fine with this load, though that's more code-dependant than hardware.

If you'd like to make the schemtic prettier, consider using labels instead of wires. The button is the black 'A' above a green line, or hotkey L. This makes the schematic easier to read, and makes following specific connections easier. You could either use sequential names Servo0, Servo1 ..., but I'd suggest "FrontRightKneeServo" "FrontRightAnkleServo". Add these names to the silkcreen if you print it.

Ed
 
PWM is pretty resistant to noise, so I wouldn't be concerned about the servos. Having enough noise to cause enough jitter to meaningfully present on the servo would be pretty crazy.

Thanks for all the suggestions! Hopefully in the next couple of weeks I'll be able to put together a new schematic incorporating them all.

About my jitter concern: I'm mostly thinking about the controller side picking up noise in the pots, which then sends "go forth and jitter!" commands to the servos. However, I don't want to filter out small, fast changes in signal, because I want the controls to be as sensitive as I can get them. I.e. I don't want tiny signal changes resulting from noise to lead to servo movement, but I do want tiny signal changes resulting from tiny position sensor movements to lead to servo movement.

This leads to a followup question: What are the tradeoffs in pot values for my position sensors?

From what I've read so far, I'm guessing:
- Higher resistance: More susceptible to noise, slower to charge up the ADC leading to slower sampling.
- Lower resistance: Higher power consumption.

Are there any other disadvantages of using lower resistance for my position sensors? Is there any other reason for me to go with a 10K or 100K position sensor instead of the 2.5K sensor?

Thanks again.
 
Oh, I see on the controller side, I'd understand being worried a bit about noise from the battery, but not elsewhere. I don't think I've ever seen enough noise on a teensy's ADC inputs to actually present a change in reading normally. I've got 20 pots lined up on a midi controller and I dont recall seeing anything. It's really unlikely to be a problem, and considering you can use bandwidth as low as 300Hz, go right ahead and filter if you're worried.

Thinking about it, you'd need a bananas amount of noise to cause a problem. Enough to actually be picked up by the relatively low-resolution DAC is one thing, but enough to cause a change in the servo position would be huge. If I recall the servo library takes 0-180, and I've never used a servo that gave me 1-degree steps (or I've never used one properly!).

You don't have a tradeoff so much as a pretty much anything will do situation. 2k5 is fine, if you want to go lower you can calculate the resulting resistance and figure out if it's sensible or not, or you can go higher. Pick the pot based on the 3D form that suits, or heck what you've got lying around!

That's not quite how it (ADC sampling with a capacitor) works, read a smidge more or ask again on monday :p
 
Oh, I see on the controller side, I'd understand being worried a bit about noise from the battery, but not elsewhere. I don't think I've ever seen enough noise on a teensy's ADC inputs to actually present a change in reading normally. I've got 20 pots lined up on a midi controller and I dont recall seeing anything. It's really unlikely to be a problem, and considering you can use bandwidth as low as 300Hz, go right ahead and filter if you're worried.

Good to know. The advice in your first reply about using capacitors to filter motor noise got me Googling and led me to this:

http://hydraraptor.blogspot.com/2007/09/dc-to-daylight.html

...in which a single motor similar to the ones I'm planning to use put out enough noise to mess with I2C signals and his wife's digital TV downstairs. The noise he was dealing with was in the MHz range, though, and like you say I'll be sampling in the hundreds of Hz range. I'm now thinking that if anything I should be worried about the effect of motor noise on the remote control signal and maybe follow some advice like this:

http://www.stefanv.com/rcstuff/qf200005.html

Thinking about it, you'd need a bananas amount of noise to cause a problem. Enough to actually be picked up by the relatively low-resolution DAC is one thing, but enough to cause a change in the servo position would be huge. If I recall the servo library takes 0-180, and I've never used a servo that gave me 1-degree steps (or I've never used one properly!).

You don't have a tradeoff so much as a pretty much anything will do situation. 2k5 is fine, if you want to go lower you can calculate the resulting resistance and figure out if it's sensible or not, or you can go higher. Pick the pot based on the 3D form that suits, or heck what you've got lying around!

That's not quite how it (ADC sampling with a capacitor) works, read a smidge more or ask again on monday :p

Aye, I definitely need to do more reading. Sometimes hard to fit in between full-time work, full-time fatherhood, and full-time laziness. :) My understanding so far is based on half-understanding comments like this one about charging time for an ADC's sampling capacitor:

https://forum.arduino.cc/index.php?topic=169000.msg1259098#msg1259098

Reading that comment again, I see that he's talking about delays of microseconds, which, like you say, is well below the threshold of anything I'll need to worry about.

The controls I'm planning will require some awkward hand movements, so I'm mostly basing my pot choices on low torque. That has led me to the Bourns 3382 series and the Alps RDC50 series.
 
Vin only accepts 3.6 to 5.5 V (there is NO additional LDO as with previous Teensies (3.2 - 3.6)
So connecting 2S LIPO (on controller) is calling for problems (distruction?). Add external dc/dc convertor to generate acceptable Vin (as with actuator circuit).
On dv24v22f3 you should check with chip id 3.3V on EN will enable the DC/DC converter.
On other products it is typically said to connect EN or /SD to input voltage (could not find a schematic for this one)
 
Vin only accepts 3.6 to 5.5 V (there is NO additional LDO as with previous Teensies (3.2 - 3.6)
So connecting 2S LIPO (on controller) is calling for problems (distruction?). Add external dc/dc convertor to generate acceptable Vin (as with actuator circuit).
On dv24v22f3 you should check with chip id 3.3V on EN will enable the DC/DC converter.
On other products it is typically said to connect EN or /SD to input voltage (could not find a schematic for this one)

I did pick the Teensy 3.2 for specifically that reason, after asking this question about input voltages the other day. Might be a good idea to have an external regulator anyway, as you're suggesting.

You're totally right about the EN pin, and I need to make that change.
 
Good to know. The advice in your first reply about using capacitors to filter motor noise got me Googling and led me to this:

http://hydraraptor.blogspot.com/2007/09/dc-to-daylight.html

...in which a single motor similar to the ones I'm planning to use put out enough noise to mess with I2C signals and his wife's digital TV downstairs. The noise he was dealing with was in the MHz range, though, and like you say I'll be sampling in the hundreds of Hz range. I'm now thinking that if anything I should be worried about the effect of motor noise on the remote control signal and maybe follow some advice like this:

http://www.stefanv.com/rcstuff/qf200005.html

Those both seem like good resources. I'd start with the 3- capacitor method in the second link, becuase it wont hurt. Inductors can also help, but if you get the tuning wrong you can make some problems worse. If you've got an oscilliscope you can just go through the same steps as those articles have

My understanding so far is based on half-understanding comments like this one about charging time for an ADC's sampling capacitor:

https://forum.arduino.cc/index.php?topic=169000.msg1259098#msg1259098

Reading that comment again, I see that he's talking about delays of microseconds, which, like you say, is well below the threshold of anything I'll need to worry about.

A lot of ADCs use a capacitor to "sample" the voltage that is being read, there are other methods (I think). This stops problems that can be caused by a signal that changes by a singificant amount while being read. You can imagine a capacitor is connected to the circuit, then disconnected. When disconnected the capacitor retains the voltage, which can then be used for the conversion. If a very high impedance source is used, in the Megaohms range, this can cause the capacitor to not have charged up fully and hence the error of the reading can be increased. I wouldn't be certain that adding a delay in would help, as the length of time the capacitor is connected to the signal (I assume) is controlled by the ADC hardware and isn't varible/ easily varible by code. Particularly becuase there are multiple Analog pins that are multiplxed onto the ADC, you might be delaying while connected to the wrong pin. One could try just reading the same pin twice, the idea being the second time will be more accurate having had twice the time to charge; but I wouldn't be suprised if as part of the process the capacitor is discharged. While interesting, this is somewhat moot because your resistances are down in the KOhm range! If you do find you've got noise on the Analog inputs there's plenty of ways to fix this in code later.
 
My controller schematic has all of my pots grounded to AGND. Does this mean my schematic is bad, and I should connect to GND instead?

I've come to that conclusion after reading this thread:

https://forum.pjrc.com/threads/45742-Proper-use-of-Teensy-3-x-AGND

...which says, "If you're measuring 'voltage between power rail and actual ground' using a resistive divider, you're going to be shorting AGND to GND ... Any current passing through AGND will cause your ADC Reference voltage to be inconsistent/noisy or change your low end range/gain of the ADC. ... If you want to have an AGND plane for all your analog stuff I suggest not connecting it to AGND on the Teensy, but connect it to GND in only one place."

Thanks.
 
So if you look at the teensy schematic (3.5 at least) you'll see AGND and GND are connected through a ferrite, and there's a circuit around this for the analog reference. Placing a pot between VDD and AGND will alter this circuit. Depending on the resistance present this will be anything from nothing to bad. A single 1Mohm probably wont do anything, but lower will start to give errors in readings (as voltage drops across the ferrite) and perhaps exceed it's current limit. Also, any noise in the POTs will be injected into AGND, particularly with the ferrite that will have a higher impedance to higher frequencies (greater voltage drop causing more noise).

Short version, yes use GND not AGND for that.
 
Team Monsoon, not only the "famous" battlebot but also "drizzle" antweight you wouldn't want to mess with.
 
Connecting the pots to agnd is probably the right choice. However, you want to reduce the amount of current into agnd. With your current pots, you're sending 3.3/(2500/12) amps, or about 16 milliamps into agnd, constantly. That's pretty high. I would recommend using 10 kOhm sensors, or even 47 kOhm sensors. Smooth them out with a capacitor; you're not going to read these more than a hundred times a second at best anyway, right?
A 100 nF capacitor per analog input should be fine with a pot in the 10k - 47k range.

Your switches (for the leg ends) might want some pull-downs, although you're probably just fine using the built-in pull-down function in practice. (I tend to prefer signals that are always well-determined, even if software doesn't help out. Your mileage may vary.)

A 5V regulator like the 7805 or whatever can probably deal with your Teensy just fine, or just get one of the Pololu switching buck regulators, and run the device on whatever battery seems reasonable. Having to monitor state of charge and accidentally plugging in a LiPo instead of a LiFePO will ruin your day -- better to make it safe.
 
With a de-coupling capacitor, the input impedance is much less of a problem. Also, linearity isn't a super bad problem -- you can either not worry about it at all (the effect is somewhat muted) or you can warp it in the software.

For the AGND current, three things happen:
1) Teensy pins are generally rated at 5 mA or 10 mA. I don't see a rating for the AGND pin specifically, though. You may be exceeding this, or not -- might have to look that up in the datasheet.
2) Current through the de-coupling circuitry of AGND -> GND will raise the "floor" for AGND, which will cause the measurements to be non-linear.
3) Everything sharing the AGND and raising the voltage floor of it (because of current) will cause a ground loop, which may introduce more noise into the ADC circuitry.

In practice, for the application you're specifying, using 10 kOhm sensors with no additional circuitry might still be just fine, and doing it with a de-coupling capacitor should make it do very well.
 
Thanks for the further detail. I'm trying to get this figured out without having to spend $40-50 of my Canadian dollars per batch of sensors only to have things go wrong when sensor #12 is connected. :)

Here's what I'm seeing in the datasheet for the VSSA and VREFL pins that AGND is connected to:

- The difference between VSS (GND) and VSSA must be less than 100mV for 16-bit ADC performance. (And since 16-bit performance is only available in differential mode, I'm guessing that this is a requirement for 12-bit performance in single-ended mode.)
- VREFL must be equal to VSSA for 16-bit ADC performance. "The ADC analog portion uses VSSA as its ground connection. In some packages, VSSA is connected internally to VSS. If externally available, connect the VSSA pin to the same voltage potential as VSS." (I'm guessing this is why the Teensy wires them directly together.)
- "If separate power supplies are used for analog and digital power, the ground connection between these supplies must be at the VSSA pin. This must be the only ground connection between these supplies, if possible. VSSA makes a good single point ground location."

I'm not seeing anything about current limits on VSSA, and that note seems(?) to say that everything through VSSA (and therefore AGND) is actually preferable? My datasheet-fu is weak, though, so I may be misinterpreting that.

I did some experiments last night and confirmed what you said about capacitors and this additional bit in the datasheet:

"Empirical data shows that capacitors on the analog inputs improve performance in the presence of noise or when the source impedance is high. Use of 0.01 μF capacitors with good high-frequency characteristics is sufficient. These capacitors are not necessary in all cases, but when used, they must be placed as near as possible to the package pins and be referenced to VSSA."

Plugging a capacitor into the board size of my connections did, indeed, reduce noise more than plugging it into the sensor side.

This block seems worth quoting in full:

31.6.2.3 Noise-induced errors
System noise that occurs during the sample or conversion process can affect the accuracy of the conversion. The ADC accuracy numbers are guaranteed as specified only if the following conditions are met:

• There is a 0.1 μF low-ESR capacitor from VREFH to VREFL. [Already taken care of on the Teensy 3.2 board.]
• There is a 0.1 μF low-ESR capacitor from VDDA to VSSA. [Teensy 3.2 is using 0.1μF and 470Ω in series between these pins.]
• If inductive isolation is used from the primary supply, an additional 1 μF capacitor is placed from VDDA to VSSA. [Teensy 3.2 is using 2.2μF here.]
• VSSA, and VREFL, if connected, is connected to VSS at a quiet point in the ground plane. [Taken care of on the Teensy 3.2 board.]

• Operate the MCU in Wait or Normal Stop mode before initiating (hardware-triggered conversions) or immediately after initiating (hardware- or software-triggered conversions) the ADC conversion.
• For software triggered conversions, immediately follow the write to SC1 with a Wait instruction or Stop instruction.
• For Normal Stop mode operation, select ADACK as the clock source. Operation in Normal Stop reduces VDD noise but increases effective conversion time due to stop recovery.
• There is no I/O switching, input or output, on the MCU during the conversion.
[I don't know what any of those four points mean, exactly. I wonder - are any of them used in Pedvide's ADC library? Or is that library only doing the ADCK and averaging stuff below?]

There are some situations where external system activity causes radiated or conducted noise emissions or excessive VDD noise is coupled into the ADC. In these situations, or when the MCU cannot be placed in Wait or Normal Stop mode, or I/O activity cannot be halted, the following actions may reduce the effect of noise on the accuracy:

• Place a 0.01 μF capacitor (CAS) on the selected input channel to VREFL or VSSA. This improves noise issues, but affects the sample rate based on the external analog source resistance. [As you mentioned.]
• Average the result by converting the analog input many times in succession and dividing the sum of the results. Four samples are required to eliminate the effect of a 1 LSB, one-time error. [Easy enough in the ADC library, and it helps.]
• Reduce the effect of synchronous noise by operating off the asynchronous clock, that is, ADACK, and averaging. Noise that is synchronous to ADCK cannot be averaged out. [I assume Pedvide's ADC library is doing this, since it mentions ADCK speed.]

FWIW, I got the best sampling speed and the smallest amount of 12-bit noise in my experiments on a single sensor with the sensor grounded to AGND, a 0.047μF capacitor between the analog input and AGND placed near the Teensy pins, and these settings:

adc->adc0->setAveraging(16); // set number of averages
adc->adc0->setResolution(12); // set bits of resolution
adc->adc0->setConversionSpeed(ADC_CONVERSION_SPEED::HIGH_SPEED); // change the conversion speed
adc->adc0->setSamplingSpeed(ADC_SAMPLING_SPEED::MED_SPEED); // change the sampling speed

I've read that the more sensors I add the more complicated it'll get.
 
Last edited:
Status
Not open for further replies.
Back
Top