View Single Post
  #7   Spotlight this post!  
Unread 14-07-2013, 15:49
Mike Bortfeldt Mike Bortfeldt is offline
Registered User
FRC #1126 (& 1511)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Rochester, NY
Posts: 119
Mike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud of
Re: Arduino Mecanum drive using PWM?

cad321,

A couple of observations regarding the I/O. The pulseIn code (source) looks like it will return a zero (0) when it does not find the pulse within the timeout period. You may want to put in some code to check for this, otherwise your outputs may not be what you would like. Also, be aware that your "loop" execution time will be variable depending on how long it takes to obtain the three pulse values and output to your four servos. Assuming a standard 20 millisecond interval for the incoming servo PWM value, you will probably have a range between 8 to 65 milliseconds. This may not be a problem.

My knowledge of the hardware you are using is limited, but You may also want to review your mixing algorithm as well. Again, assuming a standard servo input (1-2 ms pulse), the pulseIn should return values between 1000 and 2000 (usec). Adding all three together for FL (for example) would yield 3000 to 6000, or basically your maximum all the time. This could be correct if the inputs are not what I assumed, but it doesn't look right for a standard servo input/output signal. My guess, based on your original post of the 1 second delays, indicate that you are probably not reading at least two of the signals (Strafe & Rotate perhaps?), so you are adding zero (0) to your forward value and the calculations are doing what you expect. The 1 second delay is approximately the timeout for the default pulseIn when it doesn't see a pulse and no explicit timeout is passed.

Mike