Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Hot answers tagged

9

The electrical connections required depends on the servo you have. The GPIO provides 3.3 V and up to 16 mA, which is insufficient for your servo, so you will need to buffer it with a transistor. There are 8 GPIO pins on the expansion header, though other pins can be reconfigured to give up to 17 GPIO pins in total. If you need more, you will have ...


8

If you are running a realtime operating system on your Raspberry Pi this is indeed possible. As others have said already you will need an external power source to the servos but except for that you do not need any other additional hardware. If you are running Xenomai (realtime patch for Linux) you can run a completely familiar Linux system, but with added ...


7

I'm not sure if anyone will write the code for you. It's too broad a question. You need to acquire a basic understanding of Python programming first, otherwise you'll be forever asking questions. Personally I'd use the Python curses module (import curses) to handle keyboard entry. There are example of using curses within pigpio at http://abyz.me.uk/rpi/...


6

The Pi is the "command and control centre" and it happens to run at 3.3v logic. That is pretty standard for like MCU's like Arduino. You also get 5v versions. Neither is correct or incorrect. You build high power infrastructure around the MCU/controller. You don't need the breakout board if you know how to wire up the servos. The fact is that you WILL ...


6

You can drive as many servos from the Pi as you can find spare gpios. You have to use hardware timed PWM rather than software timed PWM. People who report jitter have been using software timed PWM. My pigpio library generates independent hardware timed PWM on all the user gpios and is suitable for servos. I think the defaults used mean it has ...


5

If you don't mind using a Linux Kernel driver there is servoblaster which exposes the servos as a char device. https://github.com/richardghirst/PiBits I have forked a new version which does not consume all of the gpio pins for servos use. I'm currently using such on a small servo driven robot the I have built and demoed for our robot club using IPGamePad ...


5

Servos can draw a lot of power so don't expect to be able to reliably power anything but a tiny 9g type servo from the Pi. A servo has three wires, power (+ve), ground (-ve) and control. You can connect the control wire directly to a Pi gpio. If you do you must also connect a Pi ground to the servo ground. So you can connect a Pi 5V to servo power, a Pi ...


4

I don't use those functions so this is gleaned from the documentation. The basic pulse unit is 100 micros long. The final paramater in softPwmCreate says how long each cycle is in basic pulse units. softPwmCreate(1,0,200) says create a cycle 20 ms long made up of 200 steps (20 ms as 200 * 100 = 20000 microseconds). softPwmWrite(1,185) says keep the pulse ...


4

I doubt you'll need to use the PWM capability of gpio 18. There are many ways to provide hardware timed PWM on the Pi on all the user gpios. They are all variations on a theme and use DMA transfers paced by the PWM or PCM peripherals. You can ignore that as they are all wrapped up in simple wrappers. My offering is pigpio which will let you send servo/PWM ...


4

For the Raspberry Pi Python RPi.GPIO module (which seems to use dutycycle values between 0 and 100). dutycycle = ((angle/180.0) + 1.0) * 5.0 so angle=0 gives 1.0 * 5 (5%), angle=90 gives 1.5 * 5 (7.5%), angle=180 gives 2.0 * 5 (10%), angle=45 gives 1.25 * 5 (6.25%) etc. The RPi.GPIO ChangeDutyCycle method is not a reliable way to control servos. It uses ...


4

Use gettimeofday(), it returns seconds and microseconds. You are unlikely to get satisfactory results for servos using Linux sleeps. There will be glitches. Unless you have a particularly poor servo the glitches will result in servo twitches. A B+ has two channels of hardware PWM suitable for driving servos. The C libraries which generate hardware timed ...


4

Simple. The maximum number is 0 (zero). You will need at least a transistor or a relay to drive the DC motor, as the GPIO pins on the rPi do not provide enough power to drive the motor. You will also want to put a flyback diode in place, plus a current limiting resistor. Since you said you only want to use a breadboard, rPi and motor, those components do not ...


4

I don't see why not. Why not try and see? You only connect the control wire to a GPIO. The current is negligible. Personally I always connect the control wire direct to a GPIO for a servo. If you are of a nervous disposition add a 10 k resistor in series with the control wire.


4

You need to use hardware timed pulses for servos. Software timed pulses will lead to jitter and a shorter servo lifetime. Try pigpio, servoblaster, RPIO.GPIO, or similar which use hardware timed pulses.


3

There is an extension board available for the raspberry pi called the gertboard that is used to control servos and other loads that the Pi can't drive by itself.


3

RPIO, like pigpio, servoblaster, piblaster, and possibly others, use DMA to time the servo pulses. In effect the pulses are hardware timed. In contrast to software PWM they suffer little if any jitter. The DMA timing is achieved by pacing transfers from a Broadcom SOC peripheral. There are only two which may be used, PWM and PCM. Initialising the ...


3

Servos require accurate and regular pulses. More accurate than software timing will provide. If you want your servo to stop twitching you have several choices. use some add-on hardware to generate the pulses find some software which can generate the needed pulses on gpio18 (which can use special PWM hardware). This will only be good for one servo. use ...


3

It does seem like the GPIO pins get set during boot. This is quite a problem as it is not what you would have expected! The problem is that during boot the GPIO pins are floating and pulled down by anything. So they will have "random" or unexpected values and voltages. *Reference First of all the servos should NOT be connected directly to the GPIO. You ...


3

Have a look at the Joystick API of the Linux kernel. The API is really simple, you just need to open the device and read data from it. There are several ioctl parameters to query the number of axes and buttons. There is a nice, but old tutorial on the linuxgames mailing list, and all the important stuff is defined in the linux/joystick.h header. If you ...


3

Servos are, generally, controlled using PWM signals; you should refer to GPIO as PWM output. There is PWM support on the chip, so we should be able to use that in the future. Basically, all the software does is tell the hardware to produce pulses at a certain frequency. Some people have had success using external PWM controllers over I2C.


3

Knowledge of how to do things on the Pi has improved quite a lot in the years since this question was asked. There are at least four ways of generating hardware timed PWM/Servo pulses on the Pi's gpios without using external hardware. The use of kernel modules to do this is pretty much deprecated, The following userland solutions are available. My own ...


3

Is it just me or does the thought of allowing a web application to edit cron jobs give you the willies. Here is how I would go about it: Setup a cron job to always run at the frequency you desire. Make it run the script you want. In the script the first thing you do is read a small settings file which tells it whether to continue or not, for instance run=...


3

You can setup servos to use PWM-ish through the GPIO pins using the RPIO Module which will send a PWM pulse which works great with servos. Setting up the Hardware To set up the Servos in a Pan and Tilt situation, Put a bottom servo as Pan and attach the second servo sideways as tilt and attach it to the Servo arm on the Pan servo. You can add linkages if ...


3

Have you looked into GO based groundcontrol daemon at https://github.com/jondot/groundcontrol? It is very light on CPU resource and has a very simple control UI with various buttons for executing simple bash commands or complex scripts. In your case, let's say you have a cronjob entry to allow a script named, servos.sh run every 30 minutes. crontab -l */30 ...


3

To answer your general rather than specific question. My pigpio library will allow you to control servos. Download and installation instructions wget abyz.me.uk/rpi/pigpio/pigpio.zip unzip pigpio.zip cd PIGPIO make make install The simplest way to control a servo is from the command line using the pigs utility. sudo pigpiod # start the daemon If you ...


3

Lucky to see this question, I just spent weeks on controlling two servo (SG90) using WiringPi and programming in C, there're three things that I recommend. 1.Using BCM GPIO instead of WiringPi Pin because controlling more than one servo, you might need more than one pin such like 1(WiringPi Pin)/18(BCM GPIO) for another servo, For RPi3 B+ version, it give ...


3

Servos do not require a motor driver board (the servo itself incorporates a driver board). You just need to supply power via the power and ground wires and a control signal via the control wire. The control signal is generally a pulse between 1 and 2 milliseconds long transmitted 50 times per second. The length of the pulse determines the servo angle. ...


3

Please do not try to drive a servo (or multiple servos) directly from a GPIO pin. You will need to put a transistor in between, and provide a separate power source for the servo, as the RPi might not be able to deliver enough power to drive the Servo (depending on the voltage used to drive it, at 3.3V the RPi only has 16mA available, at 5V this is a little ...


3

The only problem I can see with the code is that it terminates straight away. When the program ends the pigpio library will shut down so servo pulses will stop. I suggest you add a time_sleep(10) or so to see the servo move. Here is a longer example. Change the 0 at the end of each line of servoInf to 1 if a GPIO is connected to a servo. #include <...


3

Ground in a DC circuit refers to either an actual earth ground (i.e., 0 volts vs. anything) or a common ground for different components that may be working at pretty much any voltage relative to it. I think what you would really want to be concerned with on the Pi is the amperage, if the "common ground" to the Pi is the primary ground for whatever you are ...


Only top voted, non community-wiki answers of a minimum length are eligible