-
Random failure of claw machine
03/08/2014 at 00:28 • 0 commentsSince day one the claw machine has had random lockups that I thought a watchdog timer would fix.
The three lockups that were seen were:
Button for claw drop would not activate claw drop routine. This was resolved by using the watchdog timer and to reset if the condition of "IF the joystick has control of the machine AND the claw drop routine interrupt was inactive, THEN do not reset watchdog" This seemed to clear up the random lockup.
The second was what would be what appeared to be the steppers getting noise on the step pin. Either the X or Y axis would start to move slowly and then accelerate. The code does not support different speeds of the motors, so I figured it had to be a noise issue caused by either the power supplies or the stepper drivers. Putting a scope to the 5V supply showed noise but none that could be associated to the random movement. Same for the 24V supply. I knew that the problem did not show up until the room was warmer. So I started to heat the circuit up with a little heater. The claw machine then started to show the signs of failure. I started poking around the step pins on the drivers and found that they were getting solid 0v 5v transitions. No noise. Also the MCLR circuit was very touchy. If I would touch the circuit, the steppers would then try to step very fast. I took the MCLR directly to 5V and still touching the pin would cause fast stepping. Questioning the design of the MCLR and the oscillator circuit, I took a closer look at both. Following Microchips design criteria for the MCLR did not fix the problem. Looking at the crystal, I mistakenly thought that it was a 4 MHz crystal as that is what I normally used for random projects. I had changed over to 20 MHz for some project in the past (not sure which) and failed to remember this. Checking the code, found the oscillator setting set to XT. Once I changed it to HS the problem went away. So it was a matter of the oscillators inability to keep time with low power.
The third problem was a random lockup when the claw was raised all the way up. The claw would pull up and when it got into the spring loaded seat, it would stop and still try to step. This would make audible missed step noise and a gentle push up of the claw would allow the upper limit switch to be activated and it would finish the home routine. I thought it was due to the plastic on aluminum contact that was causing a binding action. I replaced the plastic bushing with a sintered bronze but it still had the problem. So I bumped the current up to the stepper and the problem hasn't showed up again.
-
Toy Claw Machine Build
02/27/2014 at 03:18 • 0 commentsAs I gather more documentation and pictures for this build, it is planned to add later on. As for now:
Hardware:
Processing power 16F870 @ 20 MHz
Limit switches gnd out the PICs input and inputs utilize a 1K pull up resistor
PIC sends step/dir signals to all three axis using a timer interrupt to keep the correct step pulse rate.
Watchdog timer used to make sure the interrupt timer is still active and to detect if the steppers should be enabled, but the claw drop button is not active.
Port B interrupt used for claw drop button
Left RX/TX pins open to allow for expansion for computer control (or external uC)
Program structure:
Normal operation uses the interrupt timer for stepping the steppers the correct direction (this is both used for the joystick operation and the homing operation) The sub will contain checks to see where the state machine is at and if it will allow for the axis to move (I didn't want to be able to move the X and Y axis if the claw is raising/lowering)
The main program (not within the timer interrupt) is a state machine and loop within a state until the prescribed move on condition is met.
Claw drop button uses the port b interrupt along with a short debounce to keep out any noise from interfering.
Once the claw drop button has gone active and passed the debounce check, then lower the claw for a predetermined amount of time, close the claw (under full 24V power) then raise claw back up until z axis upper limit is active. Then home machine to prize drop corner.
The program is written in asm as that is what I am familiar with.