User avatar
AwaX
Posts: 14
Joined: Mon Mar 04, 2013 8:09 am
Location: France

Re: Generate 2 pwm signals

Fri Mar 15, 2013 10:48 am

The microcontroller way seems to be easier and cheaper but maybe I'm wrong.

So with this way, I would only need to develop the UART interface with the microcontroller and the microcontroller outputs will be my PWM signals ?
And will I need some extra features to program the microcontroller or just my computer ?

Have you already got some good documentations on it ?
I found this one : An Introduction to programming an Atmega
microcontroller


@metachris :
Is it a sort of software generated signals ? It seems to be a nice way to do it programmatically. I will do some researches on DMA even if I would prefer the analogue way. Because my goal when I ordered my RPi (which I will receive very soon !) was to improve myself in electronics :)

User avatar
metachris
Posts: 96
Joined: Wed Feb 06, 2013 1:52 pm
Location: Vienna, Austria

Re: Generate 2 pwm signals

Fri Mar 15, 2013 11:57 am

AwaX wrote:@metachris :
Is it a sort of software generated signals ? It seems to be a nice way to do it programmatically. I will do some researches on DMA even if I would prefer the analogue way. Because my goal when I ordered my RPi (which I will receive very soon !) was to improve myself in electronics :)
Always a rewarding endeavor :)

Re your question: RPIO.PWM uses a semi-hardware method to generate pulses. The onboard PWM hardware from the soundcard is used for the pulse-timing (very accurate up to 1-2us) and the DMA to set/clear gpio's without any interaction with the processor/application. The documentation describes it in more detail: http://pythonhosted.org/RPIO/pwm_py.html
pythonhosted.org/RPIO

User avatar
AwaX
Posts: 14
Joined: Mon Mar 04, 2013 8:09 am
Location: France

Re: Generate 2 pwm signals

Fri Mar 15, 2013 3:04 pm

Ok thank you, I will read this carefully :)

tummychow
Posts: 41
Joined: Wed Feb 20, 2013 6:36 am

Re: Generate 2 pwm signals

Mon Mar 18, 2013 12:08 am

Many of the solutions seem to be massively overcomplicated. As mahjongg said, the right solution is to simply grab an extra chip that can generate PWMs for you, and learn how to interface it. There are plenty such ICs on the market, and any solution involving more than two chips is probably making it harder than it needs to be. Anything involving analog signals of any kind is making this harder than it needs to be. Grabbing a microcontroller just to generate PWM outputs is also a bit excessive, like killing ants with a flamethrower. There are much easier ways to add PWMs to a raspberry pi.

Things like the adafruit breakout (based on an NXP chip whose name I cannot remember) or TCA6507 are pretty good if you have them, and they're i2c chips so they only require 2 lines to control. However they're surface mount devices which may be inconvenient for a hobbyist. You can find breakout boards that put SMT chips into a through-hole footprint, but that adds cost and it's also kind of annoying.

The easiest solution by far, then, is to use a simple DIP PWM driver, such as the TLC5940 which plenty of people know how to use (http://flipmu.com/files/2011/04/Demysti ... LC5940.pdf). The interface and logic is the same as a shift register (basically it's SPI) and there's plenty of work available on how to use it. Comes in a PDIP package (28 pins iirc), 16 PWM channels. You aren't going to get sixteen channels with any solution cobbled out of a 555 timer. Not as powerful as the i2c chips (it requires an external PWM clock, which is kind of inconvenient. the adafruit chip is free-running, meaning that it clocks itself) but more than enough to get this job done in one package.

If you want to do the PWM in software, I have seen some implementations of that in this forum, looks promising. Not sure how rigorous it would be though, since you have to rely on the OS to schedule, and it's not a real-time system, etc etc. I'd be more confident in an external chip.

User avatar
joan
Posts: 14078
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Generate 2 pwm signals

Mon Mar 18, 2013 9:06 am

tummychow wrote:Many of the solutions seem to be massively overcomplicated.
...
The least complicated and quickest solution is to use one of the software solutions which program a DMA channel to generate PWM. Once setup the hardware generates the PWM without software involvement.

User avatar
AwaX
Posts: 14
Joined: Mon Mar 04, 2013 8:09 am
Location: France

Re: Generate 2 pwm signals

Wed Mar 27, 2013 9:38 am

@tummychow :
Thank you for your response. Yes you're right, some solutions are more complicated than needed but that's what I asked, I didn't want to buy an expansive adafruit driver which have a lot of functions I won't use while there are chipper ways to do it, even if it's complicated. Because my goal was to do it myself to learn new skills in electronics but the conclusion is, and you're right : without a proper PWM driver it's very hard to make it yourself !

So I think I will do it with the TLC5940, it seems to be the perfect chip for what I want and it's cheaper than other drivers like the adafruit driver.

So thank you all of you for your help ! And although some solutions led to nothing, I still learned some things haha.

gideon
Posts: 8
Joined: Fri Jun 21, 2013 5:46 pm

Re: Generate 2 pwm signals

Sun Jun 23, 2013 6:01 pm

mahjongg wrote:
  • Add hardware
    or
  • use software PWM's

What kind of hardware can I add as a newbie? Would this work by any chance:
http://www.mgsuperlabs.co.in/estore/Rob ... er-Carrier

gideon
Posts: 8
Joined: Fri Jun 21, 2013 5:46 pm

Re: Generate 2 pwm signals

Sun Jun 23, 2013 6:04 pm

rfincher1 wrote:We have been using the Adafruit PWM 16 board that gives you 16 PWM outputs with the 2 wire I2C connection.
What kind of motors does it work with?

The tutorial on this pagesays : "Note this cannot be used for driving anything other than analog (1-2 millisecond pulse drive) servos. DC motors, AC motors and digital servos are not going to work."

pirobots
Posts: 1
Joined: Sun Oct 19, 2014 4:44 pm

Re: Generate 2 pwm signals

Sun Oct 19, 2014 4:51 pm

You can generate PWM signal on all pins whichever you want...

https://www.youtube.com/watch?v=Ge3JN6foaZw

Return to “Automation, sensing and robotics”