View unanswered posts | View active topics It is currently Sun May 01, 2016 12:17 pm

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
sinusoid code?
Author Message
Rookie

Joined: Wed Apr 21, 2010 3:26 pm
Posts: 1
sinusoid code?
Hi all,
I'm new to robotics and C. I'm trying to drive my vex servo sinusoidally with the pic18F8520 vex microcontroller - from what i've seen so far online and in the help topics, it doesn't look like there is a function for this in robotC for ifi, but i thought i'd post to the forum and see if anyone had any experience or advice on how to write code which would drive the servo in a sine function, or just vary velocity over time smoothly. Any advice would be appreciated, thanks!

Wed Apr 21, 2010 3:39 pm
Rookie

Joined: Sat Nov 22, 2008 8:06 pm
Posts: 48
Re: sinusoid code?
It can be done, but it would be manually. If it didn't have to be sinusoidal and you just wanted it smooth, you could just average the old and new motor speed values. I would suggest about 3 to 1 average, old value to new, such that you would have code like this.

 Code:motor[leftMotor] = (int)(3*oldMVal+motorVal)/4;oldMval = (int)(3*oldMVal+motorVal)/4;

oldMVal would and motorVal would just be standard character variables. You would change motorVal in your code to run the motor smoothly. I think the (int)s would be required to keep the values from overflowing.

Anyhow, this would do it, with just a short pause between loops. Maybe like 50 milliseconds. More if you want it even smoother.

If you really want perfect sinusoidal control, well, RobotC does have some built in trig commands.

Thu Apr 22, 2010 12:34 am

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Re: sinusoid code?
Using trig functions might use unnecessary amounts of processing time. Does it really need to be sinusoidal or does it just need to be smooth? I would go with Bluesaberist's solution. Remember, K.I.S.S.

Regards,
Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]

Thu Apr 22, 2010 1:36 am
Display posts from previous:  Sort by
 Page 1 of 1 [ 3 posts ]

#### Who is online

Users browsing this forum: No registered users and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning