Page 1 of 1

Candy Machine

Posted: Thu Sep 16, 2021 6:37 pm
by electron67
Hello everyone,

A question about servos; I am using a servo to open and close a door which releases candy; It works by inserting a coin, activates the servo and opens the door to release a certain amount of candys. The problem I had was that sometimes the door stayed a little open and the candys came out continuously; add to the servo SETPOSITION (0. 0) and the problem was corrected, but now the servo maintains a constant vibration on the door, can the servo be kept without vibration? and the door fully closed until a coin is deposited.
servoDOOR.fcfx
Flow
(12.56 KiB) Downloaded 164 times
Thanks
Enrique

Re: Candy Machine

Posted: Fri Sep 17, 2021 9:38 am
by Benj
Hi Enrique,

Sounds like a sweet project :D bad dad jokes there I'm sorry :wink:

If you set position 0 and then wait say half a second for the motor to move into position then you can call the disable macro to switch off the motor output. This will cut power to the motor and stop the vibration.

Then when you want to move the motor again just enable it again first.

Re: Candy Machine

Posted: Fri Sep 17, 2021 3:25 pm
by electron67
Hi Benj, I know it sounds very sweet :D

I use SETPOSITION (0, 0) and then DISABLE SERVO, but sometimes the door opens a little and I wanted that without using a level switch, through programming the door would be kept closed safely. Is there a way to use the function (IF) using some variable (X) to check if the position of the servo is zero 0 ?

The problem is that in a few seconds the content is emptied, when the door is not completely closed. :(

Enrique

Re: Candy Machine

Posted: Fri Sep 17, 2021 3:41 pm
by electron67
This is the flowchart I was using. . . .then add the option SETPOSITION (0, 0) in the sequence of the program when it is waiting for the coin to be deposited to make sure the door does not stay open, that's where the vibration started.
servoDOOR1.fcfx
(13.17 KiB) Downloaded 183 times

Re: Candy Machine

Posted: Fri Sep 17, 2021 4:05 pm
by Benj
How about a little micro switch on the door to check if it is properly closed?

Re: Candy Machine

Posted: Fri Sep 17, 2021 4:28 pm
by electron67
I tried with a level switch, but I have the idea of making a few devices and I was looking for a way to simplify the manufacturing and speed up the assembly, trying to correct the fault with software. . .but I think it would be the safest option.

Re: Candy Machine

Posted: Wed Sep 22, 2021 1:48 pm
by Benj
Hello,

The vibration could be the motor trying to seek to a position it cannot physically get to. It might be better to try and find a nice position where the door is shut and the motor is happy and essentially off. To do this you could move the motor in small increments until the door is shut and then store this shut position into the MCU EEPROM. This might hopefully negate the need for a limit switch and get rid of the vibrations.

Re: Candy Machine

Posted: Wed Sep 22, 2021 4:12 pm
by AbhijitR
Hello! Enrique

Kindly excuse i am not aware of the setup of your project, this is a suggestion if it is possible for you to use a magnetic reed switch then you have a probability of setting the vicinity of operation of the reed switch by placing the magnet close or far as per your requirement, may be you do not get this opportunity while using a mechanical switch.

Abhi