loading
 
Sparkfun-Arduino servo control not working
David Covarrubias from United States  [3 posts]
10 year
Hi I just downloaded roborealm and am having trouble interfacing to an arduino board.

I simply want to start by getting the red ball tracker working with an arduino UNO.

I uploaded the Sparkfun-Arduino sketch into my uno and replaced the parallax control module with the Sparkfun arduino one.

I am not getting any servo control when I click on te sparkfun arduino module and set up pin 3 to be controlled by COG X or MouseX (or anything else)
My servo is connected to pwm digital pin 3 and gnd and 5v... its a tiny test servo so its not an issue to power it directly from the UNO.
I can see Rx led is flickering so data seems to be flowing...

Also what is the Serial sketch for?  Is it just meant to be a stripped down version of the Sparkfun one so that its not specifically set to control all servos???

If you can help me out id appreciated.  Not enough Youtube tutorials out there ye to help me resolve this without he forums help:(

I noticed there is also a Serial UNO sketch
Steven Gentner from United States  [1446 posts] 10 year
David,

The best way is to try to simplify the process.

Remove everything from RR except for the Sparkfun_Arduino module. Get that on the right COM port and use the mouse to toggle one of the digital pins and check with a voltmeter that the power changes when clicking on the on/off of a digital pin.

What we want to do is isolate that this is a hardware versus software issue.

Be sure that the module is also connected and not complaining in any way. This should ensure that the uploaded sketch is actually the correct one.

STeven.
David Covarrubias from United States  [3 posts] 10 year
Ok I think I figured it out....
looks like the Red Object tracking module sends out servo position data that is in the 0-180 range (degrees), but the sketch for Sparkfun arduino is looking for servo positions in microseconds (500-2500 or so) so all of the data was being read but it was below the servos working range in microseconds.

Does that make sense???

I ended up doing a quick test by changing the VBScript
from:
SetVariable "SERVO_VALUE", Cint((GetVariable("COG_X") * 255)/GetVariable("IMAGE_WIDTH"))

to:
SetVariable "SERVO_VALUE", Cint((GetVariable("COG_X") * 2055)/GetVariable("IMAGE_WIDTH"))

And got the servo moving...  the exact equation for the VBScript needs adjusting but that arbitrary number showed me that the problem is there...
Steven Gentner from United States  [1446 posts] 10 year
Almost, the Red Object tracking will send out 0 to however wide the image is in pixels ... so if your camera happens to be 180 pixels wide, that will be the range. You were on track through, it has to do with variable scaling. You may try the Scale_Variable module which will do the above calculation but allow for easier adjustment. The module was created after the example which is why it is not included in that example.

http://www.roborealm.com/help/Scale_Variable.php

STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index