I have a project so I went down to Maplin bought an UNO and a motorshield and some components including some LDR and some other bits. There's a huge amount of information here but it can be quite difficult identifying which bits are relevant. I hope I can get some help.

So the questions:

1. For this project the core is a state-machine for which I think the code will all be sequential but is there a time clock interrupt for implementing a time sliced process?

2. Can you suggest a motor or what do I need to consider. I need to be able to drive a motor to rotate in fixed 60 deg (or multiples thereof and forwards or backwards) but no more than 360 deg in one movement. A movement needs to be complete in about 0.1 second. The item it is driving is a hollow cylinder about 40mm in diameter and weighing about 120gm. I'm happy to pay for something reliable.

3. I bought the LDR because I need to identify whether there is a threshold of light in 4 places. My first thought is to link each one up to a digital input. But is there a better way of doing this? I did wonder if I could get the input as a bit set binary number.

PS The programming seems to be reasonably straightforward (at the moment). The electronics wil become a challenge.PPS I wonder whether I should have split this up into seperate threads.

1. For this project the core is a state-machine for which I think the code will all be sequential but is there a time clock interrupt for implementing a time sliced process?

Yes, no, and maybe. You'll need to provide more details on what you want to do.

Quote

2. Can you suggest a motor or what do I need to consider.

I'm partial to the Chevy 350. Of course, that might be just a little bigger, or smaller, than what you need. Hard to say, without knowing what the motor is for.

Quote

I need to be able to drive a motor to rotate in fixed 60 deg (or multiples thereof and forwards or backwards) but no more than 360 deg in one movement. A movement needs to be complete in about 0.1 second. The item it is driving is a hollow cylinder about 40mm in diameter and weighing about 120gm. I'm happy to pay for something reliable.

Oh, OK. This is better. Is "a movement" 60 degrees? How is the hollow cylinder supported? How is the motor going to actually move the cylinder?

Quote

3. I bought the LDR because I need to identify whether there is a threshold of light in 4 places. My first thought is to link each one up to a digital input. But is there a better way of doing this? I did wonder if I could get the input as a bit set binary number.

An LDR is not a digital device. You can set a bit if the value is over a threshold, or clear it if the value is under a threshold.

> 1. For this project the core is a state-machine for which I think the code will all be sequential > but is there a time clock interrupt for implementing a time sliced process?

There are timers that can generate interrupts but there is no OS to provide pre-emptive multi-tasking. In 99% of cases you don't need the overhead of a multi-tasking operating system to do anything you want.

> 2. Can you suggest a motor or what do I need to consider. I need to be able to drive a motor > to rotate in fixed 60 deg (or multiples thereof and forwards or backwards) but no more > than 360 deg in one movement. A movement needs to be complete in about 0.1 second. > The item it is driving is a hollow cylinder about 40mm in diameter and weighing about 120gm. > I'm happy to pay for something reliable.

To get that kind of speed (360 degrees in 0.1 seconds = 600 RPM) you would likely need a hefty DC motor with position feedback (rotary encoder). A stepper motor is likely too slow and a servo motor generally only turns about 180 degrees total, let alone 360 at a time.

2. Time slicing. I don't need it for this project. The sort of reason for thinking about it is: a process which is controlling motion and needing to check every 1/10 sec for inputs on any sensor.

Turning a motor on is all that is needed to get it going. Turning it off after the proper duration does not require continuous monitoring. You can read sensor input, then see if it is time to turn the motor off. No "time slicing/multi-tasking" required.

Turning a motor exactly 60 degrees, at an average speed of 600 rpm is going to be a challenge, no matter what motor or drive arrangement you come up with.

If you only need to move 360 degrees away from the starting point, I'd suggest using a fast servo with a 2:1 ratio between the servo output and the thing you want to drive, so 180 degrees on the servo gives you 360 degrees on your driven cylinder. Getting a servo with an adequate combination of torque and speed could be problematic, but I think you have a chance.

On the other hand if you need to move an arbitrary angle away from the starting point you have a much harder problem. Accelerating, decelerating and getting any sort of accuracy on the resting position is going to be quite challenging in that sort of timescale. In that case I'd try to come up with some sort of mechanical drive system that moved in increments of 60 degrees so that you just need to cycle it through the required number of steps and not try to interactively control the position and acceleration of the motor.

I only provide help via the forum - please do not contact me for private consultancy.

I am really glad I asked the question asall your comments are making me think.

PeterH: 1. It is always fixed positions (and small errors in position are ok). Thinking about it I could probably redesign the main component so that everything is accomplished in a 180 deg but it would add to the weight It may weight 280 gm. It would also reduce the rotation to 300 rpm.

2.

Quote

come up with some sort of mechanical drive system that moved in increments of 60 degrees

Not quite sure how to do this. Maybe something like an escapement on a clock, or a continuiously running motor with a flywheel, clutch and brake Though that does seem to start getting complex.

So what is it you are really trying to do?. Don't talk about "time slicing" or FSM's and such. State your real goal, no buzz words, no star trek style techno bablle just plain English. If you get rid of the rubbish that you don't understand and we think is boring then maybe we can help you.

Thank you for your interest. The key bit I am trying to resolve, was described in my first post but I have copied it below, and there have been a some really useful observations made here about the practicality of this 2. Can you suggest a motor or what do I need to consider. I need to be able to drive a motor to rotate in fixed 60 deg (or multiples thereof and forwards or backwards) but no more than 360 deg in one movement. A movement needs to be complete in about 0.1 second. The item it is driving is a hollow cylinder about 40mm in diameter and weighing about 120gm. I'm happy to pay for something reliable.

Don't talk about "time slicing" or FSM's and such. State your real goal, no buzz words, no star trek style techno bablle just plain English. If you get rid of the rubbish that you don't understand and we think is boring then maybe we can help you.

Mark

On the subject of timeslicing this article explains it reasonably well http://en.wikipedia.org/wiki/Preemption_(computing) I have used it commercially for writing operating systems and for things like aircraft simulators, missile guidence systems etc so implementing a timeslice process for my needs should be reasonably straightforward. My commercial coding of these things finished about 30 years ago; the coding was mostly in machine code or we might write an assembler.

Personally, given the requirements, I would think that a reasonably gutsy stepper motor would be the easiest solution. 600 rpm isn't CRAZY fast, but it's not unreasonable either. Sixty degrees is just 1/6 rotation... So that isn't a huge deal. Reasonably high torque is easily done with a stepper, and they can be very fast....

On the subject of timeslicing this article explains it reasonably well

We're not asking you to explain the buzzwords you used in your post. The point is that they are irrelevant to the problem. We need to understand what your solution is trying to achieve, not the software mechanisms that you think will be needed to implement it.

I only provide help via the forum - please do not contact me for private consultancy.

Personally, given the requirements, I would think that a reasonably gutsy stepper motor would be the easiest solution. 600 rpm isn't CRAZY fast, but it's not unreasonable either. Sixty degrees is just 1/6 rotation... So that isn't a huge deal. Reasonably high torque is easily done with a stepper, and they can be very fast....

Now, that's just the first Google hit- but if you pull up their spec pdfs from near the bottom of the page, 600 rpm isn't a problem, in fact the specs are given for the range of 100-2250 RPM as a standard it looks like.

Those are pretty much industry standard stepper motors, and any maker will have something similar. Since most of the libs for arduino have been written for unipolar stepper motors, and the wiring for them is easier (no h-bridge needed), I would choose a unipolar motor.

I am not recommending any maker or seller, by any means- so shop around. The device you need however- very easily gotten, and isn't particularly expensive or hard to find. I probably have half a dozen in a box that would fit the bill, I rip them out of printers (a very common use for small stepper motors) before they are sent to the great recycling bin in the sky. For driver circuitry, you'll need a reasonably hefty couple of switching transistors as the windings are going to want a bit of current. There's also dedicated chips for this purpose. If you want to avoid the wiring bits as much as possible, look into a motor shield (http://arduino.cc/en/Main/ArduinoMotorShieldR3) or (http://www.ladyada.net/make/mshield/) or others.

Stepper motors work by taking "steps", in the case of most of the ones linked above, they have a step of 1.8 degrees.. 200 steps per revolution. This is going to get you pretty darn close to exactly 60 degrees, but not exact. I'm betting that will be within spec for your use, if not, then it's a matter of gear-reducing the output for accuracy and increasing the speed to compensate. Note, that is using FULL stepping, if using half-stepping or microstepping you are more accurate but provides less torque.

Hi,eventually, cold and flu intervened to distract me, I have purchased a hybrid stepper motor. As I need to move in approximately 60deg segments and at most a single 240deg turn Bipolar Parallel seems the best option.I also have the Arduino Motor Shield.