richardghirst / PiBits

819 stars 565 forks source link

ServoBlaster on a Raspberry Pi 3? #62

Closed emeflag closed 6 years ago

emeflag commented 8 years ago

Richard.... Do you see any issues with ServoBlaster working on a Raspberry Pi Version: 3?

richardghirst commented 8 years ago

I don't expect any significant issues, but I don't have one to try.

Richard On 4 Apr 2016 8:15 pm, "emeflag" notifications@github.com wrote:

Richard.... Do you see any issues with ServoBlaster working on a Raspberry Pi Version: 3?

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/richardghirst/PiBits/issues/62

emeflag commented 8 years ago

I’ve got a Raspberry PI 3 on order and will give it a try then. I’ll let you know one way or the other if it works.

Thanks for the speedy response! Cheers..

On Apr 4, 2016, at 12:58 PM, richardghirst notifications@github.com wrote:

I don't expect any significant issues, but I don't have one to try.

Richard On 4 Apr 2016 8:15 pm, "emeflag" notifications@github.com wrote:

Richard.... Do you see any issues with ServoBlaster working on a Raspberry Pi Version: 3?

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/richardghirst/PiBits/issues/62

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/richardghirst/PiBits/issues/62#issuecomment-205469630

lf- commented 8 years ago

@emeflag any news on that? I want to find out if it works prior to buying a pi3.

hexaguin commented 8 years ago

@lf- ServoBlaster works perfectly on my Pi 3.

emeflag commented 8 years ago

I can confirm servo blaster works fine on a PI3

kuime commented 8 years ago

system: 2016-05-27-raspbian-jessie pi model: pi 3 model B v1.2

If a monitor is connected to the HDMI port while the pi boots up, nothing happens. If the pi boots up without a monitor connection, Servoblaster goes crazy when I run: echo P1-16(any pin)=100(any value) > /dev/servoblaster

Without a monitor connection, when I put the command in rc.local, I saw the servo turned correctly while the pi boots up, but then if I ran the command again in command line later, the servo turned crazy again.

richardghirst commented 8 years ago

Have you tried invoking servod with --pcm ? Someone else had trouble on an rpi3 and that fixed it for them.

On 27 Aug 2016 3:46 am, "kuime" notifications@github.com wrote:

system: 2016-05-27-raspbian-jessie pi model: pi 3 model B v1.2

If a monitor is connected to the HDMI port while the pi boots up, nothing happens. If the pi boots up without a monitor connection, Servoblaster goes crazy when I run: echo P1-16(any pin)=100(any value) > /dev/servoblaster

When I put the command in rc.local, I saw the servo turned correctly while the pi boots up, but then if I run the command again in command line later, the servo turns crazy again.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/richardghirst/PiBits/issues/62#issuecomment-242891141, or mute the thread https://github.com/notifications/unsubscribe-auth/ABvYsZPVbSkFpaUKXHqJifP79j7esei-ks5qj6T7gaJpZM4H_aoD .

EugeneR1985 commented 8 years ago

Hi Richard! I have problem with my raspi3 and servos. Servo's dont work correctly while the pi boots up. The problem was discussed earlier (post by kuime). How to fix the problem? Thank you!

lf- commented 8 years ago

Did you try the suggestion of invoking it with --pcm?

On Thu, Sep 22, 2016 at 12:35 AM, EugeneR1985 notifications@github.com wrote:

Hi Richard! I have problem with my raspi3 and servos. Servo's dont work correctly while the pi boots up. The problem was discussed earlier (post by kuime). How to fix the problem? Thank you!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/richardghirst/PiBits/issues/62#issuecomment-248823894, or mute the thread https://github.com/notifications/unsubscribe-auth/AGWDqDkAbYmRjx_bINVECC_h4Wao0qyZks5qsiGxgaJpZM4H_aoD .

EugeneR1985 commented 8 years ago

i create a file in /etc/init.d/ called servoblaster

... echo "Starting servoblaster" /home/pi/PiBits/ServoBlaster/user/servod --p1pins="15,16" --pcm ... right?

kuime commented 8 years ago

I tried pcm as well, did not work. Now I have it working perfectly by switching the OS to the lite version xD.

EugeneR1985 commented 8 years ago

Hi!Use raspbian lite?My servo working correctly with --pcm. Thanks)

Triuman commented 7 years ago

I'm using SB on Pi3. Before putting an USB audio adaptor, it was working well without --pcm. But while recording sound through USB adaptor, my servo did just small wiggling. Using --pcm solved the problem.

But while daemon is working, I set servo value to 0(zero) to cut the signal as it's in the desired position and "sometimes" the servo does a big move to one side and other times it cuts the power to that servo as desired. As it's the steering servo of a RC car, I can't tell where it really wants to stop since the steering has a max angle.

I'm also using servod to run the brushless motor of the car via ESC(Electronic Speed Controller), so I can't use idle_timeout. How can I stop sending pulses to the steering servo?

AFUDIrk commented 7 years ago

For me it worked on my Pi 3 without any restrictions. But be the last update kernel: Bump to 4.9.11, the servos no longer work. I control the servos via RPi Cam Web Interface.

maxjp commented 7 years ago

After updating kernel, the below change needed. it works after the change/compile on my P3.

cat /proc/cpuinfo |grep -i hardware Hardware : BCM2835

line#960, added the BCM2835 ;-)

  else if (strstr(modelstr, "BCM2709") || strstr(modelstr, "BCM2835"))
AFUDIrk commented 7 years ago

else if (strstr(modelstr, "BCM2709") || strstr(modelstr, "BCM2835")) It works !! Thank you

Bonzadog commented 7 years ago

25.5.2017

I have just updated my Rpi2 somewhat old version of jessie and am now getting the Sevmod: cannot..etc I re installed using the install-pan-tilt.bah and this did not solve the problem. But where is the else if (strstr(modelstr, "BCM2709") || strstr(modelstr, "BCM2835")) located?

AFUDIrk commented 7 years ago

cat /proc/cpuinfo |grep -i hardware Hardware : BCM2835

In servod.c, line#960, added the BCM2835 ;-)

else if (strstr(modelstr, "BCM2709") || strstr(modelstr, "BCM2835"))

2017-05-25 16:40 GMT+02:00 Bonzadog notifications@github.com:

25.5.2017

I have just updated my Rpi2 somewhat old version of jessie and am now getting the Sevmod: cannot..etc I re installed using the install-pan-tilt.bah and this did not solve the problem. But where is the else if (strstr(modelstr, "BCM2709") || strstr(modelstr, "BCM2835")) located?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/richardghirst/PiBits/issues/62#issuecomment-304027127, or mute the thread https://github.com/notifications/unsubscribe-auth/ALOKkSzDs75OAl2V_kG6_ER1_Ys-6mFfks5r9ZLkgaJpZM4H_aoD .

Bonzadog commented 7 years ago

I do not have sermod.c on the RPi. When I installed from OpenElectrons the pre-assembled sermod (without sources) was included.

I downloaded the servod source from Github, make servod .make install, but no servos are working: I am using a Raspberry Pi 2.

Any Tips on this please? Can oneone help me on this??

srcshelton commented 7 years ago

If anyone is still having problems with this, please try the code at https://github.com/srcshelton/servoblaster/ and drop me a line (either here or by opening an issue there) to let me know if anything's improved?

lzto commented 7 years ago

I can confirm that it does not work on RPI A+ with kernel 4.9.41+ (updated from an older kernel version, and previously it works)

coco ~ # uname -a
Linux coco 4.9.41+ #1023 Tue Aug 8 15:47:12 BST 2017 armv6l GNU/Linux
coco ~ # cat /proc/cpuinfo
processor   : 0
model name  : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS    : 797.66
Features    : half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part    : 0xb76
CPU revision    : 7

Hardware    : BCM2835
Revision    : 0012
Serial      : 0000000065dbe208
coco ~ #

servodebug shows the following

coco ServoBlaster # ./servodebug
This code should be compiled with the command:

  gcc -Wall -O2 -o servodebug servodebug.c

It should be run with the command:

  sudo chrt 1 ./servodebug

DMA controller is not running - is the module loaded?
coco ServoBlaster #
lzto commented 7 years ago

never mind, I reinstalled the kernel and it works now... weird though ... previously I have servos connected to P1-38 and P1-40 and they map to servo 0 and 1 respectively. and they works fine. (which is impossible from current version???) I tried to change them to P1-18 and P1-22 and they does not work initially. but after i reinstalled the kernel and restarted several times it finally works. .. magic....

harlock74 commented 7 years ago

@srcshelton That did the trick indeed (on RPi2 with the raspbian stretch)! Could you please explain the different from the original code? Many thanks!

srcshelton commented 7 years ago

The commit with the changes is 4f42f39 - and most of these are simple fixes to resolve compiler warnings. The key change in terms of working on recent hardware, however, is from line 1025 where the (no longer valid) constants used to determine key locations in memory for interfacing with peripherals are replaced with calls to the Broadcom bcm_host library - which should provide compatibility across all models of RPi, past and present.

harlock74 commented 7 years ago

@srcshelton Thanks for that. Very useful to know.

harlock74 commented 7 years ago

@srcshelton I have just noticed the commands like: echo 0=+10 > /dev/servoblaster do not work anymore. But commands like: echo 0=240 > /dev/servoblaster work perfectly fine. Any thoughts please? Many thanks!

srcshelton commented 7 years ago

Hmm, I'm not aware of this being due to anything I've changed - but I'll admit that is the most likely explanation ;) I'll take a look and see whether I can spot anything suspect! Sadly, I don't have an RPi handy right now to do real-world tests against...

srcshelton commented 7 years ago

It's the change around line 799 - if you run servod directly rather than as a daemon/service, do you see any errors printed about the format of the input when you write the command to the servoblaster FIFO?

harlock74 commented 7 years ago

Thanks for helping. Did you mean run something like: sudo ./servod ? If so I don’t get any error messages at all. Cheers

On 13 Oct 2017, at 20:13, Stuart Shelton notifications@github.com wrote:

It's the change around line 799 - if you run servod directly rather than as a daemon/service, do you see any errors printed about the format of the input when you write the command to the servoblaster FIFO?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

myklr650 commented 7 years ago

I think what running as a deamon is, You don't need to install to make servod run. You just type sudo make. Then sudo ./servod and it will run. If you install it will boot every time u turn on ur pi. I may be wrong tho.

myklr650 commented 7 years ago

I just tested 0=+10% and works fine. I didn't install mine tho. Just 'make' then run

harlock74 commented 7 years ago

Hi, Thanks for your notes. If I run only ’sudo make’ then if I run for example:

sudo echo 0=120 > dev/servoblaster I get /dev/servoblaster: Permission denied

I am using srcshelton fork as the original version doesn’t work at all for me.

Can you please confirm the following steps?

sudo git clone https://github.com/srcshelton/servoblaster.git cd servo blaster sudo make

or

sudo git clone https://github.com/richardghirst/PiBits cd PiBits/ServoBlaster/user sudo make sudo make install

Thanks!

On 14 Oct 2017, at 08:36, myklr650 notifications@github.com wrote:

I just tested 0=+10% and works fine. I didn't install mine tho. Just 'make' then run

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/richardghirst/PiBits/issues/62#issuecomment-336617314, or mute the thread https://github.com/notifications/unsubscribe-auth/AD8e3iQOk1VQYqcCw-HWjbZ-yP2RlCBYks5ssGRqgaJpZM4H_aoD.

harlock74 commented 7 years ago

Ok I started from a fresh image of raspbian: I can get it to work with the following:

sudo git clone https://github.com/richardghirst/PiBits
cd PiBits/ServoBlaster/user
sudo make
sudo ./servod --pcm

Commands like:

sudo echo 0=140 > /dev/servoblaster

work just fine

but commands like:

sudo echo 0=+10 > /dev/servoblaster

don't work.

This is what I am trying to achieve:

Servo adjustments may also be specified relative to the current position by adding a '+' or '-' prefix to the width as follows:

echo 0=+10 > /dev/servoblaster echo 0=-20 > /dev/servoblaster

Before it was working OK. Cheers

harlock74 commented 7 years ago

Heads up: I was wrong, I have just noticed that after running: sudo echo 0=+10 > /dev/servoblaster I am getting the error message: Invalid width '+10' printed out in a separate terminal where I have run sudo ./servod --pcm

Bonzadog commented 7 years ago

14.10.2017

I have given up on the Servoblaster and am now using https://shop.pimoroni.com/products/pan-tilt-hat and is also good for 3 servo only applications For more servos, the adafruit servo module.

All the best

nt

srcshelton commented 7 years ago

sudo echo 0=120 > dev/servoblaster

Bear in mind that 'sudo echo 'text' > destination' won't do what you think: the echo command will run with elevated privileges, but the redirection to write to the specified destination will still run as your own user. Try 'echo 'text' | sudo tee destination >/dev/null'... which is admittedly a bit of a mouthful, but it does the job ;)

srcshelton commented 7 years ago

Invalid width '+10'

Ah, this is what I was looking for! Now let's see how we got there...

srcshelton commented 7 years ago

(For reference, to drive the four servos supplied with a MeArm kit (minus the joystick controller, and using the GPIO pins directly via a breadboard HAT), I was testing with an RPi3 and 'sudo ./servod --idle-timeout=1000 --p1pins=15,16,18,22 --step-size 5 --min 102 --max 444'. These latter two values were found by experimentation to find the limits beyond which the servos didn't reliably operate - YMMV.)

srcshelton commented 7 years ago

... so the error is coming from line 996 (which should read the same as line 948 - I'll fix that), which means that the parse_width function at line 848 is returning failure. Ah, got it! line 880 is incorrectly using the modified value digits rather than the unmodified original od - I'll fix that now!

harlock74 commented 7 years ago

Hi Stuart, That looks very promising! Many thanks for looking at it! Looking forward to your fix;)

On 14 Oct 2017, at 13:02, Stuart Shelton notifications@github.com wrote:

... so the error is coming from line 996 (which should read the same as line 948 - I'll fix that), which means that the parse_width function at line 848 is returning failure. Ah, got it! line 880 is incorrectly using the modified value digits rather than the unmodified original od - I'll fix that now!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

srcshelton commented 7 years ago

Please try https://github.com/srcshelton/servoblaster/commit/a16934944400b5c290d18911dd77e885a428a4c0

harlock74 commented 7 years ago

Bingo!!! That worked like a charm Stuart! Thanks a ton for the quick fix! Very much appreciated!!!

srcshelton commented 7 years ago

😁

japheth12 commented 6 years ago

I am using raspberry pi B rev 1.2, raspbian stretch, with 4.9.59 kernel and echo commands doesn't work but it does not give errors. Please help. Thankyou.

srcshelton commented 6 years ago

@japheth12 Are you using the code from this repo, or my fork at https://github.com/srcshelton/servoblaster? If you've not given it a try, then please take a look at this link - I've updated the code from here to use more standardised methods to determine how to hit the hardware, which should increase compatibility.

I've not had chance to test with the latest kernel yet I have to admit - but you're in luck, because I'm planning to move my MeArm from an RPI3 to an old RPi2B (or was it a B+?), so I'll have chance to double-check that everything still works on different hardware then.

harlock74 commented 6 years ago

Hi, I can confirm that Stuart’s fork works like a charm on my old Raspberry Pi B as well!

On 7 Dec 2017, at 11:42, japheth12 notifications@github.com wrote:

I am using raspberry pi B rev 1.2, raspbian stretch, with 4.9.59 kernel and echo commands doesn't work but it does not give errors. Please help. Thankyou.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

japheth12 commented 6 years ago

@srcshelton I've used your fork but still it doesn't work. Please help.

japheth12 commented 6 years ago

Is it necessary to have "OUT" Mode in the gpio pin? Thanks.

richardghirst commented 6 years ago

Latest version works fine on Pi3.

DilipKumar-code commented 4 years ago

for people using Raspberry pi 4 add

else if (strstr(modelstr, "BCM2709") || strstr(modelstr, "BCM2835") || strstr(modelstr,"BCM2711"))