-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No hardware PWM's on all GPIO #31
Comments
I have used hardware PWM in a live demo that I did for CodeOne 2019. So it's at least been tested before to some degree. If you have not already, I would suggest getting and installing he latest version: |
It looks like I used different PWM channels in my demo project: If it possible for you to try pin 18 or 19? I wonder if there is a mode not getting applied to the requested PWM GPIO pin. This looks suspicious: |
I can try 4, 5, 6 and 13. That's clean GPIO's. No I2C or SPI. |
I have
|
I post the whole error log and also the Java code: Java code:
And for the ADS1115 16-bit ADC
pi@raspberrypi:~/Documents $ sudo java -jar opensourcelogger-1.0-SNAPSHOT.jar 2020-07-10 16:43:15 sigHandler: Unhandled signal 4, terminating 2020-07-10 16:43:15 sigHandler: Unhandled signal 11, terminating pi@raspberrypi:~/Documents $
|
So reading that PIPGIO supported hardware PWM on pins 0-31 was a bit confusing to me.
If you read further in the actual function description on PiGpio: You will see that it says: "The GPIO must be one of the following ..."
So I think that the RaspberryPi hardware only supports 2 hardware PWM channel and they can be routed to the GPIO pins listed above --- but in the end you only get 2 hardware PWM channels. So I'm not sure if the documentation on the PIPGIO site that says: "hardware timed PWM on all of GPIO 0-31" ... really just means that if you use the software PWM functions that the library is using some hardware timing elements to emulate PWM in software or if this just means that the library supports the hardware PWM functions on all pins, but its up to the actual hardware as to which pins can accept hardware PWM So .. I guess try BCM pin 13. |
So the conclusion is that there are 0-31 hardware PWM pins, bit raspberry pi can only use two of them? I need 4 PWM pins - hardware. |
Ok! It's seems to work now. But I have another issue you might want to look at. I have selected the pins you suggested. It's seems to...not giving any errors. Also I removed the id-label. Not sure if they are needed.
And now to the error. Not sure what it means. But it close the spring boot application.
|
On 11/07/2020 11:35, Daniel Mårtensson wrote:
||
And now to the error. Not sure what it means. But it close the spring
boot application.
|2020-07-11 12:32:34 sigHandler: Unhandled signal 11, terminating
2020-07-11 12:32:34 sigHandler: Unhandled signal 11, terminating |
I think this is an issue that I uncovered a while back. Essentially
PiGpio decides it wants to control all the signal handlers. The Java
runtime has different ideas. Chaos ensues.
I'll see if I can get a fix sorted this weekend.
Regards,
Jim.
|
Ok! I tried to add id-labels to all of them now. Separately id:s. Now I only got this error |
No, I don't think that accurately reflects the situation. See this post in the Raspberry Pi forums:
The Raspberry Pi supports 2 hardware based PWM channels. You can access these two channels via 2 separate sets of 4 GPIO header pins. But still limited to only 2 channels (2 unique PWM timing configurations). The PIGPIO library is providing additional PWM support to any of the GPIO pins (0-31) and its using some hardware timing technique to optimize performance --- but its not the same as the actual hardware PWM pins natively on the RaspberryPi. In the Pi4J API, we would call this "Software" PWM and you would need to set If you need 4 PWM pins, then I would suggest trying to use the software PWM functionality, it may be perfectly fine for your application. If they are not good enough, then you will probably need a PWM expander board/chip (controlled by I2C/SPI) to provide additional PWM support. Thanks, Robert |
The As @hackerjimbo mentioned, the signals issues was recently uncovered and is being tracked via issue: #15 |
Hmm.. Still got the error, even if I replaced all hardware enums with software enums.
|
That's because it's got nothing to do with the @DanielMartensson, what hardware are you running on? |
I'm using Raspberry Pi 4B |
OK, I now have no idea why it's not work. It should get this right. |
Perhaps the Pi4J project is to complex? |
I make a lot of use of OOP on my hardware drivers. A great (and very recent) one was talking to the SH1106 display driver. This is available via both I2C and SPI. The vast majority of the code is common but I have a few abstract methods that allow me to drive it one the specific device in use. See also the MCP27x17. Are you running 32 or 64 bit on the Pi 4? I know for certain that the 32-bit one probes the exact hardware in use by checking what works and what doesn't (trapping the illegal instructions and from that deducing what the functionality available). This allows the JIT compilation to be perfectly tuned for the hardware. I wouldn't describe Pi4J as too complex. Software only gets complex when it hits 1 000 000 lines! :-) Right now we're shaking down the pigpio drivers (which I think we've fixed now) and getting Pi4J to talk nicely to them even on a Pi Zero (getting cross-compilation right, which I also think we've done). Not bad for about a week's work! |
I'm using ARMv7 Processor, which is 32 bit.
|
The However, knowing that you're running in 32-bit mode is helpful. Which JVM are you using? |
|
Just for reference for @savageautomate and others, on the Pi Zeros I'm using:
|
Do you think Java 8 will solve this issue temporary? |
No. Pi4J-v2 is based on Java 11 and uses the extra features of that. The issues aren't with the language version but with the binding to PiGPIO. I think we've got that more-or-less understood and fixed now. |
If you want! I can upload my web application software so you can really see what issues there are inside my setup? |
I'd like to get the known issues fixed and publicly available. Then we'll see which of yours remain. |
This will help. |
Thanks for all the info shared in this topic, I used it for the initial content of the PWM page on the new site --> https://v2.pi4j.com/getting-started/io-examples/pwm |
Did you try my software? Perhaps it will work on your Pi? |
@DanielMartensson no sorry, not yet, I'm a bit behind with testing on the Pi itself... |
Here is a compiled from ( |
Is is available for The current settings for my
|
As soon as @hackerjimbo confirms the fix here, I'll deploy it to the maven repositories. In the meantime, you could manually copy the JAR file into the directory where you are running it on the Pi. |
Do I have to remove the Pi4J dependencies in Pom.xml? I tried to include the JAR file into my project. Still got the same error
Notice that I'm using Pi4J inside a thread. I tried also to remove Pi4J-Core dependency in Pom.xml, but it gave me the same result -
|
@savageautomate — it works! Tested on a Pi Zero and a Pi 1. Both crash with the old version of the java code and the system pigpio and now work with the OS-supplied pigpio and the fix you posted. Great work! |
Have a look at this code:
|
Why did it not work for me? |
Please try again. I have deployed the latest version (with the signal fix) to the Maven SNAPSHOT repository now. You may want to first delete the directory and files on your local system where this JAR file could be cached to ensure the new version is picked up by Maven.
|
Ok! Seems that there are no errors now :) Need to check if the PWM's can pulse too. |
Just checking in to see if this issue can now be closed. Thanks, Robert |
I haven't test my PWM's yet. I just have created my project and I will soon test it. |
Nope. No activity from the GPIO's here: Row 134 |
Hi!
Just started with Pi4J 2.0 and I got an error.
And the Java code:
I call that function with:
That's weird because Pigpio says that there are 0-31 hard ware PWM's
http://abyz.me.uk/rpi/pigpio/
The text was updated successfully, but these errors were encountered: