I've been trying to control a mg995 Servo by changing the duty Cycle with the RPi.GPIO library, but the Servo ended up shaking a lot. I've been reading a lot of Threads about this issue and I know, that using the RPi.GPIO library is causing the issue.
I then tried to use the pigpio library but it's unfortunately not available for the RP4.
I know that buying a specific hardware could help out but I want to try it with software first.
Is there another way to controll a Servo without the shaking? I want to run the Servo through python code btw
If the driving is not done at a too high PWM frequency then you can create a solution by using SYSFS driver, if you need high frequency the problem is maybe hardware and not software to control at the oscilloscope. If you are able and want to do without any lib then you can write directly the gpio registers of the SOC through memory-map with mmap
As I tested before, software PWM is unstable and the servos can shake a lot, hardward PWM is quite acurrate, but the pi has only 2 hardware PWM channels.
The best way may be add an external PWM module (PCA9685 for example).
Related
I have multiwii board connected to raspberry pi 3A and I want to calibrate the mpu6050 sensor from raspberry pi using python programming, can anyone help me out on how I can program this, please?
Try to be more specific in you questions for te next times.
But, to calibrate a Gyro you should take a look at this tutorial.. Or if you are a really begginer and wants to learn how to use the sensor, take a look to this.
This and this tutorial are also useful.
I am writing a GUI for my Raspberry pi, but I'd like to work on the code on PC, then drop it into the pi, just cos the tools are better and I mostly have remote access to the pi etc etc. My problem is that the GUI does some calls to change IO pins on the Pi, using the RPi.GPIO library, which doesn't exist on PC. Of course I can comment out the lines of pi-specific code, but that's really messy especially if I start going back and forth. My idea is to set up a dummy/mirror library for the PC, then the code picks the dummy library on PC and the real library on the pi. Seems simple, but I'm getting really bogged down creating my own library. So, to my question, in summary - what is the easiest way to create a quick library using PyCharm that my code would pick up...
Here is some quick code for context...
import RPi.GPIO as GPIO # this is the library I want to mirror
# sets pin numbering on pi, does completely nothing in
# the dummy I want to call in on on PC
GPIO.setmode(GPIO.BOARD)
GPIO.output(self.reset_pin, 1) # also does stuff on pi, nothing on PC
There is the fake-rpi package on pypi:
So, does this simulate everything on a Raspberry Pi? No! Right now it simulates what I use and need. Over time, more will be added. You are also welcome to submit pull requests for things I haven't added yet.
But it looks like it simulates GPIO pins
I have a python script on raspberry pi 3 and I want to secure my script as much as possible. The user can only contact with the touch screen so there is no external hardware like keyboard, mouse etc. What should I take measure against stolen? For example disabling usb ports, encoding script...
Everything a Raspberry Pi 3 "knows" is on that little micro-SD card. The only way to gain some security is to physically secure the device in an enclosure that prevents the user from getting the SD card. And you need to make your software hard to break into -- difficult for an interpreted language like python -- but made a lot easier if there's no keyboard or other ports available. Again, protected inside the enclosure. If the users can literally only get to the touch screen, then I have a hard time imagining how they'd steal your software.
I have a raspberry pi and I was wondering if there was a way to interrupt a program using a GPIO pin? For example, the pi begins printing a long story but if i click a button and close the switch it will pause and turn on a led. I did some research but i could only find stuff for python 2 while I am using 3. Thank you any help is greatly appreciated. :D
The RPi.GPIO library supports Python 3, so you can start by using that.
Assuming that your RPi board is one that uses GPIO 3, here is an example:
import RPi
RPi.GPIO.setmode(RPi.GPIO.BCM)
RPi.GPIO.output(3, RPi.GPIO.LOW)
I'm new to the Arduino platform and i'm wondering if it is possible to tell if an LED is on using an arduino input? I'm confused as to if i can check the voltage of one side of the LED in reference to the Arduino's ground? or would i have to check the voltage relative to the other terminal of the LED.
Just a little confused.
This question is probably better asked on electronics.SE, but here goes:
Yes, it is possible, and there are a couple of ways you could do this:
You could hook up a light sensor to your arduino, aim it at the led, and read that. No modification of the coffee maker is needed
You could connect a wire to a coffee maker LED, and connect it to Arduino. But where to connect the wire? To understand this you have to consider how LEDs are usually hooked up: there is the control signal, the LED itself, a current-limiting diode, and ground. The two main options look like this:
Assuming that the control voltage is either +5 or zero volts, and assuming your arduino runs on that (and not 3.3V, for example), in both cases (the one on the left and the one on the right), you want to connect your wire to the point indicated as "control". In the left hand case is "before" the resistor, but in the right hand case it is "before" the LED. You should use your multimeter to confirm your assumptions about the LED circuit, and verify that the connection point indeed is either at +5V and 0v (or whatever your expected voltages are) when the LED is on or off, respectively (if you don't have a multimeter, then this might not be a good project for you)