Shop OBEX P1 Docs P2 Docs Learn Events
Help with PE Lab "MonitorPWM" object — Parallax Forums

Help with PE Lab "MonitorPWM" object

Tired2Tired2 Posts: 29
edited 2009-07-21 09:22 in Propeller 1
Hi,

I am new to the propeller, and have a question about modifying the "MonitorPWM" object from the Propeller Education Kit (#7 Counter Modules)

My project involves running a large DC motor with a PWM output... I have the driver circuit in place, and everything is functioning as it should.

I have implemented a few safeties that should keep me from having a 'runaway' motor in the event of a drive circuit failure (transistor burning up in the ON position, etc)... Once a value goes out of spec (for instance temperature of the motor or drive transistor), the main safety function will set the throttle to 0% Duty, and open a relay that disables the drive system. Anyway, that is all working well, so on to my problem:

I would like to use a voltage divider circuit to monitor PWM duty at the motor, and if the PWM duty at the motor does not match the PWM duty that is being generated (within a few percent), then I want to go to error. (I'm also not yet sure how to get the 24v motor voltage to the propeller's counter pins, but that is another story... maybe voltage divider?) For now, I have soldered my output pin directly to my input pin for testing.

Using the MonitorPWM object (attached for convenience) works well... I get a PWM input within 1% of my output across the 0-100% duty cycle. The problem is that when I get to 100% duty cycle, it no longer detects edges, and the value remains at the last valid reading (1%-99%). Depending on how fast I ramp the throttle, the value can be as low as 85%, and the "tHprobe" variable set by "MonitorPWM" will remain there until I return the throttle to 99% and it detects a new time.

Is there a simple way around this problem? Obviously, it happens on the way down to 0% as well, which is also a problem.

For those who know spin better than I do, is there a way I can modify 'MonitorPWM' to set the value to 0 if waitpeq does not find an edge? Maybe a simple check to see if the pin is high over X amount of cycles?

My current PWM frequency is at 1.5KHz.

Thanks in advance for any suggestions.

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2009-07-21 09:22
    In your program you not only can read the variables which hold the high-time and low-time, you also can set the values. And you know the frequency of the PWM that you use. So, set the values to 0 and wait for at least 1 cycle. If the values have been changed monitor PWM detected a PWM signal, if the values are still 0 you have DC. With the state of the pin you can decide which kind of DC (high or low).
Sign In or Register to comment.