Total Newby

waltsar

New Member
I'm completely new to Picaxe. Way back when ... I programmed in Basic, C, and PLC logic - that should give you a clue of how old I am. Right now I have a general question about what Picaxe can do. I have a small starter kit with a 14M2 processor chip with "Revolution" and "AXE117" printed on the PCB. As my first project, I'd like to connect an SPDT switch to the input which would select 2 different values. Each value would cause the Picaxe to generate a specific PWM duty cycle output. Also, I'd like to be able to set a ramp time of up to 30-40 seconds when going from one input to the other.

If this sounds like something that Picaxe is capable of doing, please let me know and I'll dig into refreshing my programming chops.

Thank you,
Walt
 

Aries

New Member
The simple answer is "yes". Picaxe can do a great deal - take a look at some of the User Projects to see what has been done. There are also a lot of threads in this forum about using Picaxe for various things. As said above - look at the documentation and the manual for assistance (I learnt all my Picaxe from the manual). For something specific, if you can't find it in the manual (e.g. looking for xxxx), try "Google Picaxe xxxx". The search function on the forum can be useful, but it doesn't allow short words (e.g. PWM).

And finally - this is a friendly and helpful forum, so do come back and ask if there is something you need help with.

Good luck.
 

Flenser

Senior Member
The search function on the forum can be useful, but it doesn't allow short words (e.g. PWM)
There is a workaround for this issue with the forum search.
Use google search instead specifying the site parameter with picaxeforum.co.uk like this:

25762
 

hippy

Ex-Staff (retired)
If this sounds like something that Picaxe is capable of doing, please let me know and I'll dig into refreshing my programming chops.
Yes, the PICAXE is perfectly capable of doing that. Getting it to ramp between two different duties will need some "ah, that's how one would do it" insight, which may be difficult to comprehend if it were simply thrown at you as a solution, but should be more understandable if built up from a simpler base.

I would suggest the best starting point, to get yourself up to speed, back into the flow of coding, is to forget PWM for now, and start with turning a LED on or off depending upon the switch position. We can replace the LED control with PWM control later.

My starting point would be -
Code:
#Picaxe 14M2

Do
  If pinC.0 = 1 Then ; When switch closed ...
    High B.5         ;   Turn on the LED
  Else               ; Otherwise ...
    Low  B.5         ;   Turn off the LED
  End If
  Pause 10           ; We don't need to run flat-out
Loop                 ; And repeat this loop forever
And then, because it's always good to not have to change hard-coded values throughout a program when you may want to use or try other I/O pins, I would specify those pins via SYMBOL statements -
Code:
#Picaxe 14M2

Symbol SWITCH_IN = pinC.0 ; Switch on input C.0
Symbol LED_OUT   = B.5    ; LED on output B.5

Do
  If SWITCH_IN = 1 Then   ; When switch closed ...
    High LED_OUT          ;   Turn on the LED
  Else                    ; Otherwise ...
    Low  LED_OUT          ;   Turn off the LED
  End If
  Pause 10                ; We don't need to run flat-out
Loop                      ; And repeat this loop forever
And that's the fundamentals of what you need sorted. When the LED is on it will eventually be PWM output at one duty, when off it will be PWM output at the other duty.

If you run that in PICAXE Editor 6 simulation you will see output pin B.5 reflect the input pin C.0 state, and that will be toggled every time you click on the C.0 pin in the simulation panel, usually bottom left of PE6.

I would suggest the above alone will have got you 60% towards completing your project. Changing the LED output to be PWM is a fairly small step to get you to 80%. But as always with any '80:20', it's that final 20%, making PWM ramp from one duty to another, which requires most perspiration.

We can move on in further instalments or we can leave it for you to decide that you want to figure it out for yourself. Whichever you prefer, members here will always be happy to answer any questions you do have along the way.
 
Top