Go to Post Or you could go to the Waterloo or Greater Toronto regional, walk up to anyone in their pit, and ask. You may end up feeling like you asked for a sip of water and ended up soaked by a fire hose, but you won't walk away disappointed. - Richard Wallace [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 01-04-2010, 22:04
apalrd's Avatar
apalrd apalrd is offline
More Torque!
AKA: Andrew Palardy (Most people call me Palardy)
VRC #3333
Team Role: College Student
 
Join Date: Mar 2009
Rookie Year: 2009
Location: Auburn Hills, MI
Posts: 1,347
apalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond repute
Possibility of Controller Overload using Compressor

Hello. If you have had any of the problems I have had, you probably keep a scribe close to hit the No App switch every time you download. Looking deep into the WPI library for possible causes of CPU overload, I found this.

The Compressor library opens a new thread to handle compressor updates. Kinda a weird thing to do, since it could just poll the compressor during every loop of Teleop or something, but it does. It uses FIFO to transfer enabled state between the main thread and the Compressor thread. The compressor thread has no delays - an infinite loop that reads the FIFO, reads the switch, and sets the relay. I don't know much about how FIFO operates, but I assume it dosen't take long to read the FIFO. I do know it dosen't take long to read a switch or set a relay. Thus, it is quite possible that all extra CPU power is dedicated to running the compressor as fast as possible, so it would be really really hard to tell if optimizations work, as the processor is always around 95% since the compressor is always eating the extra.

The solution is simple. I added a 100ms delay to the Compressor loop. After doing this, the CPU load on my cRio went from 96% to 56%. Drastic improvement. I can't certainly say it was this compressor, as I was trying desperately to get the drive lag to go away.
__________________
Kettering University - Computer Engineering
Kettering Motorsports
Williams International - Commercial Engines - Controls and Accessories
FRC 33 - The Killer Bees - 2009-2012 Student, 2013-2014 Advisor
VEX IQ 3333 - The Bumble Bees - 2014+ Mentor

"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." ~ John Carmack
Reply With Quote
  #2   Spotlight this post!  
Unread 01-04-2010, 22:46
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Possibility of Controller Overload using Compressor

The compressor implementation should be fine if you start and stop the compressor only when needed. The code in question is Starting for every auto and every tele and every disabled packet, the compressor was already Started in Begin and never Stopped.

You can modify anything you like, but I'd recommend calling Start only in Begin.

As for the implementation, the Compressor was done as a background VI which loops waiting on a low-jitter queue called the RT FIFO. This enables other code to send commands to the compressor whenever you like, kinda like a fancy global. The RT FIFO read has a 500ms timeout so if no commands are sent, it will poll the compressor at 2Hz.

Greg McKaskle
Reply With Quote
  #3   Spotlight this post!  
Unread 01-04-2010, 22:58
apalrd's Avatar
apalrd apalrd is offline
More Torque!
AKA: Andrew Palardy (Most people call me Palardy)
VRC #3333
Team Role: College Student
 
Join Date: Mar 2009
Rookie Year: 2009
Location: Auburn Hills, MI
Posts: 1,347
apalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond repute
Re: Possibility of Controller Overload using Compressor

The reason I added the calls in Teleop was because the single call in Begin wasn't enabling the compressor. I tried calling it once, and it just didn't enable. So then I called it in the loop. And it worked. So I left it.

Code:
relay8_fwd = !rc_dig_in18;
This is what IFI had for their compressor. WPI has:
Compressor->Open, which opens two RT-FIFO's and a Digital Input and a Relay, then begins asynchronous execution of a thread dedicated to polling the compressor.
Comrpessor->Run (thread) - polls compressor as fast as possible, assuming no delays from RT-FIFO (greg claims it does wait for new data).
Compressor->Start - sets RT-FIFO to enabled
Compressor->Stop - sets RT-FIFO to disabled
Compressor->Enabled - gets RT-FIFO for enabled and switch state
Compressor->Close - Closes RT-FIFO. The Run thread closes itself when RT-FIFO spits an error out (assuming that the RT-FIFO was closed).
All the complexity to take the place of that one line of code.
__________________
Kettering University - Computer Engineering
Kettering Motorsports
Williams International - Commercial Engines - Controls and Accessories
FRC 33 - The Killer Bees - 2009-2012 Student, 2013-2014 Advisor
VEX IQ 3333 - The Bumble Bees - 2014+ Mentor

"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." ~ John Carmack
Reply With Quote
  #4   Spotlight this post!  
Unread 01-04-2010, 23:12
Vikesrock's Avatar
Vikesrock Vikesrock is offline
Team 2175 Founder
AKA: Kevin O'Connor
no team
Team Role: Engineer
 
Join Date: Mar 2006
Rookie Year: 2007
Location: Manchester, NH
Posts: 3,305
Vikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond repute
Send a message via AIM to Vikesrock Send a message via MSN to Vikesrock Send a message via Yahoo to Vikesrock
Re: Possibility of Controller Overload using Compressor

Quote:
Originally Posted by apalrd View Post
All the complexity to take the place of that one line of code.
There is nothing stopping you from directly setting the relay to the opposite value of the pressure switch if you have a problem with the way WPIlib implements the compressor.

<R78> describes the only requirement your system must meet.
__________________


2007 Wisconsin Regional Highest Rookie Seed & Regional Finalists (Thanks 930 & 2039)
2008 MN Regional Semifinalists (Thanks 2472 & 1756)
2009 Northstar Regional Semifinalists (Thanks 171 & 525)
Reply With Quote
  #5   Spotlight this post!  
Unread 01-04-2010, 23:27
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Possibility of Controller Overload using Compressor

I'm not sure what we are discussing here. The compressor runs an independent VI, but VIs do not own a thread. The behavior, if not constantly told to start, is that twice a second the loop will run. If enabled, it will test the switch and update the relay.

This could be coded in many ways. You can put the code to test in teleop, but what if you want it in auto. You'll also be checking the relay 50 times per second when the pressure cannot really change that much in 20ms. WPILib implementation allows control over multiple compressors and makes state data for each instance so that you can Start, Stop, and Check the state at various places in your app. In other words, the parallel loop seems like a reasonable way to do this. It could be simpler, but it isn't particularly complex either.

As for the behavior of RT FIFOs, feel free to read the help, experiment, or ask others.

Greg McKaskle
Reply With Quote
  #6   Spotlight this post!  
Unread 01-04-2010, 23:31
Vikesrock's Avatar
Vikesrock Vikesrock is offline
Team 2175 Founder
AKA: Kevin O'Connor
no team
Team Role: Engineer
 
Join Date: Mar 2006
Rookie Year: 2007
Location: Manchester, NH
Posts: 3,305
Vikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond repute
Send a message via AIM to Vikesrock Send a message via MSN to Vikesrock Send a message via Yahoo to Vikesrock
Re: Possibility of Controller Overload using Compressor

Quote:
Originally Posted by Greg McKaskle View Post
I'm not sure what we are discussing here.

In other words, the parallel loop seems like a reasonable way to do this. It could be simpler, but it isn't particularly complex either.

As for the behavior of RT FIFOs, feel free to read the help, experiment, or ask others.

Greg McKaskle
To be honest, me either Greg.

I was simply suggesting that the OP is free to do the control himself if he doesn't like the way WPIlib does it for whatever reason.

We have no problems with the standard WPIlib compressor setup (Compressor Open and Start in begin) and I find it to be extremely simple. Reading the state to pack it into Dashboard data was also very straightforward and simple.
__________________


2007 Wisconsin Regional Highest Rookie Seed & Regional Finalists (Thanks 930 & 2039)
2008 MN Regional Semifinalists (Thanks 2472 & 1756)
2009 Northstar Regional Semifinalists (Thanks 171 & 525)
Reply With Quote
Reply


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
Using x-box 360 controller sparks-1784 Programming 13 23-03-2010 20:17
Using a TI-83+ or TI-84+ as an auxilary controller Hydr0g3n Programming 14 30-08-2006 19:34
Current reversed on compressor spike controller scottish144 General Forum 20 05-09-2005 07:33
using a ps2 controller Thunderhawk1038 Control System 6 26-02-2005 17:15
Using Accelerometer with '04 controller sanddrag Control System 4 20-02-2004 12:18


All times are GMT -5. The time now is 22:01.

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