Mon Apr 21, 2014 2:52 am
I'm a little confused by what you're actually asking. It sounds like you can already read the torque and turn (do you mean turning speed?) so you're already started if I understand correctly.
Where to go from here?
As far as programming languages, C or C++ will be about as fast as possible as far as run speed. However, that probably matters less in this application (truthfully, in most applications) than the time it takes to code it up, so my recommendation is to use whichever language is easiest for you to use. You can even use multiple languages for different parts. (i.e. call a separate program to read the torque, which happens to be written in a different language.) If you happen to find that your bash script (as an example, assuming for the sake of argument that that's what you find most familiar) isn't fast enough, you can translate it to C later, and probably more easily than coding it initially in a language you weren't as familiar with (if you're not very familiar with C.)
The first step in any coding project is to figure out exactly what you want your program to do. i.e. when the torque reaches TORQUE_LIMIT, then reverse direction for 3 seconds, stop the drill for 0.5 seconds, and resume drilling until either TORQUE_LIMIT is reached again, a depth sensor is triggered, or the operator sends a stop signal.
Design is often the hardest part. Once you know the steps your program should take, it's generally fairly simple to convert that into an algorithm, if you're already familiar with the language you're using.
The main idea is to break your project down into little bite-sized micro-projects. It sounds like you've already completed one of those. Now you just need to define what the rest of those entail. Once each of the pieces is working independently, you can put them together much more easily than building it up as one big project. It's also easier to debug a 5-line function that does one thing than your entire 800-line (or even 80-line) project, especially if you're not even sure if the bug is in hardware or software.
Also if you're building it in pieces, you can more easily prepare to add additional things like your temperature sensor, and just not build that piece until you need it. (for example, you can already call a read_temperature() function, but until you have a temperature sensor, that function is just: return (0); It's called a stub function, just acting as a placeholder.)
You said you already have the drill, and that includes the ADC to read the torque and turn. Does it also include a way to control the drill? If not and if it's a DC motor, you'll want to use an H-bridge. L298N is commonly used around here, but your drill may take more current that that will permit. If it's an AC motor... I'm not really sure.
You also didn't mention anything about controlling drill depth; either sensing depth or moving the drill. This is probably just as important as actually turning the bit. If you haven't already planned this out, it's going to be important to consider, and probably a large portion of your design and program.
Hope this helps.