Controlling Rotational position.......

Rotational Control using Mega

Please help....

I'm planning on using a Mega, with the hope of using it to control a rotational turnhead that makes a complete 360 degree turn.

The idea is that the Turnhead is driven by a gearbox that will rotate on a 360 axis. The Arduino will ultimately energise a Starter(sending a HIGH signal using an IO Relay) for "Clockwise" rotation and different Starter for "Counter-Clockwise' rotation, de-energizing the stater when a limit switch(sending a HIGH signal to the arduino Via an IO Relay) position in reached. The Turnhead will have 6 independent limit switches(6 independent IO's) representing 6 positions.

I have all the mechanical, electrical components and IO circuitry ready to go, I just need a little hint on how to manipulate the code to look at the current position, then look at the required position based on the input state of the limit switch(if HIGH stop at position1 if LOW continue to position2 if HIGH stop at position2 if low continue to position3 and so on.... until all 6 positions have been looked at).

Any help you can provide would be greatly appreciated.

Thank you!!
Dave

How do you propose to overcome backlash in the gear-train or are you intending to fit the "detectors" to the actual table.

Then there is the inertia of the motor to consider if it's simply a conventional, rather than a stepper or servo, type. Nothing stops instantaneously so you have to allow for this slight over-run.

I take it you appreciate that an approach to a detector in a clockwise rotation of the table will produce a different positional result if the table approches the same detector from an anticlockwise direction. Read up about both Sod's law and Murphy'slaw for proofs of that.

My first inclination would be to use a stepper motor as a drive system then table position is determined by the number of steps you drive the motor (assuming of course that you neither lose count nor the stepper "slips") If using a stepper you either always drive in the same direction, or you intentionally overshoot by a known amount then step back to the desired point (just like you would do if driving a rotary machine-table by hand.

Perhaps some further insight to the actual project would help in developing an answer.

Thanx for your replay...

There is currently no backlash as the gear-train is designed to rotate and stop via a motor controller that has all ready been designed and implemented for this application, there is currently no over-run as the motor stops at the limit switch(sensor) as soon as the switch(sensor) is tripped.

The detector does not produce a different result with each change in position, and this is due to the program(and/or operator) recognizing the current sensor1 position and which direction to rotate while looking for sensor2 input that has been requested. However it is possible to redesign the current system to maintain a constant clockwise direction and look for sensor inputs.

The whole mechanical system currently works great and is operated in a manual fashion, and I would like to implement an automated system.

Best thing to do is get the mega and start testing.

zoomkat:
Best thing to do is get the mega and start testing.

I have been, for about 2 months now and still having trouble with the turnhead application.
However I have been able to get the mega to run the multiple gate and conv. system associated with the final build.
Its just the turnhead thats stumping me......

Its just the turnhead thats stumping me…

Well, without the turnhead controlling code and specifics on your wiring/hardware setup, I think the forum will also be stumped. If the limit switches are input to individual arduino pins, then the arduino can know where the turnhead is when an individual switch is activated. Below is some simple “switch” test code (I actually just touch wires) that positions a servo (aka, a specific switch is activated, do a specific thing).

//zoomkat servo button test 12-29-2011

#include <Servo.h>
int button1 = 4; //button pin, connect to ground to move servo
int press1 = 0;
int button2 = 5; //button pin, connect to ground to move servo
int press2 = 0;
Servo servo1;

void setup()
{
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  servo1.attach(7);
  digitalWrite(4, HIGH); //enable pullups to make pin high
  digitalWrite(5, HIGH); //enable pullups to make pin high
}

void loop()
{
  press1 = digitalRead(button1);
  if (press1 == LOW)
  {
    servo1.write(170);
  }    
  
  press2 = digitalRead(button2);
  if (press2 == LOW)
  {
    servo1.write(10);
  }
  
  /*else {
    servo1.write(90);
  }*/
}

jackrae:
How do you propose to overcome backlash in the gear-train or are you intending to fit the "detectors" to the actual table.

Then there is the inertia of the motor to consider if it's simply a conventional, rather than a stepper or servo, type. Nothing stops instantaneously so you have to allow for this slight over-run.

I take it you appreciate that an approach to a detector in a clockwise rotation of the table will produce a different positional result if the table approches the same detector from an anticlockwise direction. Read up about both Sod's law and Murphy'slaw for proofs of that.

My first inclination would be to use a stepper motor as a drive system then table position is determined by the number of steps you drive the motor (assuming of course that you neither lose count nor the stepper "slips") If using a stepper you either always drive in the same direction, or you intentionally overshoot by a known amount then step back to the desired point (just like you would do if driving a rotary machine-table by hand.

Perhaps some further insight to the actual project would help in developing an answer.

I'm not sure if your familiar with brake controlled motors?...they have special disk brake on the motor shaft which allows them to stop abruptly without damaging the gear-train.....and the sensors are magnetic pickup so when the turnhead passes the pickup sensor associated with the target bin it breaks the circuit stopping the turnhead at the selected bin, thats when the gate and conv. system that I have working on the mega2650 takes over to fill each bin and this process occurs for each bin. The current system operates a large bin fill system with 6 individual storage bins and each bin needs to be constantly filled at random. So it would be great to be able to do this with an automated system. I know it I have a lot of work ahead of me in order to make this work.....:slight_smile:

zoomkat:

Its just the turnhead thats stumping me…

Well, without the turnhead controlling code and specifics on your wiring/hardware setup, I think the forum will also be stumped. If the limit switches are input to individual arduino pins, then the arduino can know where the turnhead is when an individual switch is activated. Below is some simple “switch” test code (I actually just touch wires) that positions a servo (aka, a specific switch is activated, do a specific thing).

//zoomkat servo button test 12-29-2011

#include <Servo.h>
int button1 = 4; //button pin, connect to ground to move servo
int press1 = 0;
int button2 = 5; //button pin, connect to ground to move servo
int press2 = 0;
Servo servo1;

void setup()
{
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  servo1.attach(7);
  digitalWrite(4, HIGH); //enable pullups to make pin high
  digitalWrite(5, HIGH); //enable pullups to make pin high
}

void loop()
{
  press1 = digitalRead(button1);
  if (press1 == LOW)
  {
    servo1.write(170);
  }   
 
  press2 = digitalRead(button2);
  if (press2 == LOW)
  {
    servo1.write(10);
  }
 
  /else {
    servo1.write(90);
  }
/
}

Yes your right…each bin requires 1 input for each sensor, so 6 inputs for all 6 sensors should cover it, and the input signals can be LOW or HIGH. Then I need 2 outputs, these can also be LOW or HIGH to control direction of the turnhead, and if I redesign the motor controller for a single direction only, I only need one output to control the turnhead motor.

concretefreak:

zoomkat:

Its just the turnhead thats stumping me…

Well, without the turnhead controlling code and specifics on your wiring/hardware setup, I think the forum will also be stumped. If the limit switches are input to individual arduino pins, then the arduino can know where the turnhead is when an individual switch is activated. Below is some simple “switch” test code (I actually just touch wires) that positions a servo (aka, a specific switch is activated, do a specific thing).

//zoomkat servo button test 12-29-2011

#include <Servo.h>
int button1 = 4; //button pin, connect to ground to move servo
int press1 = 0;
int button2 = 5; //button pin, connect to ground to move servo
int press2 = 0;
Servo servo1;

void setup()
{
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  servo1.attach(7);
  digitalWrite(4, HIGH); //enable pullups to make pin high
  digitalWrite(5, HIGH); //enable pullups to make pin high
}

void loop()
{
  press1 = digitalRead(button1);
  if (press1 == LOW)
  {
    servo1.write(170);
  }   
 
  press2 = digitalRead(button2);
  if (press2 == LOW)
  {
    servo1.write(10);
  }
 
  /else {
    servo1.write(90);
  }
/
}

Yes your right…each bin requires 1 input for each sensor, so 6 inputs for all 6 sensors should cover it, and the input signals can be LOW or HIGH. Then I need 2 outputs, these can also be LOW or HIGH to control direction of the turnhead, and if I redesign the motor controller for a single direction only, I only need one output to control the turnhead motor.

Oh by the way…thank you!!..this will be a really great start, I’ll try playing around with this and see where it leads me…

Below is a typical two relay motor reversing setup with safety limit switches.