Picaxe PWM code help
I have a throughly noob question or two.
I have yet to use my 20M2 board that has been sitting around waiting for a project. A friend is trying to fix an "Aquabot" for his wife's boss. So I figured that it would come in handy on this project, the only problem being I have never programmed anything for picaxe (or any uC) before. It's a pool cleaning robot that runs for about 7 hours at a clip, it has two motors, one is the impeller which is always on, and the other is a stepper, which I need to turn on and run forward for a random amount of time between lets say 2 and 6 minutes and then reverse for another random 2 to 6 minutes.
I have a 555 pulse generator connected to an 'EasyDriver' http://www.schmalzhaus.com/EasyDriver/ to control the stepper. At first I was trying to avoid using the picaxe altogether but after getting the stepper running from the easydriver which was recieving pulses from the 555, I realized that you can't just take and dump high frequency pulses from the start, you need to ramp it up, or else the stepper locks up. So I connected a LDR accross my 555 timer's frequency adjust pot. and viola! Next I added an LED to pin b.2 on my 20M2 board for the pwm signal. It is connected from pin b.2 to anode, cathode to resistor to GND. My plan is to pwm the led that I have pointing at the LDR and use it as a optoisolator/ digital pot/ gas pedal for the picaxe to control the frequency of pulses for the easydriver.
So my idea of the code is like something this:
toggle(?) direction pin (to easydriver input)
pwm pin b.2 LED from off to on over a 3 second period and hold LED on
pause for a random time between 2 and 6 minutes
turn off LED
I also plan on adding an output pin to put the easydriver into sleep mode in the future.
I know the 20m2 is a bit of overkill here and if I had an 08m I's use that... but it is what it is I guess.
Any pointers with the pwm code or any of this would be greatly appreciated, meanwhile I'm back to the picaxe manuals.
Thanks in advance!