Flasher Circuit Help

Axel87

Senior Member
Working on my first VSM circuit.
Looking for a little help as how to get this properly laid out, and the circuit isnt working as expected.
The simulation file should give you a good idea how this is supposed to work.View attachment Motorcycle Flasher Program.bas
Upon 3 pushes of the horn, the flasher should engage.
A 12V supply, with the 5v regulator to supply the input for picaxe.
I will try my best to answer any questions.
Thank you for the assistance.

Code:
setint %00000010,%00000010 ;arm interrupt for high on pin C.1

init:
    let b0 = 0 ;switch counter byte
    gosub allLow ;make sure the turn signals are all off

main:
    if b0 = 3 then flasher
    goto main

flasher: 
	high b.5		; LF Turn Signal High 
	high b.4		; RF Turn Signal High 
	high b.3		; LR Turn Signal High 
	high b.2		; RR Turn Signal High 
	if b0 = 4 then init ;check counter byte for 6th button press, if so, exit to init without having to wait for the 1 second pause below
	pause 1000		; for simulation only
	gosub allLow	; put all turn signals low ^
	if b0 = 4 then init ;this here again so, on 6th button press, user will see immediate exit to init without having to wait for the 1 second pause below
	pause 1000
	goto flasher
	
allLow:
	low b.5 		; LF Turn Signal Low
	low b.4		; RF Turn Signal Low
	low b.3		; LR Turn Signal Low
	low b.2		; RR Turn Signal Low
	return

interrupt:
     
     if pinC.1 = 1 then 
          goto interrupt ;debounce switch
     elseif pinC.1 = 0 then endif
     do if pinc.1=0 then inc b0 
     elseif b0 =5 then goto flasher 
     if b0=>1 then
          goto init:
          loop
     endif
     endif
     setint %00000010,%00000010 ;re-arm interrupt for high on pin C.1
     return
 

hippy

Technical Support
Staff member
Your interrupt code is quite convoluted and you cannot exit the interrupt by using GOTO into the main part of the program as that will prevent your button push causing an interrupt activation later.
 

Axel87

Senior Member
Thank you for the input hippy.
I guess I dont know how else to approach that right now.
My main concern with this post is the VSM circuit.
I am sure there are do's and dont's when completing these, so checking if this looks alright or if I should change my thinking.
I welcome any other input as well of course!
Thanks again guys
 

vttom

Senior Member
It sounds like you want advice on your circuit, but have not provided a schematic diagram. Can you post the schematic?

Also, I agree that your interrupt subroutine is much more complicated than it needs to be. I believe this will suffice:

Code:
interrupt:
     
     if pinC.1 = 1 then 
          goto interrupt 'debounce switch
     endif
     inc b0 
     setint %00000010,%00000010 're-arm interrupt for high on pin C.1
     return
 

Axel87

Senior Member
Untitled.png

Attached is a very...very.. unprofessional example of the circuit.
I apologize for the delay, and the turn out. I have been thinking on how I can best represent this, without the tools to provide you with a real schematic.
Since I have been learning VSM, to both churn out a schematic and breadboard practice while away from my workbench.

The code has been designed for a certain number of horn presses- activates the flasher circuit.
The two issues I am having right now-
One- I would like to know how others "layout" there projects on a given space. Does this come with practice? Can anyone with more experience with this provide any insight?
2- I am having trouble figuring out how to wire up my relays to make this circuit work in simulation.

I apologize for the lack of a proper schematic, I dont know how to provide you with a better representation at this point.
Willing to learn tho!
Thanks
 

Paix

Senior Member
@Axel, Sorry that I don't have the time available just at the moment, but I will see what I can put together to guide you, but if you have a clean sheet of white paper, a pencil, draw out the diagram nice and clearly and if you need to use colour, pen over the appropriate lines with felt tip pens and use a scanner, camera or phone camera with good light to get a good readable image.

There are a number of free drawing packages out there that can help to one degree or another. If you draw a library of different components, then you can copy and drag them all around the place and just join them up.

Are you using Windows? I'll have a look to see what might be good to go without parting with anything other than a free download.
 

Axel87

Senior Member
Paix-

I am using Windows.
I apologize for the delayed response- hectic life pulls me away from these fun projects.
Anyhow, I would like to better represent my idea here but am having trouble putting it on paper for others to understand. I thought that this is what VSM would be for?
If you can recommend a better program for me, I will be happy to give it a go
Thanks again
 
Top