Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 03:43 11 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : MMX: Turning off PWM

Author Message
BrantB
Newbie

Joined: 27/10/2017
Location: Canada
Posts: 40
Posted: 10:33pm 03 Mar 2018
Copy link to clipboard 
Print this post

Hello All,

Sorry for another post/topic, so quickly (I just recently posted one about the GPS functions), but I have run into another little snag - completely unrelated to the GPS issue.

This time, it is with PWM-ing a LED. Simple enough; I've done it 100's or 1000's of times. But ...

When I issue PWM 2, 500, 100, I get a nice bright LED. When I issue PWM 2, 500, 1, I get a dim LED. All good; all exactly as expected.

When I issue PWM 2, 500, 0, I get ... a bright LED. Huh?

What I expected was no signal at all (i.e., LED completely off). I can get the LED to be extremely dim by using a value of 0.1 - but once I turn on the PWM, I can never seem to get it fully turned off again.

I also tried PWM OFF, but that gives a syntax error.

I tried PWM 2, 500, 0 in Micromite "Standard" on an MX170 (DIP-28), and it behaved exactly as I expected - it turned the LED off completely.

Has anyone else encountered this? Any ideas?

By the way, my current MMX environment (in which I am experiencing the PWM issue) is as follows:

PIC32MZ2048EFH100 processor

OPTION CPU 200
OPTION LCDPANEL ILI9341_16_BUFF, 98
OPTION HEARTBEAT ON

MMX Version 5.4.14

Cheers!

Brant
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10569
Posted: 10:41pm 03 Mar 2018
Copy link to clipboard 
Print this post

Hi Brant

Nice to see someone using the MMX. Bedtime here in the UK but I'll look at both issues tomorrow

PeterEdited by matherp 2018-03-05
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10569
Posted: 09:44am 04 Mar 2018
Copy link to clipboard 
Print this post

This seems to be a difference in the Microchip plib routines between the old plib library and the new Harmony plib calls. My code is correctly calling the plib routine with the value 0 but it is being ignored/misinterpreted. I will need to special case 0 to fix the issue. I'll post an update later today.

NB the correct syntax to stop a PWM output is PWM n,STOP

Bug fix here Edited by matherp 2018-03-05
 
hitsware
Guru

Joined: 23/11/2012
Location: United States
Posts: 535
Posted: 12:31pm 04 Mar 2018
Copy link to clipboard 
Print this post

Don't you have to make the pin go inactive (open)
to insure 'offness' ?
Or does STOP do that ?
 
LouisG
Senior Member

Joined: 19/03/2016
Location: Australia
Posts: 129
Posted: 12:36pm 04 Mar 2018
Copy link to clipboard 
Print this post


PWM n,STOP

To me STOP has connotations of STOP FLIPPING continuously between logic 1 and logic 0.

I haven't tried the PWM command till now but could it conceivably stop at logic 1?


 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10569
Posted: 01:01pm 04 Mar 2018
Copy link to clipboard 
Print this post

PWM n,STOP is standard Micromite syntax - see the Micromite manual

The pin is released back to the default state (input) - this is the same for MM, MM+ and MMX

The only thing differences in the MMX was that prior to this patch setting the duty cycle to zero was being incorrectly handled and the MMX has one extra pin on channel 2
 
BrantB
Newbie

Joined: 27/10/2017
Location: Canada
Posts: 40
Posted: 04:46pm 05 Mar 2018
Copy link to clipboard 
Print this post

@matherp,

I have some bad news - the updated firmware does not appear to have fixed up the issue(s) .

It has changed the PWM behaviour associated with a 0 value, but it is still not right. With the firmware update applied, issuing PWM 2, 500, 0 now results in half brilliance, rather than pinning the LED at full brilliance the way it used to. But it does not turn it off.

BTW - no change in the (mis)behaviour of the GPS function, either. But I will continue that discussion in the other (GPS) thread, for those who may only be following that one.

Admittedly, I have not broken out my oscilloscope to confirm that PWM 0 results in precisely a 50% duty cycle. But by comparing the results of a 0 value to those of 40, 50, and 60, I would say 50 is a pretty good bet. The brilliance of the LED appears to remain the same when alternating between a PWM value of 0 and 50, whereas alternating between 0 and 40, or 0 and 60, does generate an easily perceptible difference.

By the way - my bad about PWM OFF vs PWM n, STOP. In the prose section of the Micromite manual (v5.4, pg 38, to be precise), there is a reference to using the PWM OFF command. I must confess that, in that case, I failed to refer to the actual Command table (beginning on page 52). Oops. Sorry about that.

Using PWM 2, STOP does extinguish the LED - but, of course, as you know, that is not the equivalent of PWM 2, n, 0. The former also turns off all of the PWM signals running on #2, which may not be desirable ... whereas the latter would (for practical purposes) turn "off" just the one sub-channel of #2.

Any chance you could have another look at this to see what's up?
 
BrantB
Newbie

Joined: 27/10/2017
Location: Canada
Posts: 40
Posted: 05:35pm 05 Mar 2018
Copy link to clipboard 
Print this post

NOTE: This is a (purposeful) cross-posting of a message from my other (GPS) thread. The same info is relevant in both threads.

@matherp,



I take it all back! The firmware update is fine. I somehow screwed up .

I previously ended up re-burning exactly the same firmware (sigh). I wanted to keep the original version of the 5.4.14 hex file, just in case I needed to do further (comparative) troubleshooting. So, I created a copy with a new name. And after that, something went screwy - it looks like I somehow might have re-downloaded the earlier version of the ZIP file from the forum, instead of the correct/new one. Of course, since the version number didn't actually change, I was doomed.

Anyway, I am very pleased to report that the error was mine, not yours, Peter. (Well, it does not please me that I goofed up like that , but I am glad it turned out to be something so simple.)

Why the PWM behaviour changed when I re-burned the same firmware, I will never know. At this point, I am content for that simply to remain a mystery.

Anyone: This brings me to another question (about using the forum) - how do I edit my own messages? I see that others do it, and I have looked at the Help (which, in this case, is not helpful). I don't see an Edit button anywhere. I would like to edit my previous "no joy" message with a line at the top, to warn future readers that the information contained therein is not accurate. I don't want to erase my gaffe - there is no integrity in that. I did it; I will "own" it. But, I don't want to cause people grief with bad information.

 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2959
Posted: 06:23pm 05 Mar 2018
Copy link to clipboard 
Print this post

  BrantB said   I previously ended up re-burning exactly the same firmware (sigh). I wanted to keep the original version of the 5.4.14 hex file, just in case I needed to do further (comparative) troubleshooting. So, I created a copy with a new name. And after that, something went screwy - it looks like I somehow might have re-downloaded the earlier version of the ZIP file from the forum, instead of the correct/new one. Of course, since the version number didn't actually change, I was doomed.


If it makes you feel any better, I have been using MicroMites for 4 years; and have programmed 100's, yet occasionally I still make this exact same mistake!
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 06:58pm 05 Mar 2018
Copy link to clipboard 
Print this post

@BrantB, you can only edit your own post for a limited time or until someone adds another post below it. The Edit button will appear to the right of the Buddy button at the bottom of your post during this time.

Paul in NY
Edited by Paul_L 2018-03-07
 
BrantB
Newbie

Joined: 27/10/2017
Location: Canada
Posts: 40
Posted: 07:04pm 05 Mar 2018
Copy link to clipboard 
Print this post

@WhiteWizzard: Many thanks for the consoling words. It makes me feel a little better knowing I am not alone.

@Paul_L (and credit also goes to @WhiteWizzard for your similar reply in the GPS thread): Thanks for the tip about the Edit. It was driving me nuts.
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025