pwmout not behaving as expected.

Furlong

New Member
Or rather not at all. Briefly, I'm learning about Picaxe (28X1) by slowly developing a method of determining the speed of an object using a Sharp IR rangefinder (GP2Y). Have reached the point where I can make 3 LEDs come on to indicate slow, medium, fast, but to refine the output (to control a motor) I think I need the pwmout command. I thought I was familiar with pulsed output having dabbled in RC and servos in distant past, but can so far get no output at all, so maybe have got 'wrong end of the stick'. I assume that code such as
Code:
 PWMOUT 1, 255, 1000 [code] should drive a motor/lamp/even an LED at close to its max. But nothing doing. I've checked output 1 with a basic scope and all happens is that at very low voltage levels the signal has less noise, but the 4.5 volt square wave that I expected is absent. What am I doing wrong? Thanks in advance. PF
 

Furlong

New Member
Sure- just trying to keep the initial post short. One 'proven' code that I've borrowed is this
Code:
REM ditch light experiment
SYMBOL led = 1
SYMBOL temp = w0 'for/next variable
SYMBOL Rate = b8
SYMBOL skip = b9

rate = 10 'adjust these two variables to
skip = 30 '   change the speed of flashing
REM higher rate = slower flash
REM higher skip = faster rise/fall of flash

main:

  FOR temp=0 TO 1023 STEP skip
     PWMOUT led, 255, temp
     PAUSE rate
  NEXT temp

  FOR temp=1023 TO 0 STEP -skip
     PWMOUT led, 255, temp
     PAUSE rate
  NEXT temp

GOTO main:
This should make an LED pulse, as far as I can see. I'm using the Tech-Ed 28X1 starter pack, and wired up an LED the same as I've done before, with output 1 to negative leg and other going to +4.5v. Hope this makes things clearer.
 

eclectic

Moderator
"This should make an LED pulse, as far as I can see. I'm using the Tech-Ed 28X1 starter pack, and wired up an LED the same as I've done before, with output 1 to negative leg and other going to +4.5v. Hope this makes things clearer."

I've just run your program on

AXE022 with 28X1 and

AXE020 with 28X

Both work.

BUT, with PWMout pin1 (leg 12 / Out c1 /In1) to + on the LED >> resistor >> Gnd.

Please check your wiring.

e
 
Last edited:

Furlong

New Member
Thanks for quick reply, but no joy with reversing the layout. I'm not familiar with the AXE boards quoted, but on mine (AXE001) I'm picking up the output via darlingtons, and I think the pin you quoted is straight from the PIC and would indeed need the LED to go to 0v. My misunderstanding of this extra output stage led to my only other post, but Dr Acula put me right and LED to positive now works fine on my other experiments. But at least you've confirmed that the code is valid. Thanks again. PF
 

eclectic

Moderator
Thanks for quick reply, but no joy with reversing the layout. I'm not familiar with the AXE boards quoted, but on mine (AXE001) I'm picking up the output via darlingtons, and I think the pin you quoted is straight from the PIC and would indeed need the LED to go to 0v. My misunderstanding of this extra output stage led to my only other post, but Dr Acula put me right and LED to positive now works fine on my other experiments. But at least you've confirmed that the code is valid. Thanks again. PF
I'm a bit confused, as usual.
The AXE001 kit includes the AXE020 board.

Pwmout 1 does NOT go through the Darlington array.

e
 

Furlong

New Member
My fault- I'm getting the starter pack and the board itself mixed up. I was going to ask how does the pwm get out, but I've just realised that pin 12 goes to/from the digital INPUT socket, and presumably pwm pushes back out this way, so I'll give it a try. Can't say it is too well documented though, but I am (over)relying on D Lincoln's book. Will report back soon, hopefully for last time. PF
 

Furlong

New Member
Yep- all sorted. I'd simply assumed that 'output 1' was via the same output socket that I'd been using up 'til now. Thanks for your patience. Peter F
 

BeanieBots

Moderator
Please be aware that D Lincoln's book is a bit old now.
To the best of my knowledge, it has not been updated since many of the newer PICAXEs came out. Including the 28X1. There have also been many changes/additions to the command set since it was written.
When in doubt, always refer back to the offical PICAXE manuals.
Or of course, this forum.
 

BCJKiwi

Senior Member
Recommend that selected pages from Manual 1 be printed out - the ones that show the Chip layouts with all the pin functions - e.g. Manual 1 page 6 (rev 6.4b) for a start - and others further down if needed.
 
Top