Community
cancel
Showing results for 
Search instead for 
Did you mean: 
ONois
Novice
1,633 Views

How to change the polarity of PWM signal?

Jump to solution

Hi Makers,

I'm successfully using PWM signals on Galileo Gen2, but I cannot figure out how to change the polarity of the signal?

As per documentation I have found so far,

(in /sys/class/pwm/pwmchip0/pwm1/ folder) polarity - Changes the polarity of the PWM signal (read/write).Writes to this property only work if the PWM chip supports changing the polarity. The polarity can only be changed if the PWM is not enabled. Value is the string "normal" or "inversed".

So I have tried:

echo "normal" /sys/class/pwm/pwmchip0/pwm1/polarity

or

echo "inversed" /sys/class/pwm/pwmchip0/pwm1/polarity

And I get the following error: -sh: echo: write error: Function not implemented

So my question is: Does the PWM chip support changing the polarity? If yes, how to do that? If no, is there a work arround?

Thanks for your help on that Guys,

Olivier

0 Kudos
1 Solution
asss
Valued Contributor II
291 Views

Hi,

yes, PWM chip PCA9685 used in Galileo Gen2 supports a polarity inversion.

As I see PWM driver (kernel module for Gen2) does not support this feature.

Need to rewrite a kernel PWM driver to enable a polarity inversion.

BR,

xbolshe

View solution in original post

5 Replies
asss
Valued Contributor II
292 Views

Hi,

yes, PWM chip PCA9685 used in Galileo Gen2 supports a polarity inversion.

As I see PWM driver (kernel module for Gen2) does not support this feature.

Need to rewrite a kernel PWM driver to enable a polarity inversion.

BR,

xbolshe

View solution in original post

FTinetti
Honored Contributor I
291 Views

Hi Oliverleure,

Just curious: why do you need to invert the polarity? Isn't it enough to "invert" duty cycle?

Fernando.

ONois
Novice
291 Views

Hi Fernando,

I want to be able to change the direction of a DC motor. Inverting the duty cycle would work but apparently the driver doesn't support it.

Olivier

FTinetti
Honored Contributor I
291 Views

Hi Olivier,

I tought your problem was solved, because the question is marked as "answered"... please "unmark" it if not.

Oliverleure wrote:

Hi Fernando,

I want to be able to change the direction of a DC motor. Inverting the duty cycle would work but apparently the driver doesn't support it.

I see... I've made it relatively simple, what did you mean by "PWM chip" in your original post

Does the PWM chip support changing the polarity?

Did you mean the PCA9685 referred to by xbolshe? I know nothing about that chip and/or its usage. It does not seem to be related to DC motors according to

http://www.nxp.com/products/power-management/lighting-driver-and-controller-ics/ic-led-display-contr... PCA9685|NXP

www.nxp.com/documents/data_sheet/PCA9685.pdf

but again, I do not know the PCA9685.

Anoyhow, I've always used some H-bridge, such as L9110S or L293D for controlling DC motors... I use them in an Arduino controlled car (http://tpii-2015.esy.es/03-Galileo/ Proyecto con Galileo - https://www.youtube.com/watch?v=8kUqpHOWR6Q&feature=youtu.be Intel Galileo - Arduino Car - YouTube ). I've not used them in an Intel Galileo, but it should be the same. If you think it would be useful I could make some experiments and report back.

HTH,

Fernando.

asss
Valued Contributor II
291 Views

Hi,

need to speak about a logic inversion, not a voltage inversion in case of PCA9685.

•INVRT bit (MODE2 register) can be used to keep the LED PWM control firmware the

same independently of the type of external driver. This bit allows LED output polarity inversion/non-inversion only when OE=0

A voltage inversion requires to use external drivers for Galileo Gen2 board.

From Kernel documentation:

https://www.kernel.org/doc/Documentation/pwm.txt https://www.kernel.org/doc/Documentation/pwm.txt

polarity - Changes the polarity of the PWM signal (read/write).

Writes to this property only work if the PWM chip supports changing

the polarity. The polarity can only be changed if the PWM is not

enabled. Value is the string "normal" or "inversed".

When implementing polarity support in a PWM driver, make sure to respect the

signal conventions in the PWM framework. By definition, normal polarity

characterizes a signal starts high for the duration of the duty cycle and

goes low for the remainder of the period. Conversely, a signal with inversed

polarity starts low for the duration of the duty cycle and goes high for the

remainder of the period.

BR,

xbolshe

Reply