Reinventing the wheel
My buddy Kit is always up to something wonderful. We have collaborated on a few pieces in the past including a pachinko machine converted into a jukebox, a pinball machine that plays pinball wizard, and a drawing robot. This time he presented the carcass of a slot machine. I love these projects, as they always involve trying something new and often involve solving what is to me a mystery of engineering. So, how to make it look like this thing works. Sound effects and music, not an issue, we have done that a few times. But the wheels and switches, those could be interesting.
The original thought was to use an LED matrix to replace the wheels and use animation to replace the spinning of the wheel. While that seemed workable, the resolution of the matrix that would fit was limiting. I noticed that the wheels were still intact. Thus began a journey to reverse engineer the wheels so that we could control them ourselves.
One look at the motors gave me pause. I can deal with 4 wire or 6 wire or even 8 wire stepper motors. But this sucker had 5 wires ( red, yellow, black, tan, orange). A bit of the google told me that this was a unipolar motor. Dang, I have not played with these before. My stepper motor-fu was very much not ready for this. So, first attempt, was to swap those motors out for a bipolar motor that I could confidently control. I have piles of those on hand. Build up a wheel with the motor swapped for one I could manage. It went togeher and spin but the interface between the 5 of 6 mm shafts of my motors and the 1/4 inch shaft the wheel wanted to be driven with proved harder that it looked. The shaft coupling could not take the torque and vibration associated with speeding up the wheel and then stopping it in the desired position. After a few spins, it would fail. No easy answer via motor swap is seems.
So, back to the original motors. More googles. Still no clear path. So, brute force. Figure out which of the 5 wires was the common / center tap. Multimeter to the rescue. Yep, black is the common. The google suggested that grounding that and connecting the other 4 to the motor driver could work. Nope.
Just as I had given up and was in the process of removing the wires, I got lucky. I started by unplugging the common/center tap. That got a twitch out of the motor. A twicth means life so, a few more minutes of fiddling and BOOM, I can drive that sucker.
It is not pretty. It is occasionally unhappy with the first few pulses. But it works. So, woot and all of that.
I have the current limited to about 1 to 1.5 amp and these are fairly large NAMA 23 motors so some of that motor angst may simply be not enough current to for those early pulses. Early days still so i am considering taking the current limit up to as much as 3 amps. I could not find the specs for this specific motor so starting low out of caution. I suspect I will also need a more capable power supply for these suckers. Luckily Kit has provided one.
In any event, I can spin the wheels like a stepper motor. This means “stepping” the motor to make it move. One step = 1/200th of a rotation in this case. So, to make it spin, you have the arduino run a bunch of steps in quick succession. You can control the speed by how long you wait between steps. You can control the amount of movement by the number of steps.
So, turned my attention to the encoder. It looks a bit like the optical switches used in some motion control systems (CNC machines). These are “u” shaped devices that can be used detect when there is something inside the u or not. In this case, it presented itself as 4 wires emerging from a deep hole in the wheel frame.
From way back in my derby car logger projects, I had a bit of understanding of how they worked. One side is a light source (probably IR) and the other side is a photocell that changes resistance based on how much light is is receiving. Block the light and the resistance changes. So figure out which 2 wires go to the light source and power them, then figure out what happens when blocked vs unblocked in terms of resistance which could be measured on the other 2. Ok, the resistance changes a ton. I can use that. Connect one of the to ground and the other to an arduino input pin set to INPUT_PULLUP. That pin setting means the pin will be weakly held “high” but if given a chance, like when you connect it to ground, can be pulled “LOW”. In this case, when the resistance in the switch is high, the pin will be HIGH but when the resistance drops enough, the pin will be pulled low. So, those 4 wires have become a switch that could be read by an arduino. Now what?
Looking at the wheel, I observed a ring that passes neatly within the “U” as the wheel spins. That ring has a bunch of large and small slots in it. The pattern of large then small, repeats itself around the ring 10 times. the 11th time the large slot is replaced by a pair of small slots. You can see this on the wheel just above the green single bar symbol. So, using this ring and the optical switch, as the wheel spins I can have the arduino look for the lack of the large slot. This was done by having the arduino look for that switch to go from high to low and keeping track of how many steps have happened since the last time it did the same. There is only one place where the number of steps is small 3 times in a row. Finding that spot reliably means the Arduino knows the position of the wheel. I can then move in increments of 18 steps to move to each of the symbols in turn. So the code does this: spin the wheels for a while (all at once which requires some tricky fu as well but this post is long enough already), then look for that spot on each wheel’s encoder ring, then knowing that, keep spinning them into a final location which was predetermined (just like the slots in Vegas).
So, got it working with one wheel, then wired in a 2nd wheel. That worked better than expected but has exposed the need to move to a better power supply for the wheels. So, getting there. Stay tuned.