Good day
I need help please. Im using the Picaxe18m2.
I tried to write code to switch an output on and off and the on and off times must be independently controlled by 2 pots on the input.
I use 2 linear 10k pots on adc inputs. I found that the pulse widths only adjust from 0v to about halfway at 2.5v on the wiper of the pots. Further adjustment to 5V does not change anything.
It also seems as if I cant get more than 250ms pulses out . So what i did to get up to 25 sec on and off times was to repeat the pause pulse in both cases 100 times
I can use it like that but surely there must be an easier way to do it or to write the code. Someone that is not available anymore helped me with the original. I studied the commands and changed it a lot as it was not working as it should. To tell you the truth I don't really understand the Symbol statements using W6 etc
Any help will be appreciated
Here is the code I use:
I need help please. Im using the Picaxe18m2.
I tried to write code to switch an output on and off and the on and off times must be independently controlled by 2 pots on the input.
I use 2 linear 10k pots on adc inputs. I found that the pulse widths only adjust from 0v to about halfway at 2.5v on the wiper of the pots. Further adjustment to 5V does not change anything.
It also seems as if I cant get more than 250ms pulses out . So what i did to get up to 25 sec on and off times was to repeat the pause pulse in both cases 100 times
I can use it like that but surely there must be an easier way to do it or to write the code. Someone that is not available anymore helped me with the original. I studied the commands and changed it a lot as it was not working as it should. To tell you the truth I don't really understand the Symbol statements using W6 etc
Any help will be appreciated
Here is the code I use:
Code:
let dirsB=%11111111 --------------------- ;B0-7 ALL OUTPUTS
let dirsC=%00001000 -------------------- ; C0 C1 INPUT (c3 out c4 in)
let adcsetup=%0000001100000000------- ;set ADC BIT 8 AND 9 C0 AND C1
setfreq M32
Start:
Symbol FreqAdj1 = w6
Symbol onpulse = w7
Symbol FreqAdj2 = w8
Symbol offpulse = w9
goto Main
Main:
do
readadc10 C.1, w6 -------------------------------- ;Get value from adjust pot. (ON PULSE)
onpulse = FreqAdj1 min 0 max 255-------------- ;Make onpulse equal to FreqAdj1.
readadc10 C.0, w8-------------------------------- ;Get value from adjust pot. (off PULSE)
offpulse = FreqAdj2 min 0 max 255 ------------- ;Make offpulse equal to FreqAdj2.
high B.6----------------------------------------------- ;Turn led and Motor FET on
pause onpulse---------------------------------------- ;Pause for value of onpulse
low B.6------------------------------------------------ ;Turn led and Motor FET off
pause offpulse---------------------------------------- ;Pause for value of offpulse
goto main
Last edited by a moderator: