# program for stoping the motor with the feedback of Hall Sensor

8 years 8 months ago #29530754 by somu
Hello Everyone,

I'm using SBL 1360 contorller and I want to stop the motor by the Feedback given by the Hall counter so I wrote a Program

But the problem is motor is not stoping at the given count value. the motor is Stoping at hall counter value of 115.

below is the program what i wrote.

TOP:

COUNT=GETVALUE(_FEEDBK,1)

SETCOMMAND(_HOME,1)
setcommand(_GO,1,-600)

IF COUNT >10 THEN
SETCOMMAND(_GO,1,0)
END IF

WAIT(1000)
GOTO TOP

Please let me know what is problem in this script and how to correct it.

8 years 8 months ago #29530805
The problem is in the query. You are querying a feedback, rather than the actual count.

Since the command is telling the motor to spin in reverse, then the count will be negative. Therefore the motor in a sense won't stop, or won't stop unless it reaches position first.

If you are doing this based on the hall sensor count, then you query via the following command.

count = getvalue(_CB, 1)

Since you are going negative count, then the second argument looking for 10 should be -10 if you want it to go back to 0, unless for some reason the counter is counting positive for whatever reason.

if count < 10

8 years 8 months ago #29530824 by somu

I have made the changes as you mentioned but the motor is not stoping at given value.. for example if i give value of 20 the motor is stoping at 25 to 29. everytime i run program the motor is stoping at randam hall count value of 25 to 28.

setconfig(_rwd,0)
setcommand(_CB,1,0)
top:

setcommand(_GO, 1, 500)

if getvalue(_CB,1) <= 20 then
goto top
else
setcommand(_GO, 1, 0)
end if

somu

8 years 8 months ago #29530832
That is because the go command is a motor command for output %. If you want to go to a specific count, then you need to use the closed loop count position and use setcommand(_P, 1, value).

8 years 8 months ago - 8 years 8 months ago #29530850 by somu
I have one more issue, when i run a program its works fine for few times but sometimes it get's stall and motor won't work. then i have to switch off and switch on the controller power, then its starts working without changing anyting in program or configration.

why it is happening like this ? and how to come out of this problem? please let me know how to do it.

8 years 8 months ago #29530852
If it stalls, then something occurred to create the stall condition. You can cancel out the stall condition by doing the following. Setting the motor mode back to open loop, and sending the motor command to 0.