Pages: [1]   Go Down
Author Topic: Lost looking for PWM library  (Read 205 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I'm new to Arduino and the Due, but I have a good deal of experience programming 8-bit AVRs in C.

I'm using the Due because I need the additional speed and capabilities.

Right now I'm trying to program a PWM channel with a base frequency somewhere in the 5kHz-10kHz range... well withing the capabilities of the SAM3X.

In may searches I have found mention of a library called PWM.h that sounds like it will do exactly what I need.  I have also found posts that suggest making modifications to variant.h will get me where I need to go.

I would like to look into both of these options, but I'm having trouble finding either.  The PWM library I think is an add-on, but I'm not sure where to find it.   Variant.h seems to be part of the base library structure, but where does the variant.h library live?  I can't find it on my mac with spotlight?

Thanks,

Bill
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 514
Posts: 31540
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Go to the Arduino application. Alt click and choose "Show Contents" from the drop down menu.
Then in the window type in PWM in the search box at the top of the window. You will then see them all.
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the quick reply.

Those instructions don't seem to be working for me.  I wonder if it is because I am on a Mac?

When I go to the apps folder, I click on the Arduino.app with my control key held down.  I get a menu with the option "Show Package Contents"... which I then chose.

Then the following window pops up.



I don't see the stuff there, and spotlight doesn't help either?  What have I done wrong?

Thanks,

Bill
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 514
Posts: 31540
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes I am on a mac as well. You are not doing the search in the top right of the window.

Then in the window type in PWM in the search box at the top of the window. You will then see them all.

This is what I get:-


* pwm.png (554.01 KB, 2010x1118 - viewed 15 times.)
« Last Edit: April 07, 2014, 04:12:20 pm by Grumpy_Mike » Logged

Offline Offline
Jr. Member
**
Karma: 1
Posts: 64
Good Vibes, Bad Vibes, Random Vibe
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's a library I wrote for the Due (link below).  It allows you to setup up to two PWM channels each with a unique frequency.  Login to get the library.  Example included below.  Good luck.

http://forum.arduino.cc/index.php?topic=144446.msg1149044#msg1149044
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey Random!
I had just found your lib on my own and installed it.  Works great!!!  Thanks so much.

Grumpy,
I'm still not finding anything in the finder per your instructions... but now my PWM issue appears solved... so I'm off to find the next wall to bang my head against.  This time with a slightly better understanding of the landscape.  Thanks so much for your help.  It is much appreciated.

Best,

SwarfEye
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

PS.

Random, I noticed in reading over the SAM3X datasheet that there are some functions in the PWM register that are designed to allow you to time A2D readings with your PWM wave form.  Have you played with this feature at all?  I'm gonna need it as my PWM is going to drive some Mosfets which are in turn driving a motor which will be broadcasting PWM noise straight into the ear of my sensor!

Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok,

I think I'm making some progress.  I found the verbose compiler option in preferences, and that got me looking in the hidden /var directory.

I switched out of finder and into X11 and I'm seeing a lot more.

Thanks for your help.

Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 514
Posts: 31540
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Grumpy,
I'm still not finding anything in the finder per your instructions...

How have you got your finder preferences set?


* finder.png (148.49 KB, 766x594 - viewed 8 times.)
Logged

Pages: [1]   Go Up
Jump to: