PWM Sample Code?

View: New views
8 Messages — Rating Filter:   Alert me  

PWM Sample Code?

by David Rye :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Can anyone point me at gumstix PWM sample code, preferably in C?

Parent Message unknown Re: PWM Sample Code?

by David Novick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>
> ----- Original Message ----
> From: David Rye <d.rye@...>
> To: gumstix-users@...
> Sent: Wednesday, May 21, 2008 5:41:15 AM
> Subject: [Gumstix-users]  PWM Sample Code?
>
>
>
> Can anyone point me at gumstix PWM sample code, preferably in C?
>
> --
> View this message in context: http://www.nabble.com/PWM-Sample-Code--tp17364147p17364147.html
> Sent from the Gumstix mailing list archive at Nabble.com.

I was wondering that myself, since:
http://docswiki.gumstix.com/index.php?title=Sample_code/C/PWM&action=edit

is missing the actual code! :)


     

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gumstix-users mailing list
gumstix-users@...
https://lists.sourceforge.net/lists/listinfo/gumstix-users

Re: PWM Sample Code?

by Dave Hylands :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi guys,

>> Can anyone point me at gumstix PWM sample code, preferably in C?
>
> I was wondering that myself, since:
> http://docswiki.gumstix.com/index.php?title=Sample_code/C/PWM&action=edit
>
> is missing the actual code! :)

That's because nobody has yet create the PWM page :)

Are you looking for PWM for the purposes of controlling something like
a backlight?
Or PWM code for controlling somehing like an R/C servo?

--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gumstix-users mailing list
gumstix-users@...
https://lists.sourceforge.net/lists/listinfo/gumstix-users

Parent Message unknown Re: PWM Sample Code?

by David Novick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> >> Can anyone point me at gumstix PWM sample code, preferably in C?
> >
> > I was wondering that myself, since:
> > http://docswiki.gumstix.com/index.php?title=Sample_code/C/PWM&action=edit
> >
> > is missing the actual code! :)
>
> That's because nobody has yet create the PWM page :)

Well, that makes sense, but shouldn't it say something other than:
"The action you have requested is limited to users in the group user."

It would be less confusing!  :)

>
> Are you looking for PWM for the purposes of controlling something like
> a backlight?
> Or PWM code for controlling somehing like an R/C servo?

I'm just looking for examples on playing with the memory mapped registers and GPIO from with C.
Controlling an R/C servo would be fine for me.

I did come across this:
paxRC - R/C and robotics software for Linux/PXA255/PXA270
http://www.pabr.org/pxarc/doc/pxarc.en.html

but I haven't dug into the code yet.


     

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gumstix-users mailing list
gumstix-users@...
https://lists.sourceforge.net/lists/listinfo/gumstix-users

Re: PWM Sample Code?

by Dave Hylands :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi David,

>  > That's because nobody has yet create the PWM page :)
>
>  Well, that makes sense, but shouldn't it say something other than:
>  "The action you have requested is limited to users in the group user."
>
>  It would be less confusing!  :)

Yeh - what's happening is that when you create a page and put a wiki
link to a non-existant page, then they expect that you're going to
want to create the page, so the link is actually a link to "Edit the
page named PWM". In order to edit a page, you need to be logged in.

So that's why it is the way it is. You could login and create an empty
placeholder page to get rid of that :)

>  > Are you looking for PWM for the purposes of controlling something like
>  > a backlight?
>  > Or PWM code for controlling somehing like an R/C servo?
>
>  I'm just looking for examples on playing with the memory mapped registers and GPIO from with C.

Then the GPIO example code should do what you want.
<http://docswiki.gumstix.com/index.php/Sample_code/C/gpregs>

Just change:

#ifdef __ARM_EABI__
              0x40E00000 / MAP_SIZE
#else
              0x40E00000 & ~MAP_MASK
#endif

to be
              0x40E00000 & ~MAP_MASK

>  Controlling an R/C servo would be fine for me.
>
>  I did come across this:
>  paxRC - R/C and robotics software for Linux/PXA255/PXA270
>  http://www.pabr.org/pxarc/doc/pxarc.en.html

Yeah - that's what I was going to point you to if it was R/C servos
you were interested in.

--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gumstix-users mailing list
gumstix-users@...
https://lists.sourceforge.net/lists/listinfo/gumstix-users

Re: PWM Sample Code?

by Michael Caughey :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Whom ever does log in and create te page, can we place some sample code
there too, :-)  I'm heading down that road and will be needing it soon
enough.  If not i'll see what I can do after figuring it out, but that will
be a while.

-Michael


----- Original Message -----
From: "Dave Hylands" <dhylands@...>
To: "General mailing list for gumstix users."
<gumstix-users@...>
Sent: Wednesday, May 21, 2008 1:08 PM
Subject: Re: [Gumstix-users] PWM Sample Code?


> Hi David,
>
>>  > That's because nobody has yet create the PWM page :)
>>
>>  Well, that makes sense, but shouldn't it say something other than:
>>  "The action you have requested is limited to users in the group user."
>>
>>  It would be less confusing!  :)
>
> Yeh - what's happening is that when you create a page and put a wiki
> link to a non-existant page, then they expect that you're going to
> want to create the page, so the link is actually a link to "Edit the
> page named PWM". In order to edit a page, you need to be logged in.
>
> So that's why it is the way it is. You could login and create an empty
> placeholder page to get rid of that :)
>
>>  > Are you looking for PWM for the purposes of controlling something like
>>  > a backlight?
>>  > Or PWM code for controlling somehing like an R/C servo?
>>
>>  I'm just looking for examples on playing with the memory mapped
>> registers and GPIO from with C.
>
> Then the GPIO example code should do what you want.
> <http://docswiki.gumstix.com/index.php/Sample_code/C/gpregs>
>
> Just change:
>
> #ifdef __ARM_EABI__
>              0x40E00000 / MAP_SIZE
> #else
>              0x40E00000 & ~MAP_MASK
> #endif
>
> to be
>              0x40E00000 & ~MAP_MASK
>
>>  Controlling an R/C servo would be fine for me.
>>
>>  I did come across this:
>>  paxRC - R/C and robotics software for Linux/PXA255/PXA270
>>  http://www.pabr.org/pxarc/doc/pxarc.en.html
>
> Yeah - that's what I was going to point you to if it was R/C servos
> you were interested in.
>
> --
> Dave Hylands
> Vancouver, BC, Canada
> http://www.DaveHylands.com/
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> gumstix-users mailing list
> gumstix-users@...
> https://lists.sourceforge.net/lists/listinfo/gumstix-users
>



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gumstix-users mailing list
gumstix-users@...
https://lists.sourceforge.net/lists/listinfo/gumstix-users

Re: PWM Sample Code?

by David Rye :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Dave,

I was just after a simple example that shows how to configure the hardware and set base frequency and duty cycle.

Dave Hylands wrote:
Hi guys,

>> Can anyone point me at gumstix PWM sample code, preferably in C?
>
> I was wondering that myself, since:
> http://docswiki.gumstix.com/index.php?title=Sample_code/C/PWM&action=edit
>
> is missing the actual code! :)

That's because nobody has yet create the PWM page :)

Are you looking for PWM for the purposes of controlling something like
a backlight?
Or PWM code for controlling somehing like an R/C servo?

--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gumstix-users mailing list
gumstix-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gumstix-users

Re: PWM Sample Code?

by Chris Dollar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I used this bit of code in the past in an init script to set the contrast on an lcd I had connected to my connex. I got the code originally from a post to the list iirc...

PXAREGS=/usr/sbin/pxaregs
start() {
        echo "Setting LCD contrast on PWM1"
    # set GPIO to AF2
    $PXAREGS GAFR0U_17 2
    # as an output
    $PXAREGS GPDR0_17 1
    # set the period
    $PXAREGS PWMPERVAL1 375
    # set the prescale to 0
    $PXAREGS PWMCTL1_PRESCALE 0
    # configure it for a graceful shutdown
    $PXAREGS PWMCTL1_SD 0
    # set FDCYCLE to 0
    $PXAREGS PWMDUTY1_FDCYCLE 0
    # and set the duty cycle
    $PXAREGS PWMDUTY1_DCYCLE 200
    # and turn on the PWM clock
    $PXAREGS CKEN_1 1
    # done!
}

Hope this helps.

Chris


On Wed, May 21, 2008 at 3:49 PM, David Rye <d.rye@...> wrote:

Hi Dave,

I was just after a simple example that shows how to configure the hardware
and set base frequency and duty cycle.


Dave Hylands wrote:
>
> Hi guys,
>
>>> Can anyone point me at gumstix PWM sample code, preferably in C?
>>
>> I was wondering that myself, since:
>> http://docswiki.gumstix.com/index.php?title=Sample_code/C/PWM&action=edit
>>
>> is missing the actual code! :)
>
> That's because nobody has yet create the PWM page :)
>
> Are you looking for PWM for the purposes of controlling something like
> a backlight?
> Or PWM code for controlling somehing like an R/C servo?
>
> --
> Dave Hylands
> Vancouver, BC, Canada
> http://www.DaveHylands.com/
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> gumstix-users mailing list
> gumstix-users@...
> https://lists.sourceforge.net/lists/listinfo/gumstix-users
>
>

--
View this message in context: http://www.nabble.com/PWM-Sample-Code--tp17364147p17377873.html
Sent from the Gumstix mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gumstix-users mailing list
gumstix-users@...
https://lists.sourceforge.net/lists/listinfo/gumstix-users


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gumstix-users mailing list
gumstix-users@...
https://lists.sourceforge.net/lists/listinfo/gumstix-users