SIM question on a simple circuit

davidwf

Senior Member
The project is to replace the front & rear washer pump control on my car as one of the relays in the CANBUS BSi is sticking and I cannot justify £400 + to repair just one relay.......and no, it doesn't come apart - believe me I have tried !

When I run the SIM on my PC and keep either button "released" it runs, <<seems to>> stop, then runs again......the output goes high then goes low then high again whereas it needs to stay high for as long as the input is at 0V then remain high for a further 2 seconds

The input needs to be at 0V on the SIM due to the car interface circuit

I have not as yet built the project but wonder if this is just a quirk of the SIM ?



"Front" operates relay 1 for 2 seconds, "rear" operates a polarity changeover relay which reverses the pump to wash the rear screen then operates relay 1 for 2 seconds ....

Code is ultra simple and runs on an '08M - copied below as is the ct diagram

Thanks in advance



#picaxe 08m ; car washer controller
; front operates o/p 1 for 2 sec or until button released, rear operates o/p 2(c/over relay)...then o/p 1 for 2 sec or until button released
; NOTE : To program PIC...power it down, press F5 then power up immediately

SYMBOL relay1 = 1 ; out to supply relay via o/p 1 (picaxe pin 6 - washes front)
SYMBOL relay2 = 2 ; out to polarity changeover relay via output 2 (Picaxe pin 5 - washes rear)

low relay1 ; ensure relay released
low relay2 ; ensure relay released

main:
b4=0 ; zero counter
if pin3 = 0 then gosub washfront ; inverted due to input interface cct
if pin4 = 0 then gosub washrear ; inverted due to input interface cct
goto main ; loops around "main" code until an input is pressed

washfront:
for b4=1 to 10 ; 2 sec timer
high relay1 ; operate supply relay (washes front)
pause 200 ; pause for 200 msec
next b4 ; = 10 x 200msec
low relay1
return

washrear:
high relay2 ; operate polarity changeover relay
gosub washfront ; 2 sec timer
low relay2 ; release polarity changeover relay
return
 

Attachments

Last edited:

tony_g

Senior Member
ive just run the code in sim and it works fine, relay output stays high for front for the required time then goes low and when i operate the rear relay 2 comes on then relay one for the specified time and then both off, have you updated your programming editor to the current 5.5.1, thats what version mine is at and it runs o.k unless ive missed something.

tony
 

davidwf

Senior Member
Wow, thanks for the quick reply :)

Yep, version 5.5.1

Have just uploaded a revised code (even less !) but it still does the same thing with one or both i/p held low
 

davidwf

Senior Member
.....i.e. with input(s) remaining low the o/p goes high, timer counts to 10, o/p goes low, re-starts again, o/p high etc...
 

davidwf

Senior Member
is there any way of capturing / recording what my SIM does so you can see the problem ?
I am using Win 7
 

tony_g

Senior Member
if you need to see a 0v from the car to activate the inputs i would suspect they need to be kept high until the incoming signal from the cars circuit pulls them low to 0v to run each cycle similar to but opposite of when we want a high input from a switch connected to v+ to do something we normally tie it low so it doesnt get any false readings. if you run the sim with 3 and 4 high it should be similar to them being pulled up to v+ and then deactivating each one individually for a brief moment would be similar to the input seeing a 0v from the cars circuit
 

davidwf

Senior Member
The input from the car is at +12V, I am converting this with a transistor which will invert the input nicely and give 0V or +5V .... that part of it should work OK

The SIM does do what you suggest above but it's when the input is held low continuously that the problem arises
 
Last edited:

tony_g

Senior Member
do you mean as to simulate if you wanted to hold the washer switch longer to get a continuous stream of screenwash as opposed to the brief 2 seconds it would give with a push and release?
 

tony_g

Senior Member
also need to take into account that running in simulator to test code runs at a significantly lower speed than the actual chip in a circuit running at 4mhz or higher so the relays would seem to be continuosly on all the while the inputs are held low with no noticeable break or interruption in the cycle
 

westaust55

Moderator
It is unlikely to fix your problem but be aware that the current version of the PE as at Dec 2012 is V5.5.4
(V5.5.3 out Nov 2012)
 

westaust55

Moderator
typo fix

If I have understood your problem correctly, the "problem" is that if you keep an input low, the wash cycle keeps repeating.
That situation is normal.
What you need to do is in add some extra code to wait for the inputs to go high before proceeding with your input monitoring loop.
 
Last edited:

davidwf

Senior Member
If I have understood your problem correctly, the "proem" is that if you keep an input low, the wash cycle keeps repeating.
That situation is normal.
What you need to do is in add some extra code to wait for the inputs to go high before proceeding with your input monitoring loop.
As per reply to tony_g.....
do you mean as to simulate if you wanted to hold the washer switch longer to get a continuous stream of screenwash as opposed to the brief 2 seconds it would give with a push and release?

.............yes, that's exactly it

Thanks for the update info to P.E. :)
 

westaust55

Moderator
so does the following do what you seek:

Code:
#picaxe 08m ; car washer controller
; front operates o/p 1 for 2 sec or until button released, rear operates o/p 2(c/over relay)...then o/p 1 for 2 sec or until button released
; NOTE : To program PIC...power it down, press F5 then power up immediately

SYMBOL relay1 = 1 ; out to supply relay via o/p 1 (picaxe pin 6 - washes front)
SYMBOL relay2 = 2 ; out to polarity changeover relay via output 2 (Picaxe pin 5 - washes rear)

low relay1 ; ensure relay released
low relay2 ; ensure relay released

main:
	DO
		if pin3 = 0 then gosub washfront ; inverted due to input interface cct
		if pin4 = 0 then gosub washrear ; inverted due to input interface cct
	LOOP ; loops around "main" code until an input is pressed

washfront:
	high relay1 ; operate supply relay (washes front)
	pause 2000 ; pause for 200 msec

WaitTillReleased:
	IF pin3 = 0 OR pin4 = 0 THEN WaitTillReleased

	low relay1 
	return

washrear:
	high relay2 ; operate polarity changeover relay
	gosub washfront ; 2 sec timer
	low relay2 ; release polarity changeover relay
	return
Note that I have also put the program listing in code tags as per forum policy, and also indented the program lines to reflect the looping and other structures of the program which will, particulalry when you get to longer programs make it easier to read/understand the program flow.
 

davidwf

Senior Member
Hi Westaust55.....thanks for your input - I knew it wouldn't be long :) :)

Yes, that seems to work as intended

Thanks :)
 

davidwf

Senior Member
SteveT
thanks for that....however I don't want to mess with the CAN BUS system.....I will isolate the pump and connect it to my cct then tee into the switch so it will work properly like "old" cars used to :)
 

davidwf

Senior Member
Built the circuit today and with MY ORIGINAL code it does indeed "pulse" - presumably as the PIC resets and goes back to "main"

However, the code kindly modified by westaust55 works correctly although I have modified it slightly and also amended the cct diagram so the ins & outs all tie up now

Thanks for the quick replies and help.....I think that pretty much wraps it up nicely :)

Code:
#picaxe 08m ; car washer controller
; front operates o/p 1 for 2 sec or until button released, rear operates o/p 2(c/over relay)...then o/p 1 for 2 sec or until button released
; NOTE : To program PIC...power it down, press F5 then power up immediately

SYMBOL relay1 = 1 ; out to polarity changeover relay via output 1 (Picaxe pin 6 - ready to wash rear)
SYMBOL relay2 = 2 ; out to supply relay via o/p 2 (picaxe pin 5 - washes front) 

low relay1 ; ensure relay released
low relay2 ; ensure relay released

main:
	DO
		if pin3 = 0 then gosub washfront ; inverted due to input interface cct
		if pin4 = 0 then gosub washrear ; inverted due to input interface cct
	LOOP                 ; loops around "main" code until an input is pressed

washfront:
	high relay2          ; operate supply relay (washes front)
	pause 2000 	; pause for 2 sec

WaitTillReleased:
	IF pin3 = 0 OR pin4 = 0 THEN WaitTillReleased
	low relay2 
	return

washrear:
	high relay1 	; operate polarity changeover relay
	gosub washfront 	; 2 sec timer
	low relay1 		; release polarity changeover relay
	return
 

Attachments

Last edited:
Top