PWM | A PHP library for accessing the PWM pins on a Raspberry Pi
kandi X-RAY | PWM Summary
kandi X-RAY | PWM Summary
A library for low level access to the PWM pins on a Raspberry Pi. These pins can be used to control analog outputs.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of PWM
PWM Key Features
PWM Examples and Code Snippets
Community Discussions
Trending Discussions on PWM
QUESTION
I am using this python package to control a led strip. Using PWM everything worked perfectly fine but it didn't allow me to run the script without sudo which is why I switched over to using SPI.
Now I get this weird behaviour where suddenly the entire led strip lights up but in kind of a gradient:
The strip is connected to GND, 5V, and GPIO10 / MOSI / Pin 19.
Example usage of the Strip:
...ANSWER
Answered 2022-Apr-04 at 09:16After hours of try and error, I decided to continue using PWM As this required the script to run with root, I outsourced the led controller in its own python program and used interprocess communication to get the needed information from the flask app to the led controller.
This controller program is automatically started as a system service - except for this service crashing at midnight this works fine.
QUESTION
I'm currently working on a project for which I need to control 13 white LEDs and one RGB LED with two shift registers 74HC595
in cascade.
I work on windows
with a SAMD21 XPLAINED PRO
board (µC samd21j18a
) and ATMEL Studio
as IDE.
For the moment I manage to do it quite basically using SPI
(I define most of my project's parameters on ATMEL Start
).
ANSWER
Answered 2022-Mar-26 at 09:59Ok, I'm working on a software solution that works really good.
I create an "hard written" values table which is a kind of gauge to fix the LED frequency.
My gauge contains 26 values (the first 13 values are "0" and the last 13 values are "1"). I browse this gauge with a sample of 13 values depending on the intensity I want (the values in my sample start at gauge[intensity] to gauge[intensity + 12]).
(When intensity is 0, my sample contains only 13 times 0. When intensity is 1, my sample contains only 12 times 0 and one 1.). Based on these values, I turn on or off my LEDs to modulate the intensity.
QUESTION
I want to generate clock for PCA9959 LED driver with my STM32L552. The LED driver needs an external clock at 20 MHz (+/- 15%). I'm trying to generate a 22 MHz clock on port PA8 on STM32L552. I managed to generate a PWM on port PA8, but I can't reach the frequency of ~22Mhz. I arrive at a maximum of 8Mhz.
Here are the PWM parameters:
I'm not sure I filled in the pwm parameters correctly. Normally with his settings I guess I should have a 22 MHz PWM with a 20% duty cycle.
PWM (MHz) = SystemCoreClock (MHz) / Prescaler => 22MhZ = 110MHz / 5
Thanks for your help.
...ANSWER
Answered 2022-Feb-22 at 21:57The easiest way to output a high speed clock like this is with the MCO peripheral, rather than a timer. Fortunately for you the MCO pin is PA8. Perhaps the person who designed your board knew this and intended you to use MCO. Read the reference manual to see how.
If you do want to use a timer to do 22MHz, then as you have correctly identified you cannot get a 50% duty-cycle on your PWM. I would recommend starting with a 40% or 60%, with an output-compare value of 2-out-of-5 or 3-out-of-5, not 1 as you have above.
There is no detail in the PCA9959 datasheet about what the required mark-space ratio of the clock is, but I guess anything other than 50% could be a problem. You would be better to divide the clock by an even number. Either just divide 110MHz by 6 and output 18.33MHz, or else slow your core down a bit and divide by 4 (reduce the N parameter of your PLL).
Whether you use MCO or PWM don't forget to set the GPIO pin mode to the fastest slew rate available. Maybe the 8MHz you are measuring is the result of aliasing a faster clock that has been through the wrong GPIO mode. You could test this using a scope with at least 100MHz bandwidth.
QUESTION
I am implementing a pulse width modulation module to learn chisel3.
The module code is:
ANSWER
Answered 2022-Jan-24 at 20:33In Chisel 3, RegInit
is referring to a register with reset. There is experimental support for treating an asynchronous reset line as an "initial" line instead, but I want to caution that it's not something I would recommend using in typical digital design.
As you are probably aware, initial values are not universally supported in actual hardware. They are supported by some (but not all) FPGAs, and are not supported at all in ASICs. Thus writing code that relies on initial values is inherently unportable which runs counter to the ethos of Chisel for constructing resuable hardware generators.
That being said, they can make certain designs use resources on certain FPGAs much more efficiently, so we do have a way to do this:
QUESTION
I'm trying to modify the frequency of a pwm timer at runtime but I don't know how exactly the counter overflow is triggered described in the reference manual.
The output should be a short pulse of constant width (constant TIMx_CCRx
) with a variable frequency (TIMx_ARR
) in upcounting, edge-aligned mode (p.354 and 372 in the reference manual).
I want to be able to adjust the frequency faster than the minimum archivable output frequency should be.
Eg. the tick time (CK_CNT
) is 1 ms, the maximum time is 1000 ms and I want to be able to update the ARR value every 100 ms.
When the new ARR value is higher than the current counter register value the timer should continue counting up.
When the new ARR value is smaller than the current counter register value the timer should create a counter overflow and restart from 0.
To be able to update the auto-reload register every 100 ms I disabled ARR-preloading (ARPE=0
).
What would happen when I write a value into the ARR register smaller than the current counter register value? There is only an example for when the new ARR value is bigger than the counter value on p.356.
Would a counter overflow trigger and the timer starts from 0?
Do I have to create an update event (UEV
) manually?
Do I have to check the counter value and restart the timer manually if the new ARR value would be lower?
ANSWER
Answered 2022-Jan-18 at 14:12I didn't find anything in the reference manual but finally got to test the behaviour on actual hardware:
- Setting the ARR to a value lower than the current counter value doesn't create an interrupt/update event/etc, the timer keeps counting up
- Manually creating an update event automatically restarts the counter
- Setting the ARR to the current counter value creates an update event
I don't want to restart the counter when setting the ARR value to something higher than the counter value. The solution is to create a manual update event when the ARR value is lower than the counter value. There shouldn't be a problem with the counter reaching ARR while setting it because that automatically creates an update event.
This seems to work as expected:
QUESTION
While reading a book about modern C++, I have seen a code snippet that confused me. The code has been written to set up PWM (16 bit Timer) for 8 bit AVR microcontroller. The code is like that:
...ANSWER
Answered 2022-Jan-13 at 11:11This code seems severely over-engineered, which is always the biggest danger whenever you allow C++. The language tends to encourage making things needlessly complicated just for the heck of it, instead of utilizing the KISS principle.
The hard requirements are: on the given hardware, the CPU works fastest with 8 bit types but the PWM register is 16 bits. Period.
Therefore any variable describing period or duty cycle needs to be exactly 16 bits. It doesn't make sense to declare it as uint_fast16_t
because the corresponding hardware registers will always be exactly 16 bits, no more, no less.
In general the uint_fast
types are only helpful if planning to port this to a 32 bit system somehow, but it is very unlikely that there will exist a 32 bit MCU with an identical PWM peripheral. Thus in this case uint_fast
is just useless noise, because the code will never get ported.
The cast to uint8_t
supposedly truncates the 16 bit value to the 8 least significant bits. If so, the cast is incorrect, it should never be static_cast
but static_cast
. I'm otherwise not quite following what the code is supposed to do, update the duty cycle somewhere, I would assume.
Furthermore, disabling the interrupt mask as a re-entrancy protection feature probably doesn't make sense, as this can cause unexpected timing problems. If this class is to be used from inside an ISR then another protection mechanism might be more suitable, such as a semaphore or atomic access/inline asm. PWM in particular is picky with when/how you change the duty cycle, or you might get glitches.
Overall, I would strongly recommend not to use C++ on an ancient, severely resource-confined 8 bit microcontroller. Or to use ancient 8 bit microcontrollers instead of ARM when learning embedded systems, 8-bitters are much harder to program in C (or C++) than 32-bitters.
QUESTION
I am trying to implement PWM using Timer0 for Atmega328P in C++. Indeed, I have achieved this. But, I have another related problem.
I have a PWM abstract base class that provides an interface for PWM implementation.
...ANSWER
Answered 2022-Jan-09 at 14:12You can create global callback object (visible to the ISR) that should register the actual action to be taken. Generally the callable needs to be visible to the ISR, i.e. it needs to live int ISR's scope.
noexcept
suggests you're on C++11 or higher. If not, you'll need to fall back to boost or do some more typing...
QUESTION
My operating system is windows 10 with latest Docker Desktop and the app is running on node 16(docker nodejs)
Here is my nginx conf file at: ./nginx/default.conf(windows 10 machine)
...ANSWER
Answered 2021-Dec-20 at 12:11That's easy: You are missing a semicolon within nginx/default.conf, you have to write:
QUESTION
I want to create a Micropython-Class for an LED-Strip. When initializing, the class can be called with any number of color=Pin pairs.
So my idea was to call def __init__(self, **kwargs)
and then use:
ANSWER
Answered 2021-Dec-12 at 23:35Since your colors are the keys of kwargs
, which is a regular dictionary, you can do
QUESTION
I'm trying to setup a simple flask webpage to control a 3d Xmas Tree running on a raspberry pi. I've posted the code for the app and the template below. So far it works in that I can run a single function, such as Flicker and then perform either the Reset or Off functions. However, I am not able to call other functions following that. And if I run Flicker and then Random or All Flash they kind of blend together. My goal is to be able to cleanly stop GPIO output via the reset or off functions and call each respective function via the webpage's buttons or links.
app2.py
...ANSWER
Answered 2021-Dec-09 at 17:50Hi I don't have your setup so I couldn't test fully. But I think you want a background loop, and use global state to manage interaction with tree (since there is physically one tree.)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install PWM
PHP requires the Visual C runtime (CRT). The Microsoft Visual C++ Redistributable for Visual Studio 2019 is suitable for all these PHP versions, see visualstudio.microsoft.com. You MUST download the x86 CRT for PHP x86 builds and the x64 CRT for PHP x64 builds. The CRT installer supports the /quiet and /norestart command-line switches, so you can also script it.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page