Using Micro-Servo on Grove Mezzanine Board

I have the Grove Mezzanine board on top of my Dragonboard. I want to try to use the servo motor.
I have an example Sketch program from Grove but the program uses pin 9. Can I use a Grove Digital port like D3 or should I use one on the Ardunio sockets?

Hi @David

I am not sure which board you have on top of your 401c, I have seen s “Grove Mezzanine” although it is not listed on this web site, and there is a “Sensor’s Mezzanine” board which has an Arduino on it, so I am saauming that tis is the board you are interested in.

Next point of confusion is the term “Pin 9”, there are at least three different pin 9’s on the board, but for the purposes of this conversation I think you are talking about Pin 9 on the micro-controller which is Timer 0 (signal name PD5). In either case you can attach your motor to the Sensors mezzanine board the same way you would attach it to an Arduino board, or you can attach it to the D5 connector.

The signal PD5 is wired in parallel to both the D5 connector, and to the blue Arduino connectors so it doesn’t matter which one you wire to.

Full Disclosure: I am an employee of Qualcomm Canada, any opinions I might have expressed may not reflect the opinions of my employer.

@David I saw your cry for help on the Open Hours. There is so much misinformation floating around about the Sensors board about such simple topics that should just work but don’t. Here’s the deal:

The Arduino defines certain numbered digital and analog which don’t necessarily correspond to obvious numbering on a connector, and don’t correspond to MCU pins. For a reference to those pins, google for an Arduino Uno schematic. Essentially Arduino pins 0-7 correspond to Sensor board P2 pins 1-8, and Arduino pins 8-13 correspond to Sensor board P3 pins 1-6.

The servo sweep sketch defaults to using Arduino “pin 9”. The Uno schematic will show you this as pin 2 on connector IOH, and it’s connected to signal PB1. So on the Sensor board that’s P3 pin 2, and the schematic shows that as PB1 (correct). OK, does signal PB1 appear on any of the Grove connectors? I don’t see such a connection.

Maybe you could change the sketch to use a different digital output pin? OK, it needs to be a pin that supports PWM, which is a particular way of using certain timers, (to operate the servo). Arduino PCB silk screen has a ~ tilde symbol next to pins that can do PWM, and that’s pins 3, 5, 6, 9, 10, 11, which corresponds to PD3, 5, 6 and PB1, 2, 3 respectively.

So, you could for example use PD5, Arduino pin 5, aka P2 pin 6, aka Grove D4 pin 2. (I note in passing that oddly PD4, 5 and 6 appear on multiple different Grove connectors, whereas PB1-6 signals don’t appear on any.)

Now, when you run a hobby servo, usually it needs three wires, ground, servo-style PWM signal (nominally 5V logic levels), and a positive voltage of 5V to 6V (unless it’s a 12V servo etc). You may be tempted to power the servo off the VIO power pin on the grove connector. This is a bad idea – servos take a surprising amount of current when changing position, easily surging into the 100’s of mA even for small servos. Sensor board VIO comes from the +5V rail, supplied from the 96Boards LS connector, so from the Dragonboard and its 5V regulator that was not designed to supply a large current. The outcome is that moving the servo may easily result in a reboot of either the ATMEGA or the Dragonboard. So, figure on providing an external supply to the servo (ground in common with the Sensor board and Dragonboard, +5V or +6V direct to the servo.

Note that I’m looking at the Sensor schematic available here: http://www.96boards.org/products/mezzanine/grove-starter-kit, and dated 2015-11-29. I know there have been changes, and it would help if someone would post some links to updates.

And if someone updates the Sensor schematic, please add Arduino pin numbers alongside the the Arduino connectors on the schematic.

Updating my previous post with respect to powering a servo from the Sensors board Grove connector 5V supply pins.

I was finally able to track down a partial datasheet for the relevant Dragonboard voltage regulator, in lieu of the missing current capability spec for the LS connector +5V pin in the 96boards CE spec.

On the Sensor board, the Grove connector power pins labeled VIO are connected to the +5V net that originates from pin 37 on the LS connector. This in turn comes from Dragonboard U13 SY8104ADC which derives 5V from the voltage at the DC input jack.

http://wenku.baidu.com/view/d7007a8fb9f3f90f76c61b5f.html

It turns out that this regulator is rated at absolute max 4A. Even assuming it should run at substantially less than that for heat reasons, and depending on actual DC input voltage, that’s still substantial current available at 5V. (One of the roles of that regulator is to supply 5V to the the Dragonboard’s two USB-A jacks. Also the HDMI driver chip.)

The next possible constraint is that 5V is delivered to the Sensor board through a single pin on the LS connector. Those 2mm-pitch connector pins are rated at 1 to 3 amp depending on brand and plating etc. So, still enough to run a servo. (Another possible constraint is of course the power source that’s feeding the Dragonboard DC input.)

Regardless of whether this account shows there’s sufficient ongoing current, it’s still a poor idea to run a servo (or any motor) from this 5V line. Electrical noise from the servo motor may well find its way onto this supply, from which the ATMEGA itself runs. Most hobby servos contain a DC motor with brushes that are constantly switching the inductive load that is the motor winding, resulting in voltage spikes on the power supply. In addition, the servo circuit itself is constantly switching the motor back and forth to hold present position. So the +5V net will experience periodic surges of current consumption as the servo gets activated (especially with a mechanical load) along with noise spikes, neither of which are ideal for the reliable operation of a CPU attached to this +5V net (here the ATMEGA).

So, you may well get away with running a servo from the Grove +5V line just fine. But if there is any flaky operation, keep in mind to put the servo on a separate supply before tearing out too much hair.

In this post I add a Sensor board schematic annotated to show correspondence to Arduino pins. Use browser right-click “View Image” feature (or equivalent) to see it larger.

Side note: Forum apparently doesn’t allow image upload per se (nor attachments), only link. This image limitation would seem a grave impediment to the community sharing technical info, so perhaps someone could get this fixed.

(In case anyone already read my preceding post with annotated schematic of Sensors board, and possibly saved the image: I have just updated the image to 2016-10-16 Rev 1 to add additional information. The revised diagram should now appear in that post.)

Hi @gwideman

The 5V pins on the Low Speed connector have been designed (in accordance with the 96Boards CE Specification, Page 9) to supply up to 5 Watts of power (1 Amp at 5 Volts). The 5V Regulator you saw on the 410c DragonBoard has been sized to provide 2.5 Watts to each of the USB ports, plus 5 Watts to the Mezzanine board, plus whatever else is needed on the 410c DragonBoard. As long as your current draw below 1A on the mezzanine board you will be fine. I believe that 1A should be enough to run most hobby servo motors. If you do need more power, the SYS_DCIN (nominally 12v) pins on the low speed connector can supply an additional 7 Watts, but you will need to regulate this down to 5V on the mezzanine board.

The AC power supply has been sized at 24 Watts (12V at 2 Amps), this is so that it can provide the 12 watts to the Mezzanine board (5 Watts at 5V, plus 7 Watts at 12V), plus the 5 Watts to the two USB ports, plus the power for 410c DragonBoard. (Plus a little to spare, just in case).

Full Disclosure: I am an employee of Qualcomm Canada, any opinions I might have expressed may not reflect the opinions of my employer.

Thanks @ljking for pointing out the DC Power section of the CE spec. I had not noticed that. Good to know my calculations match the specs :-).

I also discovered that Dragonboard Hardware Manual section 5.7 Power Supplies has some specs on the distribution of the +5V supply. As a side note: from those specs and the Dragonboard 410c schematic, I see that USB power controllers are set to about 1.2A (6W) max for each of the USB-A jacks, totaling 12W for the USB. So if my math is right, that’s 12W for USB, 12W for the Mezz board, a couple of watts for the Dragonboard itself, and it’s over the capacity of the power adapter.

That would be an unlikely scenario, so as mentioned previously, the remaining concern is not the steady-state or slow-changing current consumption of a servo or motor. It would be the transients that servos and motors can generate onto the regulated +5V. Might or might not be an issue with any particular servo. Even if unlikely, such transients can cause problems that can be aggravatingly intermittent and hard to diagnose.

But first things first: Hopefully David will be able to use the diagram I posted to understand which Arduino pins to choose from for PWM for the servo, and be able to set up the Servo demo sketch accordingly to give it a try.

I got the micro-server to work.
I found that pin 4 will move the servo on D4.
I found that pin 5 will move the servo on D5.
I found that pin 6 will move the servo on D6.
I found that pin 7 will move the servo on D7.

So it looks like the board could power 4 servos. The documentation does recommend using a separate power supply for he servos if you use more than two. This was also discussed in gwideman’s post.

@David And you might also note that each Grove connector has two signal pins, so that you can drive two servos from one Grove connector. As shown on the schematic I posted, Grove connector D4 presents Arduino pins 4 and 5, connector D5 presents Arduino pins 5 and 6, and so on.

Further update on Arduino pins supporting servos. (Correcting info I gave earlier.)

It is true that Arduino only has certain pins which support PWM in hardware (using the hardware timer functions directly). This variety of PWM is also referred to in Arduino-land as “Analog output”, and the PWM runs at 500Hz by default, I believe. Software can write a register once to set the duty cycle in the range 0% to 100%, and then pay no further attention until a change of duty cycle is needed.

It’s also true that the hobby servo input (position-setting) signal is a variety of PWM. However, this variety of PWM has a 50Hz repetition rate (20msec), and the position setting is communicated by pulse length varying from about 0.5 to 2.0msec. (In some multi-channel systems, similar pulses for additional channels occupy the remaining ~18ms per “frame”).

The wrinkle I only just realized is that the Arduino Servo library doesn’t use the Arduino’s hardware PWM capability. Instead it uses timers and interrupts. As a consequence, it is not limited only to the pins capable of hardware PWM (the ones with a tilde). The Servo library can drive servos on any of the Arduino outputs, up to the number of digital I/Os on the board, assuming those pins aren’t used for something else, and assuming it doesn’t run out of timers.

Sorry if anyone was misled by my earlier discussion. And thanks to David who alerted me to this by noting that pin 7 can drive a servo.

Hi @gwideman:

You have correctly noticed that:

I also discovered that Dragonboard Hardware Manual section 5.7 Power Supplies has some specs on the distribution of the +5V supply. As a side note: from those specs and the Dragonboard 410c schematic, I see that USB power controllers are set to about 1.2A (6W) max for each of the USB-A jacks, totaling 12W for the USB. So if my math is right, that’s 12W for USB, 12W for the Mezz board, a couple of watts for the Dragonboard itself, and it’s over the capacity of the power adapter.

We intentionally set the USB current limits high!. Nearly all USB compliant peripherals are well behaved and only draw up to the 2.5Watts they are permitted, as long as you are using these there is no issue having the limits set high. Unfortunately there are some USB peripherals out there that are not well behaved and will draw short duration peaks well beyond the 500mA they are permitted (for example plugging in a device with a high input capacitance will momentarily draw many amps, also mechanical hard drives draw over 500mA when spinning the platters up to speed). These momentary conditions would cause the over current limit to trip out and then the peripheral won’t work and the user will have a devil of a time figuring out why.

In general we never expect USB peripherals to draw 1.2A on a long-term basis, only for short moments. Even if you do have a poorly behaved USB peripheral that draws 1A on a long term basis it is unlikely you will have two of them AND at the same time be drawing the max power for the Mezzanine board. If you do reach a perfect storm and have all of these things going on at once, the 5V regulator will shut down and protect the system (although you will have a devil of a time figuring out why).

Full Disclosure: I am an employee of Qualcomm Canada, any opinions I might have expressed may not reflect the opinions of my employer.

Thanks @ljking for the additional info.

While on the subject of current capability, in order to use the handy current sense resistor R77, it would be convenient to install J10. But that’s only useful if JP3 and JP4 are in place (and JP10 and JP11 not).

Do you happen to know where those JP’s are located? (Or alternatively, is there a PCB layout with component locations available?)

I see that Hardware Manual section 8.6.1 mentions these jumpers also, but doesn’t tell where they are. Schematic describes them as EMBEDDED_SHORTING_BAR – not sure what that means in this context.

Thanks.