Wednesday, 21 February 2024
Main Menu
Home Home
Shop Shop
News News
Products Products
Application Notes Application Notes
Publications Publications
Links Links
Support Center Support Center
Downloads Downloads
Forum Forum
Resellers Resellers
Contact Us Contact Us
Updates Updates
MCS Wiki MCS Wiki
Online Help
BASCOM-8051 Help BASCOM-8051 Help
Contents in Cart
Show Cart
Your Cart is currently empty.
Search the Shop

Products Search

User Login


If you have problem after log in with disappeared login data, please press F5 in your browser

RSS News

AN #147 - Car Windscreen Wiper Control with ATtiny13 Print
This BASCOM example show how to replace an original unit or to make a new one with a small MCU and BASCOM. This example uses the ATtiny 13, which is a small MCU with limited resources but perfect for this application.

The usual wiper control in a car has two problems, both of which this application can solve. First, it uses too many parts, usually an on/off switch and either a potentiometer to adjust the wiping interval or a multi-stage switch. Second, it is not very user-friendly: You either have a limited number of interval periods or, if the wiper is controlled via a potentiometer, you have to adjust the interval period, watch the windscreen if the interval is sufficient (takes at least one or two times wiping), readjust the period and so on.

This BASCOM example show how to do it with minimal cost and maximum functionality with small MCU. This example uses the ATtiny 13, which is small mcu with limited resources but for this application best fit.

Function description :

Upon switching the unit on, the windscreen is wiped periodically with a default interval. By switching the unit off, the driver inhibits wiping causing the windscreen to get wetter and wetter. As soon as the driver decides – the windscreen should not get wetter than this– he switches it back on. Doing so, the driver sets the new interval according to the time passed between the last clearing of the windscreen and switching the unit back on. This way the driver can either lengthen or shorten the interval to exactly what he wishes - the wipers will not go too fast (by the way, often it is the case in traffic jams, there's just no suitable setting!) and it won't go too slow.

Next function in this unit is automatic start of wipers when driver use windscreen water clean nozzles. This function is activated by the switch what activate water pump for the clean nozzles. After releasing this switch wipers is running for specified time period and not need driver assistance.

Schematic diagram :

Example of mechanical design :

Original unit

Original unit vs new PCB

 New unit

This pictures show example how original unit can be remaked with minimal impact on existing electric installation in car.

PCB in virtual look

Example of BASCOM program : (click here for download)

$regfile = "attiny13.dat"
$crystal = 9600000
$hwstack = 32
$swstack = 8
$framesize = 16

Const Timervalue = 22 ' 0.025 sec (25msec) @9.6MHz/1024/8bit = 22
Const Minimum_interval = 40 ' 1sec
Const Default_interval = 80 ' 2sec
Const Disable_after = 1200 ' 30sec
Const Wiper_water_delay = 200  ' 5sec

Const Wiper_threshold = 500 ' 500ms (for waitms statement)

Dim Interval As Word
Dim Int_timer1 As Word
Dim Temptimer As Word

Alias Pinb.0 ' switch for time-cycle wipers
Alias Pinb.1 ' switch what activate windscreen water cleaners
Alias Portb.3 ' relay for wiper motor

Config Portb.0 = Input
Config Portb.1 = Input
Config Portb.3 = Output

Config Timer0 = Timer , Prescale = 1024
Enable Interrupts
Enable Timer0
Timer0 = Timervalue ' reload Timer0 with interval (25msec)

On Timer0 Timer_int ' set Timer0 interrupt routine



 Gosub Wipe_coff ' turn off wiper motor
Debounce Switch , 1 , Start1 ' if wiper switch is turned on, start default interval
Debounce Switch_water , 1 , Wipe_water ' if windscreen clean switch is turned on, start motor




 Interval = Default_interval ' set default interval for wiper timer


 If Interval < Minimum_interval Then Goto Wipe_cont ' if wiper interval < than min interval run motor in continuosly mode



 Disable Timer0
= Interval ' set timer to interval
Gosub Wipe_one
Enable Timer0 ' start/stop motor for one wiper cycle


If Int_timer1 = 0 Then ' if timer goes to 0 , reload timer with interval and make one wiper cycle
Disable Timer0
Gosub Wipe_one
= Interval
Enable Timer0
End If
Debounce Switch_water , 1 , Wipe_water_pre ' check for windscreen clean switch over wiper timer
Debounce Switch , 0 , Time_loop ' check for turn off wiper switch
Goto Wipe_loop2  ' make loop


Wipe_con ' turn on motor - continuosly mode


 Debounce Switch , 0 , Time_loop ' check for wiper switch, if opened go check new interval
Goto Wipe_cont2

= Interval  ' save current interval when windscreen clean sw is activated over wiper timer runnig


Set Relay ' turn on motor until windscreen clean switch is closed
Debounce Switch_water , 0 , Wipe_water1 ' when is opened start time delay for automatic after-clean
Goto Wipe_water


= Wiper_water_delay ' load timer with after-clean time value


If Int_timer1 = 0 Then Goto Wipe_water3 ' if timer goes to 0 turn off motor
Goto Wipe_water2


 Reset Relay ' turn off wiper motor
If Temptimer <> 0 Then  ' check for saved interval from wiper , if is set, reload timer with old value
Disable Timer0
= Temptimer ' and restart wiper timer
= 0
Enable Timer0
Goto Start2
End If
Goto Main ' if saved timer not exist jump to main loop

:  ' time loop for get new wiper interval or reset timer when time exceed 30sec

Gosub Wipe_coff
Disable Timer0
= Disable_after ' load timer with maximum interval (30sec)
Enable Timer0


Debounce Switch , 1 , Time_loop3 ' check for wiper switch closed,if is closed set new interval
If Int_timer1 = 0 Then Goto Main  ' if time period is over and wiper switch is not closed, run program from begin
Debounce Switch_water , 1 , Wipe_water ' check for windscreen clean switch
Goto Time_loop2


 Disable Timer0
= Disable_after - Int_timer1 ' get new interval for wiper
Enable Timer0
Goto Start2 ' run wiper program from begin but ignore setting of default interval

: ' Timer0 interrupt routine

 Timer0 = Timervalue 'reload Timer0

If Int_timer1 = 0 Then Return ' if timer is not set do nothing

= Int_timer1 - 1 ' else decrement it over each interrupt

: ' routine for start/stop wiper motor

 Set Relay ' start motor
Waitms Wiper_threshold ' wait 500ms, needed for activating self-motor automatic
Reset Relay ' turn off motor (motor automaticly return wipers to start position)

: ' activate wiper motor for continuosly mode

 Set Relay

: ' turn off wiper motor

 Reset Relay

/Tomi - MCS Electronics