Questions tagged [pwm]

PWM (Pulse-width modulation) is a technique for controlling power to electrical devices, made practical by modern electronic power switches.

468 questions
0
votes
1 answer

Does PWM (analogWrite()) need to be turned off before changing states of pins?

If I have: analogWrite(4, 123); Do I need to turn the PWM off like this: analogWrite(4, 0); If I'd like to set pin HIGH or LOW? digitalWrite(4, HIGH); In practice, changing pin HIGH/LOW works without turning PWM off but I'm encountering some…
Defozo
  • 2,946
  • 6
  • 32
  • 51
0
votes
1 answer

HW Timer (PWM) or SW Timer to control a LED

As the title says, is it generally good practice to use General Purpose Timers for dimming a LED (PWM with variable duty cycle) or is it better to use OS scheduling/tasks when available (RTOS ecc)? I recently saw an example of a blinking led using…
Luigi
  • 376
  • 3
  • 16
0
votes
1 answer

PWM without sysfs

I am pretty new to linux kernel.I am trying to generate PWM through linux. The API man talks about a sysfs interface. I want to implement a userspace program in C. But using PWM forces me to use a command line. Furthermore, using read, write is a…
gPats
  • 315
  • 2
  • 17
0
votes
1 answer

C++ wiringPi Crash

I am trying to create a program that controls a servo motor using wiringPi. However, as soon as I call wiringPiSetupGPIO(); my Pi crashes. Any Idea why this might be happening? My code so far: #include #include #include…
0
votes
1 answer

Why does PWM pin 9 (on my Elegoo Mega2560) behave differently to pins 7 and 8?

I have an RGB LED hooked up to pins 7,8 and 9 on my Elegoo Mega2560. If I apply analogWrite(, 255) to each pin, I get a white light as expected. However, if instead, I apply analogWrite(, 225) to each pin, I get a yellow light, as if the blue pin 9…
pinoyyid
  • 21,499
  • 14
  • 64
  • 115
0
votes
1 answer

Arduino PWM generating

I am new on Arduino. I am trying to use the board to generate a PWM to control a IGBT switch. The following is my code. I didnt get the pulse I expected. Does anyone have idea of what's going on? Thanks int pinOut = 13; void setup() { …
Suzy.W
  • 1
0
votes
1 answer

UWP: Cannot load PWM Controllers using Lightning on Raspberry Pi 2?

i justed started working on an older Project i started once, but unfortunately the PWM Controller is not working anymore with the Lightning Driver. I am using Visual Studio 2017, the RPi2 is running at 10.0.15063.414 and I've installed the following…
Roland
  • 133
  • 2
  • 12
0
votes
1 answer

Is a TIM interrupt also blocking background counting on STM32?

As the title says, with an STM32 if an interrupt lasts for 1 microsecond should one compensate the CCR by 1 microsecond converted in counter cycles in order to achieve the correct duty cycle? For example with a period of 100Khz and an overflow…
Luigi
  • 376
  • 3
  • 16
0
votes
1 answer

Motor rotates only one direction with L293D controller

Hello I have an RC car which has two 3v motors (one for left/right and the other one for forward/back). The left and right motor is working fine but when I try to rotate the other motor it rotates only back. I've tried the motor separately and it…
Hunor Gocz
  • 137
  • 12
0
votes
1 answer

Update ARR and CCR1 delays function return by 6us

I need to vary the frequency and duty cycle of a pwm using stm32f401. Inside the "pulse finished" pwm callback i've tried the following code HAL_GPIO_WritePin(LED5_PORT, LED5_PIN, GPIO_PIN_RESET); //tentative 1 //TIM9->ARR =…
Luigi
  • 376
  • 3
  • 16
0
votes
0 answers

How to send bytes to AVR and use it on PWM

I am trying to send integers from 0 to 255 to my Atmega8L AVR, and use that value as PWM and light up a LED for each pin (3 pins)... I am doing this in Java (Android) to send data to my AVR via USART: byte toSend[] = {(byte)intA, (byte)intB,…
0
votes
1 answer

Atmega2560 PWM on PB7

I am trying to get PWM output from PB7 pin with timer0 on Atmega2560 with no luck. It should generate tone for the connected repro.My PWM settings are: DDRB = 0b11100000; PORTB = 0b00000000; OCR0A = 0x04; TCCR0A = (0 << COM0A1) | (1 << COM0A0)…
Radim Sejk
  • 5
  • 1
  • 5
0
votes
1 answer

Pulse width modulation (PWM) on Attiny 9

I am using an Attiny 9. I connected a LED to PB1. I wrote following code and upload it to the Attiny 9. #define F_CPU 800000UL #include #include #include #include #define D0 PB1 int…
neosarchizo
  • 648
  • 1
  • 7
  • 16
0
votes
2 answers

Simple DC motor Speed Control with Push Button

I'm running some tests on STM32L152 by trying to control a DC motor speed by selecting 3 different speeds using a push button, as following: ideal mode, motor is off. push button pressed, motor runs at speed-1 push button pressed again, motor runs…
lightworks
  • 21
  • 1
  • 9
0
votes
2 answers

RPI Drive servo by PWM (wiringpi / C programming)

I trie to drive a servo with the Raspberry PI using the PWM on GPIO Pin 18 i wired the setup like you can see below. When i drive the servo i can do this without any problems the commands that i use you can see below. gpio -g mode 18 pwm …
sanderfcb95
  • 59
  • 1
  • 12