Windscreen Intermittant controller

Hi Everyone!
I wrote some code last night to make a intermittant controller for my car windscreen wipers. I'm sure i'm close with it but when simmulating it, the timing doesnt seem to be correct.
The concept:
My car already has an intermittant setting for the windscreen wipers however it is extremely old school. I'm talking, a motor with a cam operating a switch, enclosed in a little box under the dash. Being that it is old, the motor squeels when in use and drives me crazy! Rather than replace the motor I thought it would be a perfect time to build my first PICAXE project. (i am working on another major project but that is still in the development phase, working out how to build the hardware)
The plan is to remove the motor driven intermittant controller and use the PICAXE to control the timing, which can then be adjusted on the fly.
INPUTS= signal from intermittant position of wiper switch, signal from washer switch
OUTPUTS= intermittant FET, washer FET
My idea was to set it up so that if the wipers were on intermittant, the washer control will adjust the delay time instead of actually wash. This would be done in increments, say 5 settings, before resetting to the first delay period again. If the wipers are in any other mode (low, or high), then the wash control would simply wash.
This is what I have so far, and it works except that the delay adjustment. It didnt seem to be pausing correctly on the intermittant run section. Although it was late last night after a 12 hour work day so maybe I just need a fresh try at it! I also made a couple of changes before going to bed which i didnt test so it might be a bit wrong there....i have also just made a few inclusions while doing this post and i dont have the programming editor here at work to test it :)



Code:
'Windscreen wiper/washer control
'18/05/2011
symbol INTsw = pin3                           'set pin 3 as intermittant switch input
symbol WASHsw = pin4                        'set pin 4 as washer switch input
symbol INTout = 1                               'set pin 1 as intermittant output
symbol WASHout = 2                           'set pin 2 as washer output
symbol DELAY = 2000                          'set delay symbol as value 2000
symbol DELAYmult = b0                        'set variable b0 as delay multiplier
symbol DELAYtime = b1                        'set variable b1 as delay time
DELAYmult = 1                                    'set initial delay multiplier to 1
DELAYtime = 2000                               'set initial delay time to 2 seconds
main:
 if INTsw = 1 and WASHsw = 1 then ADJint      'adjust delay if int is ON and wash switched
 if INTsw = 1 and WASHsw = 0 then INTrun     'simply run in in int mode
 if INTsw = 0 and WASHsw = 1 then WASHrun   'simply wash when not in int mode
 low WASHout
 goto main
ADJint:
 DELAYmult = DELAYmult + 2                   'increment the delay multiplier for longer delay time
 if DELAYmult = 9 then RESETint               'if the multiplier is at max, go and reset
 DELAYtime = DELAY * DELAYmult             'create the delay time
 goto INTrun
INTrun:
 high INTout                                          'output pulse for int mode
 pause 500
 low INTout
pause DELAYtime
  goto main
WASHrun:
 high WASHout                                      'output to run washer pump
 goto main
RESETint:
 DELAYmult = DELAYmult - 8                    'this will reset DELAYmult back to 1
 goto main

would love a little assistance if that is ok.

Cheers guys,

Dave

PS-I'm sorry about the notes being cluttered with the code, I dont know how to fix that on the forum... it isnt like that when I type it...
 
Last edited:

lbenson

Senior Member
To get the code formatting right, go back and edit the post to enclose the code in the tags, [code]...[/code]
 
cool, thanks for that. sorted. I did read the "readme first" stuff but had forgotten that one...
 
Last edited:

Janne

Senior Member
Instead of using the washer setting to actually control the intermittent time delay, you could use the intermittent switch position to control it. When you switch the wipers off, from the intermittent position, it would start a timer. After you start the wipers again, the time elapsed would be stored in a variable, and afterwards used as a delay for the wiper. That way you could retain the washer function as well.

Sadly, not my great idea, just how it works in my car from the factory :)

Also, all the usual caveats of automobile use apply for this project. The picaxe will need a robust power supply and input filtering to stand a chance in the automotive environment.

The problem with your code seems to be, that you use a byte sized (0-255) variable for the DELAYtime. It needs to be a word sized(0-65535) variable to be able to hold the value, as it goes up to 16000. Instead of B1, use for example W6 instead.
 
Last edited:
thanks. I will try changing it to a word variable tonight. I want to use the wash switch because then I can just give it a quick flick to change the delay time while still have the wipers running. In general, if I want to wash the windscreen, I would have the wipers running on either the slow or fast setting, not intermittant.
 
I have updated my code for this one. Now the delay time works - thanks Janne.
Code:
'Windscreen wiper/washer control
'18/05/2011
symbol INTsw = pin3		'set pin 3 as intermittant switch input
symbol WASHsw = pin4		'set pin 4 as washer switch input
symbol INTout = 1			'set pin 1 as intermittant output
symbol WASHout = 2		'set pin 2 as washer output
symbol DELAY = 1000		'set delay symbol as value 2000
symbol DELAYmult = w0		'set variable w0 as delay multiplier
symbol DELAYtime = w1		'set variable w1 as delay time
DELAYmult = 2			'set initial delay multiplier to 1
DELAYtime = 2000			'set initial delay time to 2 seconds
main:
	if INTsw = 1 and WASHsw = 1 then INTset
	if INTsw = 1 and WASHsw = 0 then INTrun
	if INTsw = 0 and WASHsw = 1 then WASHrun
	low WASHout
	goto main
INTset:				'increment the intermittant delay timer
	DELAYmult = DELAYmult + 1
	if DELAYmult = 5 then RESETint
	DELAYtime = DELAY * DELAYmult
	goto INTrun
INTrun:				'run the wipers in intermittant mode
	high INTout
	pause 500
	low INTout
	pause DELAYtime
	goto main
WASHrun:				'run washer pump
	high WASHout
	goto main
RESETint:				'reset the delay to the inital value
	DELAYmult = DELAYmult - 4
	goto main
the only downside is that you have to hold the WASH switch until the next cycle of the program if you want to increment the delay time again due to the program not watching the input while it is on the pause command. I tried to get around this using an interrupt but couldnt get it to work properly.

Any suggestions?
 
Last edited:

lbenson

Senior Member
Try putting smaller pauses into a loop and checking your inputs during the loop. Something like:
Code:
b13 = DELAYtime / 50 ' # 50-millisecond pauses
for b12 = 1 to b13
  pause 50
  if INTsw = 1 then main
next b12
 
thanks for that idea lbenson. it works great in simulation. now i just have to build it! (and maybe play with timing a little.

Code:
'Windscreen wiper/washer control
'18/05/2011
symbol INTsw = pin3		'set pin 3 as intermittant switch input
symbol WASHsw = pin4		'set pin 4 as washer switch input
symbol INTout = 1			'set pin 1 as intermittant output
symbol WASHout = 2		'set pin 2 as washer output
symbol DELAY = 1000		'set delay symbol as value 2000
symbol DELAYmult = w0		'set variable w0 as delay multiplier
symbol DELAYtime = w1		'set variable w1 as delay time
DELAYmult = 2			'set initial delay multiplier to 1
DELAYtime = 2000			'set initial delay time to 2 seconds
b11 = 1
main:
	if INTsw = 1 and WASHsw = 1 then INTset
	if INTsw = 1 and WASHsw = 0 then INTrun
	if INTsw = 0 and WASHsw = 1 then WASHrun
	low WASHout
	goto main
INTset:				'increment the intermittant delay timer
	DELAYmult = DELAYmult + 1
	if DELAYmult = 5 then RESETint
	DELAYtime = DELAY * DELAYmult
	goto INTrun
INTrun:				'run the wipers in intermittant mode
	high INTout
	pause 500
	low INTout
	b13 = DELAYtime / 50	'create number of 50ms pauses
	for b12 = 1 to b13	'loop until required delay is reacheed, while checking for another signal
		pause 50
		if WASHsw = 1 then main
	next b12
	goto main
WASHrun:				'run washer pump
	high WASHout
	goto main
RESETint:				'reset the delay to the inital value
	DELAYmult = b11
	goto main
 
Last edited:
Top