Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 17:41 14 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 : CMM2 PWM 2 Stopped Working

Author Message
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1106
Posted: 10:42am 26 Aug 2020
Copy link to clipboard 
Print this post

Hi

Using version b19.

I am using PWM 2,15,50 (pin 36) as a test signal & it appears to no longer work within my program.

I can get it to work from the command line but only after I reboot the CMM2.

I tried the following short program which also did not work.
do
 print time$
 pwm 2,15,50
 pause 10000
 pwm 2,stop
pause 10000
loop


I'm monitoring pin 36 with a DSO.

I don't think I am doing anything stupid.

The pin works OK as a DOUT (after turning it off)

Any ideas?

Brian
ChopperP
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10580
Posted: 11:25am 26 Aug 2020
Copy link to clipboard 
Print this post

Thanks for the report - definitely a bug but I can't see what at the moment. No issues with PWM 1 as far as I can see. Also running a program other than one which include PWM 2 doesn't cause the issue so very strange
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1106
Posted: 11:37am 26 Aug 2020
Copy link to clipboard 
Print this post

Thanks Peter.
Confirmed 1(pin 12) is working.
Edited 2020-08-26 21:52 by Chopperp
ChopperP
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10580
Posted: 03:35pm 26 Aug 2020
Copy link to clipboard 
Print this post

Please re-download b20 and see if that fixes it. What a pig that was  
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1106
Posted: 09:02pm 26 Aug 2020
Copy link to clipboard 
Print this post

Thanks Peter, that did the trick.
Much appreciated

EDIT

Short lived. It worked for a bit. Turned it off but would not restart.
Works again when program flushed from memory

Bugger.
Edited 2020-08-27 07:13 by Chopperp
ChopperP
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10580
Posted: 09:46pm 26 Aug 2020
Copy link to clipboard 
Print this post

  Quote  Short lived. It worked for a bit. Turned it off but would not restart.
Works again when program flushed from memory


More info needed. Precise sequence of steps that causes the problem as I can't replicate this time
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1106
Posted: 10:15pm 26 Aug 2020
Copy link to clipboard 
Print this post

OK, More info tonight my time
ChopperP
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1106
Posted: 08:56am 27 Aug 2020
Copy link to clipboard 
Print this post

Hi Peter

I did a whole heap of tests but I'm not sure what it all means as the results appeared not to be consistent.

My updated test program is as follows as is my list of steps I did & results. Tests mainly PWM command directly from the keyboard or from the test program  
'PWM_Test.bas
do
 print time$,
 pwm 2,15,50
 pause 3000
 print time$
 pwm 2,stop
pause 1000
loop


Tests & Results.

PWM 1 working... as expected (Swapped PWM 2 for PWM 1 in my main program
Stopped current prog with faulty PMW 2
PWM 1 still working.
PWM 2, 15, 30 ..... not working
pwm 2, stop ...
setpin 36, dout   ..... test pin
PIN(36) = 1 ....OK
NEW
PWM 2, 15,30 ...not working
reset CMM2  - off then on. Ver ...05b20
PWM 2, 15, 50 works
PWM 2, stop    .... ok
PWM 2, 15, 15 ...ok
PWM_Test.bas.....not working
reset (Off & On)
files...PWM_Test.bas...no go.
reset
PWM 15, 50 ...   OK
PWM 2, STOP
PWM 2, 15, 50 ...OK
RUN PWM_Test.bas   ...OK
Ctrl - C & run....OK
Crtl - C & NEW.
Run PWM_Test.bas.....no ouput. Prog Running though
Ctrl - C. PWM 2,15,50...no go.
Reset. PWM 2,15,50......ok
PWM 2, stop....OK
Run PWM_Test.bas....no output
Rest. Runs OK
Stopped when running.
PWM 2, 15, 50 OK as were various PWM ratios.
PWM 2, stop & PWM 2, 15, 90 worked
CTRL - C & RUN worked
CTRL - C & NEW
PWM_Test.bas... no output.

New BIN download & reflash...
Ran PWM_test.bas...no output.
Turned CMM2 off & on again.
RUN (F2) .... OK
Ctrl - C  & NEW.
Run test prog.....no output.
Turned off then on again. F2 to run. Works.....


Hope this helps

Brian
ChopperP
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1106
Posted: 11:27am 28 Aug 2020
Copy link to clipboard 
Print this post

FYI

I replaced a suspect plug on my 40 way cable to my breadboard.

All connections now seem OK.

Still something funny with PWM 2 after the b21 upgrade within my main program I'm playing with.

I've spent a good part of the day going through the program seeing when & where the PWM 2 command either stopped or did not start.

At one point, I did suspect a couple of SETTICK's were the problem, but that was a fizzer.

What is supposed to happen is the PWM comes on when I select a switch position (9, analogue voltage on a rotary switch) & then press an interrupt switch to activate it. It is turned off when the rotary switch is returned to zero. It was working up to a few versions ago but my playing around with the program (1200 odd lines) may have upset something. PWM 1 works with original coding.

What I ended up doing was using the rotary switch & activate switch to set a flag instead of opening the PWM channel.

I then put the PWM 2 ON command inside a 1 second Subroutine & then immediately have the flag checked. If not set, it would stop the PWM 2 channel.

So far, PWM 2 does work this way. If it does not fire up, I do have to reset (turn off & on) the CMM2 to get PWM 2 to come on again.

Code snippets below. I'm running both PWM 1 & 2 for comparison

 
'part of main 1 sec Sub
     
    PWM 2, 15, 50    'turn on PWM 2 channel
    IF switch_pos_No = 0 or NOT PWM_2_Flag THEN PWM 2, STOP  'stop PWM if flag not set or switch at Position 0
END SUB


'Part of Get_Switch routine. Voltage from rotary switch

SUB Get_Switch  'Rotary Switch selected then Activate Switch pressed to run selected  
    Switch_Val = PIN(29)          'gets analogue value from rotary switch position
    SELECT CASE Switch_Val        'value of analogue voltage
    CASE > 2.7                    'voltage > 2.7V
        Switch_Pos_No = 9
.
.
     CASE < 0.15                  'turn off PWM's
        Switch_Pos_No = 0
        PWM 1, STOP               'stop PWM 1
        PWM_2_Flag = 0            'set  PWM 2 flag for 1 sec Sub routine
        PWM 2, STOP               'stop PWM 2
    END SELECT

Part of Activate Switch interrupt routine

SUB Switch_interrupt     'activates switch interrupt when pressed.
  SETPIN 31, off               'turn off interrupt
  SELECT CASE Switch_Pos_No    'switch position from Get_Switch
    CASE =  9
      PRINT @(500, 96) "Sw 9 Selected"
      PWM 1, 15, 50            'PWM 1 test signal
      PWM_2_Flag = 1           'flag for PWM 2
     'PWM 2, 15, 50 'This does NOT work when uncommented


The full program has been running for a good couple of hours now with both PWM channels turning on & off when required.

EDIT

Well, so much for that. PWM 2 stopped working again....bugger. Good while it lasted
Back to the drawing board.

Brian
Edited 2020-08-28 22:22 by Chopperp
ChopperP
 
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