Pulse button control motor

lamxe

Senior Member
Dear all.
I have copied and modified this code from
http://www.picaxeforum.co.uk/showthread.php?17977-How-do-I-Count-Pulses/page2
for driver 2 motors + hall sensor
in my mini coil winding machine but with my bad experienced not work.
Please could you help me to to correct my wrong code or an new code. Many thank you
//////////////////////////////////////////
In PSEUDO code
Start :
High motor A ; motor A continuous running
Low motor B ; motor B repose and wait until a trigger negative edge
from hall sensor of motor A at twelfth pulse and turn on
High motor B ; motor B start running
Wait until a negative edge pulse at hall sensor of motor B and turn off ( it mean B motor turning only 1 turn at 12th turn of A motor
and repeat)
LOOP.
//////////////////////////////////
Code:
         My bad code
symbol  MotorB = 1           'motor B on output 1 (pin 6 of chip)
symbol pbswitch1  = pin3     ' Hall sensor switch on pin3 = hall sensor (pin 4 of chip)
symbol pbswitch2  = pin2     ;Hall sensor switch on pin2 = hall sensor (pin 3 of chip)
symbol down = 0            ' define input state
symbol counter = b0

Init:
	counter = 0                'set counter to 0 before starting
	SETINT %00000, %01000

Main:
	IF counter = 12 THEN GOSUB turn
	if pbswitch2 = 1 then gosub arret

	; do any other commands here for other functionality
	
	GOTO Main
	
turn:
	HIGH MotorB            'turn motor on
	        
	COUNTER = 0              ' reset counter
	RETURN
arret:
	low  MotorB ;  turn  B motor off
	counter = 0
	RETURN

interrupt:
	inc counter
stilldown:	
	IF pbswitch1 = down THEN stilldown
	IF pbswitch2 = down THEN stilldown
	SETINT %00000, %01000
	RETURN
 
Last edited:
Top