C# School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a C# Expert!

Join 309,234 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 2,770 people online right now. Registration is fast and FREE... Join Now!




C# PWM processorload problem

 

C# PWM processorload problem, PWM on LPT = OK; CPUusage = 50%

baskapteijn

3 May, 2009 - 11:32 PM
Post #1

New D.I.C Head
*

Joined: 3 May, 2009
Posts: 1

Dear reader,

I am a near beginner in c# (visual studio). I've written myself a PWM generator which controlls the parallel port. I can change frequency, dutycycle and stepsize. The problem is as follows:

I'm generating PWM in a while(true) loop in a second threat. This is the only way i know how to generate accurate PWM cycles. The only problem here is that i don't effectively use CPU time(im burning 50% time). I want the following:

/pseudo code on/

tell windows or some eventwatcher that i want to wait X cpu ticks
IF they passed, give an interrupt or jump to some codeloop
(without endlessly waiting and burning cpu cycles)

/pseudo code off/

In fact, system.timer or so has a timer that jumps on every set timertick to a loop. This is exactly what i want but more precisie than 1 ms. I want microsecond accuracy with autojumps to a function after a given time. Can anyone tell me how to do this in code? I will paste my code if you guys want it but this is all there is to it.

Thanks,
Bas Kapteijn

User is offlineProfile CardPM
+Quote Post

 
Reply to this topicStart new topic
Replies(1 - 1)

nin82

RE: C# PWM Processorload Problem

7 May, 2009 - 07:31 PM
Post #2

New D.I.C Head
*

Joined: 7 May, 2009
Posts: 1

QUOTE(baskapteijn @ 3 May, 2009 - 11:32 PM) *

Dear reader,

I am a near beginner in c# (visual studio). I've written myself a PWM generator which controlls the parallel port. I can change frequency, dutycycle and stepsize. The problem is as follows:

I'm generating PWM in a while(true) loop in a second threat. This is the only way i know how to generate accurate PWM cycles. The only problem here is that i don't effectively use CPU time(im burning 50% time). I want the following:

/pseudo code on/

tell windows or some eventwatcher that i want to wait X cpu ticks
IF they passed, give an interrupt or jump to some codeloop
(without endlessly waiting and burning cpu cycles)

/pseudo code off/

In fact, system.timer or so has a timer that jumps on every set timertick to a loop. This is exactly what i want but more precisie than 1 ms. I want microsecond accuracy with autojumps to a function after a given time. Can anyone tell me how to do this in code? I will paste my code if you guys want it but this is all there is to it.

Thanks,
Bas Kapteijn


dear writter:

There is no possible way of doing such thing under any windows... I have face this problem my self. I suggest you do it by other means, such as hardware... my solution was interfacing an ATMEGA162 an DAC and C# best of luck!



User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/26/09 08:56AM

Live C# Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month