Geneva mechanism on Arduino

I am trying to make a Geneva wheel using Arduino.

The hexagon Geneva magnificent mechanism allows a rotating wheel to stop at each of 6 steps on the wheel for a short while and them move to the next one. It can be designed for octagon, pentagon, or anygon..

see this link abot Geneva mechanism

http://en.wikipedia.org/wiki/Geneva_drive

Below is a suggested code for a 4 stops using a sensor on arduino. Can anyone comment if it works ?

Tray_rotator_arduino2.jpg

 

suggested code

/*

   Conditionals - If statement

 

  This example demonstrates the use of if() statements.

  It reads the state of a potentiometer (an analog input) and turns on an LED

  only if the LED goes above a certain threshold level. It prints the analog value

  regardless of the level. 

 

 

created 17 Jan 2009

  modified 9 Apr 2012

  by Tom Igoe

  modified 12 Feb 2015 by Robopunk

 

 This example code is in the public domain.

 

 http://arduino.cc/en/Tutorial/IfStatement

 

  */

 

// These constants won't change:

 const int analogPin = A0;    // pin that the IR sensor is attached to

 const int MotPin = 9;       // pin that Motor driver transistor is attached to

 const int threshold = 400;   // an arbitrary threshold level that's in the range of the analog input

 

void setup() {

   // initialize the motor pin as an output:

   pinMode(MotPin, OUTPUT);

   // initialize serial communications:

   Serial.begin(9600);

}

 

void loop() {

   // read the value of the IR

   int analogValue = analogRead(analogPin);

 

   // if the analog value is high enough, turn on the motor:

   if (analogValue > threshold) {

     digitalWrite(MotPin, HIGH);

delay(3000);

 digitalWrite(MotPin,LOW); 

 

   } 

   else {

     digitalWrite(MotPin,LOW); 

   }

 

   // print the analog value:

   Serial.println(analogValue);

   delay(1);        // delay in between reads for stability

}

 

Indeed Geneva mechanism is a

Indeed Geneva mechanism is a marvel and it still moving inside most mechnical & chrono watches. DangerousThing expressed it better than me, yea it is sort of simple encoder to emulate the Geneva setup. Now I ran the code and it did not function. Code complies, but the motor keeps running until I off the power. Any clue where it went worng ? I posted the schematic, but somehow it did not appear. It is a IR reflection optocoupler feeding reflected signal to A0 in Arduino. While Arduino output D9 feeds a 2N2222 through 1K resistor, then the transistor powers a small DC motor with a Diode in parallel. the Delay(3000) supposed to stop the motor for 3 secs at each time sensor receives signal above threshold.

 

I’m assuming that RoboPunk
I’m assuming that RoboPunk has an IR source on the other side of a disk with holes or cutouts, sort of like a simple encoder, and wants to replace the elegant and simple Geneva mechanism with an Arduino for unknown purposes.

Frankly I stand in awe of the person who invented the original Geneva mechanism. It seems so obvious with a simple animation, but I don’t think I would have thought of it. Of course, I also stand in awe of the person who invented the refrigerator magnet, so I may not be the best judge of inventors.

Now, the person who used a refrigerator magnet to hold his floppy disks to the refrigerator may have qualified for a Darwin Award when his sys admin finally found out. :slight_smile:

You send the value read to
You send the value read to the console. Does analogValue ever get above threshold?

And shouldn’t turning the motor pin high turn the motor on, or am I reading things wrong?

**Two points:

You can make**
Two points:

  1. You can make your code a little bit more elegant by removing the else clause. Since both parts of the if/else statements end with the same digitalWrite statement, then put that beneath the if statement.

  2. I’m definitely not a hardware guru and I don’t have my stuff here, this may be wrong. However, I’m thinking you might want a pull up or down resister.

Thanks alot, well below

Thanks alot, well below changes, I will try it tonight when I am back and see.

if it works, we have an advantage here is that Arduino-Geneva wheel can stop not necessarily at equal intervals like the mechanical Geneva, but at any interval depending on where we distribute the reflection points,

 

 

   digitalWrite(MotPin, HIGH);

   // if the analog value is high enough, turn off the motor for 3 seconds then move again until you  face next batch:

   if (analogValue > threshold) {

     digitalWrite(MotPin, LOW);

 dealy(3000);

 digitalWrite(MotPin, HIGH); 

   } 

   // print the analog value:

   Serial.println(analogValue);

   delay(1);        // delay in between reads for stability

}

Best invention ever IMHO

coffee-cup-holder.jpg

Or you could just use a rotary encoder
and program it for however many stops you want without having to change the hardware.

Thanks for the tips. I was

Thanks for the tips. I was using threshold to set the distance between IR sensor & the spinning tray. The spinning tray is painted mat black & is 10 inch Dia. set to spin continuously but if the sesnor meets the reflective patch(sticker made of aluminum foil), threshold is exceeded and motor stops for 3 seconds and then resumes rotation till it meets the next reflective patch.

The reason I chose this sketch is that without modifying sketch I can change number and spacing of reflective patches any way I need. This is better than the Geneva concept because it can stop at unequal slices of the spinning tray without modifying the skecth because it depends the reflective patch wherever it is located…