Show Posts
Pages: 1 ... 54 55 [56] 57
826  Using Arduino / Motors, Mechanics, and Power / Re: Micro Stepping without a motor Driver on: February 04, 2013, 04:56:50 pm
Micro-stepping is where you provide a sine-wave to each coil, 90 degrees out of phase with each other. The code presented is simulating the sine waves using PWM. Essentially, you need the beginning of one sinewave to start at the highest point of the first, etc.. etc..

Eh... a picture does better:

827  Using Arduino / Motors, Mechanics, and Power / Re: Wishing my Tamiya Motors Had More Drive on: February 04, 2013, 04:35:21 pm
Spinning one wheel faster than the other provides the turn motion. I will be the guy asking the really dumb question... the non-driven wheels. They are not connected to the same axle are they? They are independently free-running, right?

Spinning in opposite directions provides rotation along the center of the axle. In your configuration, that won't work because you are trying to spin along the center of the rear axle and the other wheels will act as brakes trying to move sideways. Omniwheels would work like this, but not normal wheels. Having some swing (even it is not controlled) would allow the front wheels to change angle with the friction, which would help since they are not trying to move sideways) would probably work, but not optimal. This is what a caster does.

Spinning one motor faster than the other puts the center of rotation on the center of the wheel spinning slower. Since the whole base continues to move forward while it does this, you are also causing the front wheels to spin at the same speed (assuming they are free-running). Now, your rotation is in an arc, with the center of rotation along one side of the base, instead of in the middle.

With a four wheeled base like you have, this is the correct way to do it.

Basically just image trying to turn a push-cart with wheels fixed in straight forward direction. You cant just pull one side back and push the other forward. You would have to push harder on one side. Of course, the turn radius is much larger. To decrease the turn radius, you use casters on the front wheels. This is why a car turns the front wheels to steer.

(I'm sure I boggled up that explanation.)
828  Using Arduino / Motors, Mechanics, and Power / Re: Motor Shield Capable of Driving 5 DC motors? on: February 04, 2013, 04:25:18 pm
Using the SCARA motors, which have a 5.54A theoretical current draw at stall?

That's the real kicker right there. A motor shield is really nothing more than an H-bridge and associated support components. If you are handy with perfboard, you could build one yourself. I tend to use TA7291S (in a freindyl SIP package), but these are rated at 1.2A max. Putting two in parallel would handle 2.4A, and so on (starting to get pricey though.)

I would look for H-bridge ICs that can handle up to 6A. I have no idea how easily you would find one. The other option is to build 5 h-bridge circuits that can handle that load by hand or find a battlebot style board.

I am suggesting this because I am not aware of an existing shield that meets your specifications. If you do find one that drive that current, but only has a few outputs, you can usually stack shields.

Personally, I would just build my own. YMMV
829  Using Arduino / Project Guidance / Re: best way to sense someone entering a room on: February 04, 2013, 04:07:47 pm
Sounds like you need a little clarification of your goal. Do you want the sandpaper to actuate when someone enters the room (as in only once per person) or do you want it to actuate the entire time someone is standing in the room (meaning the film scratches to nothing the longer someone stays?)

Monitoring just an entrace is the simplest way to count people. Depending on how you do that, it may have issues where it counts 2 people as one (though, if you put it at their legs, they would have to be walking perfectly in sync.) But how much does that really matter?

Maybe defining the overall purpose/effect you are trying to get would help. I am envisioning that this is an interactive exhibit where you are trying to show the degradation of an image the more it is viewed. Clarify your parameters, and I think people can be of more help.

BTW, a PIR sensor works by using two adjacent sensors angled slightly away from each other. Motion is detected by comparing the two sensors. The most you could determine from them (if you had a truly raw PIR sensor) is the direction of the movement. Most PIR modules have all the logic built in, which simply triggers if a sequential change between the two sensors is detected using comparators. *Technically* it can sense to some degree whether someone is continuing to stand in front of it, but again, you would need access to the raw sensors.

Automatic doors at the store uses radar for this purpose (a special band that is absorped by the human body.) Sonar would provide a similiar effect. Though if your project is as I am envisioning, a simple break-beam detector circuit would really be enough.
830  Using Arduino / Project Guidance / Re: Challenge: horizontally / inertially stabilize a pizza on motorcycle on: February 04, 2013, 03:55:19 pm
I think the biggest destructive force is that a motorcycle leans in turns. This would essentially lift the pizza up (assuming the box is affixed to the bike), which reduces the friction and the pizza will basically continue trying to stay in place while the box is moving. For most other movements of the bike, the friction of the pizza is likely enough to keep it moving along with the box. The little plastic spacer they put in the middle of the pizza would help a little with keeping the pizza from lifting.
831  Using Arduino / Project Guidance / Re: Connecting tft screen to arduino uno r3 on: February 04, 2013, 03:48:49 pm
No. Latches, to expand an 8 bit data bus to a 16 bit data bus. You latch the upper byte.
832  Using Arduino / Project Guidance / Re: Connecting tft screen to arduino uno r3 on: February 04, 2013, 03:12:13 pm
It looks like the controller has an I2C and SPI interface mode, but that is not enabled on your LCD. However, there is an SPI interface to the SD card and Touchscreen as well as CS for the display being brought out. Would have been so much simpler if they had just made it a common SPI bus with individual CS lines for the display, SD, and touchscreen.

The SPI mode of the controller is set by setting the IB pins high or low. I would investigate modifying the circuit if I were you. I couldn't advise you directly what to do because the pictures do not show what I would need to see, but first find if the IB pins are brought out somewhere so that you can change them to SPI mode, then look to see if the SCLK, DI, and DO lines are brought out somewhere (probably share a DB pin) Then connect them all together for a single SPI bus, and use the CS lines to pick which devices you are communicating with. 6 lines total would give you access to an SD card, LCD, and touchscreen.

Otherwise, you are not going to have enough IO on the Uno to control that screen. Well, at least not without using latches.
833  Using Arduino / Project Guidance / Re: Challenge: horizontally / inertially stabilize a pizza on motorcycle on: February 04, 2013, 03:00:24 pm
I guess I am also one of those people that doesn't believe that a microcontroller is the solution for everything. Add me in for the gimball. A well balanced, bearinged and weighted gimball will react a million times faster than any closed loop micro/motor/sensor could ever respond.
834  Using Arduino / Project Guidance / Controlling an animatronics bust on: February 04, 2013, 02:39:14 pm
I am currently developing a custom board to control a wowwee alive Animatronic Elvis bust. I will likely have many questions along the way, so I figured that I would define the scope of it here for reference (and suggestions.)

The input to the controller is Mini-SSC II compatible commands. This is a popular Serial Servo Controller. The command structure is very simple, for each command, there are three bytes <Sync = 0xFF> <Chan (0 to 254)> <Pos (0 to 254)>.

The output of the controller is 10 DC motors which control:
1. Eyes UD
2. Eyes LR
3. Eyebrows UD
4. Right Eyelid UD
5. Left Eyelid UD
6. Lip UD (signature Elvis lip curl)
7. Jaw UD
8. Head LR
9.Neck swing LR (tilt)
10. Neck swing UD (nod)

Controlling these all is not directly straightforward.

7 of the motors inside the head postion (face motors) are tracked by potentiometers. Within the head is an ADC chip (SNAD01).
1 motor (Head LR.. rotate like "no") has a potentiometer, but it is not connected to the ADC within the head.
The final 2 motors for Tilt and Nod of the neck are linear actuators which incorporate optical encoder wheels and limit switches. The encoders are not quadrature, so there is no absolute position or direction information. They are like a tachometer.

The encoder wheels are connected at the point of the motor shaft. 4 slots in it (so, 4 pulses per revolution of the motor). The gear box is a 10:1 ratio, meaning it takes 10 rotations of the motor to move the final output shaft 1 revolution. The output shaft is connected to a lead-screw which converts the rotation into linear movement. For 1 revolution of the output shaft, there is 5mm of linear travel. If you do the math, you learn that 8 pulses from the encoder wheel equals 1mm of linear travel.

One linear actuator has a full travel of 64mm (tilt), and the other 32mm (nod). There are 4 limit switches located at the extremes of movements.

Controlling the other 8 motors is pretty straightfoward since they have potentiometers and we have absolute position from them. The only complexity there is communicating with the built-in ADC for 7 of the motors. That ADC is a Sonix SNAD01. I have already written a library for this for use with the Arduino. The 8th motor will just use an internal ADC channel of the AVR.

So, back to the linear actuators. I have devised some code to accurately track the position of the linear actuators using interrupts from the encoder wheel.

Overall the project will find it's final destination in an ATMEGA32 which has exactly enough I/O while coming in a DIP package. However, for ease of prototyping, I am using an Arduino (Uno and 2560.)

So far I have the Mini-SSC II serial parsing coded, the linear actuator code tracking position, and a driver library for the SNAD01 ADC. Now I need to piece it all together.

Here's how I think it will work:

The main loop will watch for new serial commands, and upon receiving one, it will send the chan and pos to a Move() function which will determine direction, magnatude of change, and control the motors.
An updatepos position will manage the various methods of gaining the current position of each servo.
A timer will run at 50Hz, which will refresh the motors with the last position given to ensure that they stay in position

Now what I am trying to wrap my head around is the overall code, the big picture, if you will. I think that it makes sense to simply create an array of each motors position, and when a new command comes in, it will put that new position in the array which will be fixed at the next update() call. All movements must be completed in 20ms. Does this make sense, or does it make more sense to start moving the motor immediately upon a new command and just leave the update() function to maintain?

Ultimately, I think this code will have much use beyond just this application and because of that, it is my intent to make it as modular as I possibly can. It could be used for any number of applications in which we need to gain servo control over a number of motors using the popular serial servo control interface.

I am not really 'new' to this, but I am not a great programmer. Hardware has always been my specialty. Typically my code is never 'clean' and often is buggy. What I would really like is some support and guidance (not hand-holding) in this project. I fully intend to put this code into the public domain for anyone to use, abuse, or otherwise.

Finally, my next project after this is a Wowwe Alive! animatronic chimp head. For that, I will be creating my own H-bridge and ADC board. I will also make that hardware (schematics, etc..) available for anyone to use for their projects. Since that will just use pots for every motor, there is actually a nice motor control shield and code that will be useful in just about any project.

Expansion of the code (if it becomes universally modular) would include closed loop control, open loop control, encoders (quadrature and tacho), potentiometers, gray-code encoders, etc... It would be the ultimate motor library.

So is anyone interested in helping?
835  Using Arduino / Motors, Mechanics, and Power / Re: converting astable multivibrator for DC motor on: February 04, 2013, 01:12:38 pm
I'll preface this with the disclaimer that I hate when people suggest changing my design instead of answering directly, but in the case of a bell, have you considered a mechanical oscillation method? Then you only need to move the motor in a single direction. Very, very simple.

An oscillation could be provided by a cam or a crank.
836  Using Arduino / Motors, Mechanics, and Power / Re: Controlling position of linear actuator on: February 04, 2013, 11:13:27 am
Here is the code to move to an absolute position:

void MoveLR(int pos){

if (pos == CURRPOS[8]){

else if (pos > CURRPOS[8]) {

      while (pos != [CURRPOS[8]){





else if (pos < CURRPOS[8]) {

      while (pos != CURRPOS[8]) {






This works, but it's ugly. I am basically calling a step function which turns on the motors, delays, then stops to check the encoder pos again. And repeats until pos == currpos. It triggers on the position match, but of course the motor overshoots by quite a bit. some overshoot is ok, but we are talking actually stopping at position 16 when it is suppose to be 32 for example.

The larger project will not really have enough PWM to control all of the motors (10 motors total, but 8 of them use potentiometers for feedback), and the original controller didn't seem to use PWM either.

So, I am trying to figure out how to control the position cleanly without using PWM. Is this possible? Hopefully I included enough information. If not, just ask. If I can get something steady, I will be posting it up for posterity for others to use in similar situations. I know motor control is one of the most commonly asked questions.

I have only a little control over the design itself because I am modifying existing hardware and want to keep it as stock as possible, so simply using a servo is not an option. In fact, the end application here is to turn all of the motors into servos and provide a 10 servo serial servo controller interface to the end-user (compatible to Mini-SSC II.) Again, all code will be released to the public when completed.
837  Using Arduino / Motors, Mechanics, and Power / Controlling position of linear actuator on: February 04, 2013, 10:55:36 am
Hi all,

I am working on an animatronics project and need to control two linear actuators. The linear actuators are DC Motors connected to a gearbox and output through a leadscrew. On the shaft of the motor is an encoder wheel. Unfortunately, it is not quadrature. Only a single channel. 4 openings on the disk. Through extensive testing and experimenting, I have found the gear ratio is 1:10.

There are 4 pulses per revolution of the DC motor, 40 pulses = 1 turn of the output shaft. That translates into 5mm of linear travel. So, I am settling on 1mm resolution of control (8 pulses).

At the extremes of movement are limit switches which go low when activated. Again, the encoder is only a single channel (basically a tachometer) so I cannot derive direction or absolute position from it.

So, I have devised a plan to track the position using the limit switches and pulses using interrupts:

void CountLR(){
 //Rightmost position = 64
 //Leftmost position = 0
 // 8 pulses per 1mm of travel. Count every 8 pulses for 64 positions
if (RevLR == 8){
     RevLR=0;  //if pulses = 8, resent revolution counter
 //if moving Left to Right, increase position
  if (Dir == LU && digitalRead(L_LIM) == 1){
   }//Else if moving Right to Left, count down
  else  if (DirLR ==RD && digitalRead(R_LIM) == 1){

  if(digitalRead(R_LIM) == 0){
   if(digitalRead(L_LIM) == 0){

This snippet is activated by the interrupt on an encoder count. I have it ignoring counting until it has been triggered 8 times. Depending on the direction variable which is kept track of in code, it will count up or down. If it hits a limit switch, it will reset the min and max count to a fixed number. This is needed because the count is not always exactly the same (off only by a few.) So I constrain it to 0 to 64.

I have written code to move to a position. I will paste what I have in the next post.
838  Using Arduino / Programming Questions / Re: Trying to write a library on: January 24, 2013, 06:24:08 pm
Thanks Pyro! I will clean it up in the final version.
839  Using Arduino / Programming Questions / Re: Trying to write a library on: January 24, 2013, 06:16:01 pm
Hmm.... great point! Every library I have looked at so far did it this way, so I assumed that it was to avoid some naming collision with other code. So, this will not happen?
840  Using Arduino / Programming Questions / Re: Trying to write a library on: January 24, 2013, 05:39:34 pm
wow.... I must have looked at that 100 times. smiley-sad

Now I feel stupid. Grr!! Stupid fonts. lol
Pages: 1 ... 54 55 [56] 57