Go to Post Regardless on how you feel about any team--respect should be paramount. - MeGuttieri [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

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 14-12-2011, 17:36
Stonemotmot Stonemotmot is offline
Registered User
FRC #0486
 
Join Date: Sep 2011
Location: United States, Pa
Posts: 53
Stonemotmot is an unknown quantity at this point
Target Exception Error from Solenoid Array

Hello, I have recently been looking into making my solenoids operate
based off an Array. I get no build Errors or warnings. However when i
run it i get a Target Exception Error.
VxWorks6x_10.4.86: Exception in Kernal Task FRC_RobotTask:0x1e37368
at pc=0x1DE93B0 in RobotDemo::OperationControl()
at (Address of main.cpp)

Vector 0x300 : Data Access addr=0xEEEEEEE status=0xDC1630

The Code that matters

bool states [4] = {false,false,false,false}
bool prestates [4] = {false,false,false,false}
bool inoutbut [4] = {false,false,false,false}

class RobotDemo : public SimpleRobot
{
Solenoid* solenoids[5];
}
// more stuff inbetween

void OperatorControl(void)
{
solenoids[1] = new Solenoid(1);
solenoids[2] = new Solenoid(2);

while (IsOperatorControl)
{
for(int b=1; b<5; b++)
{
inoutbut[b] = stick.GetRawButton(b) // the stick is correctly defined

if(inoutbut[b] == true)
{
g=b;
states[g]= !prestates[g];
solenoid [g]->Set(states[g]) // the debugger shows this as wrong
prestates[g] = !prestates [g];
}
}
}
  #2   Spotlight this post!  
Unread 14-12-2011, 18:25
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,586
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Target Exception Error from Solenoid Array

One obvious problem is that you only create 2 solenoid objects, but call set on 4 of them.
  #3   Spotlight this post!  
Unread 14-12-2011, 18:42
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: Target Exception Error from Solenoid Array

I see a few problems:

-You lack a semicolon on the line that is bad; C generally prefers semicolons (although I suspect you did not copy-paste the code, but rather re-typed it)

-You are assigning 4 buttons to toggle the state of 4 pistons when pressed (yes?), however, it appears as though the If will run every cycle that the button is pressed (constantly inverting/setting the piston while the button is held), you would need a check to see if the button is pressed but wasn't last iteration.

-Is there any need for states and prestates? Couldn't you just say
Code:
state[b] = !state[b]; solenoid[b]->set(state[b]);
and get the same result?

-What are you doing where you need an array of solenoids? In embedded programming such as FRC robots, I've always hated working with arrays of objects, as most objects we use have a specific purpose and are handled in different ways (depending on the subsystem they operate under, for example), and usually robots are simple enough where having a few references isn't a bad or messy thing.
__________________
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
  #4   Spotlight this post!  
Unread 15-12-2011, 13:09
Stonemotmot Stonemotmot is offline
Registered User
FRC #0486
 
Join Date: Sep 2011
Location: United States, Pa
Posts: 53
Stonemotmot is an unknown quantity at this point
Re: Target Exception Error from Solenoid Array

Thanks for the feed back. As for semi-colons yes i retyped it not copy and paste. I will try to declare the rest of the array and see if that works. The only reson i am attempting to do this is as a test of concept not because it is an essential part of the code.
  #5   Spotlight this post!  
Unread 15-12-2011, 13:26
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,854
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Target Exception Error from Solenoid Array

Your indexing into the array is 1 to 4, rather than 0 to 3
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #6   Spotlight this post!  
Unread 16-12-2011, 14:30
Stonemotmot Stonemotmot is offline
Registered User
FRC #0486
 
Join Date: Sep 2011
Location: United States, Pa
Posts: 53
Stonemotmot is an unknown quantity at this point
Re: Target Exception Error from Solenoid Array

I figuered it out thanks for all the help. It was the indexing (0-3) and the incomplete slots in the array
Closed Thread


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


All times are GMT -5. The time now is 18:48.

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