Go to Post Sleep?! How am I supposed to do that with the build season done?! There are still practice bots to make! - [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Spotlight this post!  
Unread 23-01-2008, 14:59
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 590
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: Synchronizing with 26.2 ms communication

Quote:
Originally Posted by Alan Anderson View Post
I'm having difficulty trying to tune a velocity PID loop, and I've come to the conclusion that part of my problem is that the PWM outputs aren't changing at a predictable time relative to the PID sample time. They're not even changing at the same rate.

Is there a way to detect when the User and Master CPUs have exchanged their information? Or does EasyC even use the same "every 26.2 ms" scheme that the IFI default code has? So much is hidden behind the scenes and I don't know how to peek behind the curtain.

EasyC is easy for simple stuff, but I'm apparently fighting it when I want to try more advanced coding. I can't believe that I have to jump through so many hoops to do things that aren't predefined, and I have to think I'm just failing to see the "right" way.
Alan -

There are a few ways of solving the problem. There are 6 predefined timers that you can read that update automatically. Actually, they run off the same timer interrupt - a 1ms clock. So if it works out, you can only do integrating when the timers reach, for example, a 20ms multiple. You can also request periodic timer interrupts where easyC (WPILib) will call a function of yours with interrupts disabled at each interval. This has all the usual ISR writing caveats.

You can also find out when data exachanges between the master and user processor by looking at the packet number and waiting for a change. This is done by calling:

unsigned char GetPacketNumber(void);

This function gets the incrementing sequence number that changes every 26ms. In your own loop, you can notice the packet number change, and take whatever actions you need to. This is probably better to keep the PWM updates and your calculations in sync.

Do one of these work for you? If not let me know and maybe something could be added.
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help With Maplab C programming on serial communication loveheb3 Programming 0 04-06-2007 21:24
Labview and communication with peripheral device help jaijaidin LabView and Data Acquisition 3 26-01-2007 19:17
Serial Communication Problems with LabVIEW FRC Toolkit Jon236 LabView and Data Acquisition 1 28-12-2006 11:57
Methods of communication???? aviv Chairman's Award 3 18-02-2006 20:10
organized way of communication with FIRST? archiver 2001 0 24-06-2002 04:20


All times are GMT -5. The time now is 23:10.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi