Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

PWM Timer Access


  • Please log in to reply
20 replies to this topic

#1 Omar (OZ)

Omar (OZ)

    Advanced Member

  • Members
  • PipPipPip
  • 564 posts

Posted 06 September 2010 - 01:15 AM

The Gadget Shield from Rugged Circuits is a nice shield, we just need the PWM timer access to get the most out of it.

Hello OZ,

Apparently this is going to have to wait as the Netduino code base doesn't yet support PWM timer access or input capture timing. In general we're finding it hard to find reference documentation for the Netduino and the transition from Arduino to Netduino is not very smooth because of this deficiency.

We will have to revisit the Netduino as a supported platform once it is a bit more evolved.

Regards,


EDIT:
As Chris said, they plan on extending the PWM features in the next firmware. Until then the other inputs and outputs should keep me busy.

#2 RuggedCircuits

RuggedCircuits

    Member

  • Members
  • PipPip
  • 17 posts

Posted 06 September 2010 - 01:29 AM

In order to be civil and respectful I won't mention the ridiculous company that excluded these compatibility issues. So this is what they said to me...



So Chris I guess you should know this... is it going to be supported soon?


Hello, Ridiculous Company here :) I'll post the same thing I sent to you privately:

"I understand your frustration. However, it is not an issue of compatibility, it is one of software. We sell a hardware product. The demonstration software on our web site is just that, for demonstration. The hardware product is compatible with the Netduino as long as AREF is connected to 3.3V, which we clearly communicated to you prior to your purchase."

Our Gadget Shield is an Arduino shield that is hardware compatible with the Netduino. If one wants to use the analog inputs, then the AREF input must be connected to 3.3V, a service that we provided for you for free when you ordered your board.

The demonstration software that we provide on the web site is written in C/C++ for an Arduino environment. It does not port directly to a C#/.NET environment. This is not an issue of compatibility, but of porting code to a different development and hardware environment.

Do you really expect to get any Arduino shield and have its associated software immediately work with the Netduino?
Rugged Circuits LLC / <http://ruggedcircuits.com>

#3 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 06 September 2010 - 01:49 AM

Hey RuggedCircuits, It sounds like a driver issue, not a hardware issue here... Is that correct? We've also ordered one of your Gadget Shields to look at a bit later in the month--looking forward to it... We're expanding the PWM support in the upcoming v4.1.1 firmware (and will continue expanding it into the future). Right now, we're focused on enabling low-level configuration of the PWM clocks and such--but we'd also like to help support creating triangle waves and doing other advanced PWM logic from managed code in the future. Maybe we could create a "feature requests" forum and start a thread on PWM--to better guide new developments to the firmware by both Secret Labs and by the community? There's a lot built into .NET Micro Framework, but as a community we can do so much more... Chris

#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 06 September 2010 - 01:52 AM

RuggedCircuits -- are you looking for capture of incoming signals or are you looking to do something low-level with the PWM itself? As far as incoming signals, one of the community members already built an infrared decoder (RC6 I believe) using the InterruptPort and the DateTime passed into its event handler. Chris

#5 Omar (OZ)

Omar (OZ)

    Advanced Member

  • Members
  • PipPipPip
  • 564 posts

Posted 06 September 2010 - 01:56 AM

Do you really expect to get any Arduino shield and have its associated software immediately work with the Netduino?

I really don't want to argue with you but you didn't mention the PWM thing before. I just suggested that you inform people about the issues on your website, and you got defensive. But I guess now they know since you wanted to defend your point of view so badly.

#6 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 06 September 2010 - 02:01 AM

Just a reminder that we should all be civil here :) OZ, let's see if we can figure out what support that Rugged Circuits needs to enhance Netduino support for their platform--and then go from there. Thanks for continuing to push the limits of the platform, and for all your efforts... Chris

#7 RuggedCircuits

RuggedCircuits

    Member

  • Members
  • PipPip
  • 17 posts

Posted 06 September 2010 - 02:01 AM

Hey RuggedCircuits,

It sounds like a driver issue, not a hardware issue here... Is that correct?


Correct. The hardware, as mentioned above, is compatible thanks to your intelligent assignment of function pins on the Netduino to be compatible with similar functions on the Arduino. There is nothing preventing someone from writing native code to use the hardware resources of the AT91SAM7X512 processor to take full advantage of the onboard sensors and actuators. Higher-level constructs like a PWM class, however, would greatly simplify tasks and isolate the programmer from the low-level hardware details of the timers and such.

We're expanding the PWM support in the upcoming v4.1.1 firmware (and will continue expanding it into the future). Right now, we're focused on enabling low-level configuration of the PWM clocks and such--but we'd also like to help support creating triangle waves and doing other advanced PWM logic from managed code in the future.


For the Gadget Shield, PWM would be used to modulate the colors of the RGB LED (low frequency, duty cycles varying from 0% to 100%) as well as generate 38 kHz waveforms for the IR transmitter LED (38 kHz frequency, obviously, at 50% duty cycle).

Hope that helps!
Rugged Circuits LLC / <http://ruggedcircuits.com>

#8 RuggedCircuits

RuggedCircuits

    Member

  • Members
  • PipPip
  • 17 posts

Posted 06 September 2010 - 02:03 AM

RuggedCircuits -- are you looking for capture of incoming signals or are you looking to do something low-level with the PWM itself? As far as incoming signals, one of the community members already built an infrared decoder (RC6 I believe) using the InterruptPort and the DateTime passed into its event handler.

Chris


That sounds like a reasonable option but better would be a class that implements an "InputCapture" functionality so that input edges are timestamped. That's the approach we use with our demonstration IR decoder software for the Arduino. I'm fairly sure the AT91SAM7X512 processor can have its timers configured for this type of capture mode.
Rugged Circuits LLC / <http://ruggedcircuits.com>

#9 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 06 September 2010 - 02:12 AM

For the Gadget Shield, PWM would be used to modulate the colors of the RGB LED (low frequency, duty cycles varying from 0% to 100%) as well as generate 38 kHz waveforms for the IR transmitter LED (38 kHz frequency, obviously, at 50% duty cycle).


Hmm, let me get more details on what you need here...

For the RGB LED, it looks like you're using digital pins 5, 6, and 10. The PWM on the Netduino drives all four of these--and then PWM feature to drive duty cycle is already in the firmware. What additional functionality do you need? The ability to change the frequency?

As for the IR transmitter, the upcoming v4.1.1 release will allow you to set the low-level PWM frequency (based on a standard divisor of the 48MHz MCU clock speed) and then set custom intervals/periods for PWM square waves. Is this enough for what you need to do--or do you need something where you can submit a byte array and then have a sequence of pulses sent with different periods? A constant 38 KHz signal with 50% duty cycle will be easy with 4.1.1 -- but I want to see what else you might need here...

Chris

#10 Omar (OZ)

Omar (OZ)

    Advanced Member

  • Members
  • PipPipPip
  • 564 posts

Posted 06 September 2010 - 02:13 AM

Just a reminder that we should all be civil here :)

OZ, let's see if we can figure out what support that Rugged Circuits needs to enhance Netduino support for their platform--and then go from there. Thanks for continuing to push the limits of the platform, and for all your efforts...

Chris

Alright, I am a total newb so I don't think I can help much, other than testing alpha stuff.

I am sorry that I reacted badly RuggedCircuits, I am just upset that I couldn't do what I was expecting.

#11 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 06 September 2010 - 02:15 AM

That sounds like a reasonable option but better would be a class that implements an "InputCapture" functionality so that input edges are timestamped. That's the approach we use with our demonstration IR decoder software for the Arduino. I'm fairly sure the AT91SAM7X512 processor can have its timers configured for this type of capture mode.


Hmm, could you tell me more of what you're looking at?

Would a C# wrapper around the InterruptPort give you what you needed? Basically, the wrapper would just take readings from the InterruptPort's event handler and build them into an Array of timings...

Here's the RC6 decoder by community member Phil... What do you need in addition to the timestamps he's using?
http://forums.netdui...-decoder-class/

Chris

#12 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 06 September 2010 - 02:16 AM

Alright, I am a total newb so I don't think I can help much, other than testing alpha stuff.


Your alpha/beta testing help is much appreciated! As are the videos, samples you share with the community, etc.

Chris

#13 RuggedCircuits

RuggedCircuits

    Member

  • Members
  • PipPip
  • 17 posts

Posted 06 September 2010 - 02:22 AM

Hmm, let me get more details on what you need here...

For the RGB LED, it looks like you're using digital pins 5, 6, and 10. The PWM on the Netduino drives all four of these--and then PWM feature to drive duty cycle is already in the firmware. What additional functionality do you need? The ability to change the frequency?


Where in the firmware? I looked for PWM code samples and didn't find any. Microsoft's .NET documentation site linked from your home page has no mention of PWM. Searching for PWM in your forums fails because search terms less than 4 characters are rejected. I looked in the source and all the PWM functions seemed to be stubs. I apologize but coming from the Arduino world the C#/.NET model is still very foreign. Please please PLEASE come up with something like this to help us Ardufolks out:

http://arduino.cc/en...erence/HomePage

And code samples wouldn't hurt either B) Not in the forums...on the web site.

As for the IR transmitter, the upcoming v4.1.1 release will allow you to set the low-level PWM frequency (based on a standard divisor of the 48MHz MCU clock speed) and then set custom intervals/periods for PWM square waves. Is this enough for what you need to do--or do you need something where you can submit a byte array and then have a sequence of pulses sent with different periods? A constant 38 KHz signal with 50% duty cycle will be easy with 4.1.1 -- but I want to see what else you might need here...

Chris


Well, the more functionality the better (the byte array thing would be cool!) but simply being able to generate 38 kHz 50% duty cycle pulses is enough. IR transmitters don't change state faster than a couple of hundreds of microseconds so low-level hardware support isn't necessary for state changes, just 38 kHz square wave generation. Looks like 4.1.1 will at least make IR detection/generation possible using interrupts instead of input capture (crossing my fingers...as I'm not sure what the resolution and/or latency of DateTime is compared to actually reading a hardware timer/counter).
Rugged Circuits LLC / <http://ruggedcircuits.com>

#14 RuggedCircuits

RuggedCircuits

    Member

  • Members
  • PipPip
  • 17 posts

Posted 06 September 2010 - 02:31 AM

Hmm, could you tell me more of what you're looking at?

Would a C# wrapper around the InterruptPort give you what you needed? Basically, the wrapper would just take readings from the InterruptPort's event handler and build them into an Array of timings...

Here's the RC6 decoder by community member Phil... What do you need in addition to the timestamps he's using?
http://forums.netdui...-decoder-class/

Chris


See, this is where knowing more about the .NET code would have made me look a lot smarter B) I didn't realize that interrupts came with timestamps. Phil's code that you referenced above should work perfectly well on a Gadget Shield and no wrapper is needed.

However, my guess is that interrupts come with timestamps because the event handler, after some latency, takes a snapshot of the system time (stabbing in the dark here but that sounds reasonable to me). That should work perfectly fine for decoding IR transmissions where sub-microsecond resolution is fine, but an InputCapture class with single-cycle resolution (what is used on the Arduino for IR decoding) would be useful for other applications like accurate frequency counting. Certain sensors (I'm thinking light-to-frequency sensors like the TAOS series) encode their sensed values in frequency thus accurate frequency measurement is important, at higher resolution than event timestamps. Not important for the Gadget Shield, but something to keep in mind maybe for future development B) The more of the underlying hardware features of the AT91SAM7X512 you can expose, the more applications will be enabled.
Rugged Circuits LLC / <http://ruggedcircuits.com>

#15 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 06 September 2010 - 02:42 AM

Where in the firmware? Searching for PWM in your forums fails because search terms less than 4 characters are rejected. I looked in the source and all the PWM functions seemed to be stubs. I apologize but coming from the Arduino world the C#/.NET model is still very foreign.


The SecretLabs.Hardware.PWM class gives you two methods: SetDutyCycle and SetPulse. If you create a PWM object using one of the Netduino PWM Pins, you can use SetDutyCycle to change the duty cycle from 0-100%.

The PWM support in the v4.1.0 firmware is very preliminary. We wanted to get feedback before we fleshed it out with fuller functionality (which is what we're doing now) for v4.1.1.

Please please PLEASE come up with something like this to help us Ardufolks out:

http://arduino.cc/en...erence/HomePage

And code samples wouldn't hurt either B) Not in the forums...on the web site.


We are working on an "Introduction to Netduino" text... Should we make an online (HTML in addition to PDF) version as well?

This is great feedback...

Chris

#16 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 06 September 2010 - 02:48 AM

Certain sensors (I'm thinking light-to-frequency sensors like the TAOS series) encode their sensed values in frequency thus accurate frequency measurement is important, at higher resolution than event timestamps. Not important for the Gadget Shield, but something to keep in mind maybe for future development


I've put this down as a feature request. As soon as v4.1.1 ships later this month, maybe we can take a poll on what features to implement next?

Chris

#17 RuggedCircuits

RuggedCircuits

    Member

  • Members
  • PipPip
  • 17 posts

Posted 06 September 2010 - 02:58 AM

The SecretLabs.Hardware.PWM class gives you two methods: SetDutyCycle and SetPulse. If you create a PWM object using one of the Netduino PWM Pins, you can use SetDutyCycle to change the duty cycle from 0-100%.


OK, asking in a purely informational way, how would someone that just purchased a Netduino know this?

We are working on an "Introduction to Netduino" text... Should we make an online (HTML in addition to PDF) version as well?


Forget the text, start putting it online as you write it, print it off when it's done. Just 1 suggestion....
Rugged Circuits LLC / <http://ruggedcircuits.com>

#18 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 06 September 2010 - 03:01 AM

OK, asking in a purely informational way, how would someone that just purchased a Netduino know this?


The introductory text will help with this. But you're right...there's a lot in the platform that we need to showcase for new users... We'll continue working on that.

We'll also be putting a tutorial online. We wanted to wait on that until the updated PWM in v4.1.1 was done...

Chris

P.S. In the meantime, please feel free to ask questions on any features you need or don't understand. This will help give us the info we need for the introductory text...

#19 Omar (OZ)

Omar (OZ)

    Advanced Member

  • Members
  • PipPipPip
  • 564 posts

Posted 06 September 2010 - 03:06 AM

OK, asking in a purely informational way, how would someone that just purchased a Netduino know this?



Forget the text, start putting it online as you write it, print it off when it's done. Just 1 suggestion....


I guess both sides aren't fully documented, sorry for the 'trolling' post, I just had good stuff in mind and got a little carried away. I am planing on posting a new video soon, featuring your shield as always.

Question... What do you suggest I do to protect the light sensor from the rgb light's awesome brightness? It isn't too bad but the less interference the better.

#20 RuggedCircuits

RuggedCircuits

    Member

  • Members
  • PipPip
  • 17 posts

Posted 06 September 2010 - 03:23 AM

Question... What do you suggest I do to protect the light sensor from the rgb light's awesome brightness? It isn't too bad but the less interference the better.


The plane of the RGB emitter is higher than that of the light sensor so any interference will probably be mostly due to reflection from whatever is above the shield. Try to keep reflective objects away, or if that doesn't work perhaps glue in some cardstock around the LED or light sensor.
Rugged Circuits LLC / <http://ruggedcircuits.com>




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.