Go to Post I've been inspired for real engineering during the build season and on the playing field, but the inspiration I found in the pits is often for creative thinking and intuition. - artdutra04 [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 08-12-2004, 10:01
stephenthe1 stephenthe1 is offline
Registered User
#1008
 
Join Date: Dec 2004
Location: Ohio
Posts: 113
stephenthe1 is on a distinguished road
c debugger

I heard that there's a c debugger floating around. Because mplab, atleast as far as I can see, is pretty much useless for debugging. I guess there are two versions of it and the second one's very useful for telling errors in the code. where is this at? is it the same as the eic command thing?
  #2   Spotlight this post!  
Unread 08-12-2004, 12:41
krhs_programmer's Avatar
krhs_programmer krhs_programmer is offline
Programmer, Engineer, exDriver
#1247 (R.O.K.S.)
Team Role: Programmer
 
Join Date: Dec 2004
Rookie Year: 2003
Location: Sutton, NH
Posts: 23
krhs_programmer is an unknown quantity at this point
Re: c debugger

yeah were is this debugger i would really like it because i have come to hate mplab in the week that i have used it so far.
  #3   Spotlight this post!  
Unread 08-12-2004, 20:57
Mike's Avatar
Mike Mike is offline
has common ground with Matt Krass
AKA: Mike Sorrenti
FRC #0237 (Sie-H2O-Bots (See-Hoe-Bots) [T.R.I.B.E.])
Team Role: Programmer
 
Join Date: Dec 2004
Rookie Year: 2004
Location: Watertown, CT
Posts: 1,003
Mike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond repute
Re: c debugger

There's a program that debugs your program for you? =O

I seriously did not know that, once you program a lot your eye is trained too look for certain things. One tip of mine is to actually say things phonetically
EG
pwm01 = 255;

Would become

pee double u emm zero one equals two five five semicolon

It helps you notice missing semicolons, end quotes, etc.
__________________
http://www.mikesorrenti.com/
  #4   Spotlight this post!  
Unread 08-12-2004, 23:07
Dave Flowerday Dave Flowerday is offline
Software Engineer
VRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 1995
Location: North Barrington, IL
Posts: 1,366
Dave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond repute
Re: c debugger

Quote:
Originally Posted by MikeWasHere05
There's a program that debugs your program for you? =O
Mike,
In the software world, a "debugger" is a tool that helps you find bugs in your code. It does not find them for you*, unfortunately! Typically it allows you to step through the code line by line, look at the contents of variables, change memory on the fly, etc. Instead of the program running at full speed, you can see what each line does to variables and which "if" statements are evaluated to TRUE and which are FALSE, etc. In jobs like mine where we write very low level embedded software (device drivers, etc) a good debugger is a necessity.

Unfortunately, I'm not aware of a debugger that can be used with the IFI system, which is really a shame. In order to debug, teams are forced to use printf()s inside their code instead, which many seasoned programmers consider a fairly primitive way of debugging (though some swear by it). However, Rob Bayer has created a Robot Controller Simulator which can serve a very similar purpose as a debugger and will likely be useful for testing code for a lot of teams this year.

* Side note: there are a few tools out there which can find some types of bugs for you automatically. One that comes to mind that I used in college is called Purify, and it can tell you if your program ever uses uninitialized memory, fails to free memory, walks off the end of an array, etc. Very useful, of course, but it doesn't come anywhere close to finding all the types of bugs that can creep into a project.
  #5   Spotlight this post!  
Unread 09-12-2004, 00:39
Rickertsen2 Rickertsen2 is offline
Umm Errr...
None #1139 (Chamblee Gear Grinders)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2002
Location: ATL
Posts: 1,421
Rickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant future
Send a message via AIM to Rickertsen2 Send a message via Yahoo to Rickertsen2
Re: c debugger

Quote:
Originally Posted by Dave Flowerday
Mike,
In the software world, a "debugger" is a tool that helps you find bugs in your code. It does not find them for you*, unfortunately! Typically it allows you to step through the code line by line, look at the contents of variables, change memory on the fly, etc. Instead of the program running at full speed, you can see what each line does to variables and which "if" statements are evaluated to TRUE and which are FALSE, etc. In jobs like mine where we write very low level embedded software (device drivers, etc) a good debugger is a necessity.

Unfortunately, I'm not aware of a debugger that can be used with the IFI system, which is really a shame. In order to debug, teams are forced to use printf()s inside their code instead, which many seasoned programmers consider a fairly primitive way of debugging (though some swear by it). However, Rob Bayer has created a Robot Controller Simulator which can serve a very similar purpose as a debugger and will likely be useful for testing code for a lot of teams this year.

* Side note: there are a few tools out there which can find some types of bugs for you automatically. One that comes to mind that I used in college is called Purify, and it can tell you if your program ever uses uninitialized memory, fails to free memory, walks off the end of an array, etc. Very useful, of course, but it doesn't come anywhere close to finding all the types of bugs that can creep into a project.
It is pic based and therefore has native ICD(in circuit debugging) capabilities and they integrate with MPLAB. Unfortunately you need to buy a tool, and open up the RC just to hook the tool up.
__________________
1139 Alumni
  #6   Spotlight this post!  
Unread 09-12-2004, 00:50
Dave Flowerday Dave Flowerday is offline
Software Engineer
VRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 1995
Location: North Barrington, IL
Posts: 1,366
Dave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond repute
Re: c debugger

Quote:
Originally Posted by Rickertsen2
It is pic based and therefore has native ICD(in circuit debugging) capabilities and they integrate with MPLAB. Unfortunately you need to buy a tool, and open up the RC just to hook the tool up.
Hence why I said that there is not a debugger that can be used with the IFI system that I know of. And perhaps more importantly, if the user processor does not send data to the master processor in a timely manner, the master processor will reset the user processor. So even if you could hook up the debugger, you'd still have to worry about the user processor getting reset each time you stopped at a breakpoint.
  #7   Spotlight this post!  
Unread 09-12-2004, 09:24
stephenthe1 stephenthe1 is offline
Registered User
#1008
 
Join Date: Dec 2004
Location: Ohio
Posts: 113
stephenthe1 is on a distinguished road
Re: c debugger

this is quite rediculous. first should atleast have microchip create a simple debugger. even one that simply checked for spelling errors (ex. c is case sensitive) and find missing semicolons and brackets. it shouldn't be that hard for them to also make it check potential values for variables to see if the value would be out of the variable's bounds. First needs to "modern-up" a little. I mean, have you seen visual studio 2003 or 2005? It needn't be as complex as visual studio, just have some of the same features. regular c isn't nearly as complicated for the purpose of programming the robots.

Last edited by stephenthe1 : 09-12-2004 at 09:27.
  #8   Spotlight this post!  
Unread 09-12-2004, 09:44
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: c debugger

Quote:
Originally Posted by stephenthe1
this is quite rediculous. first should atleast have microchip create a simple debugger. even one that simply checked for spelling errors (ex. c is case sensitive) and find missing semicolons and brackets. it shouldn't be that hard for them to also make it check potential values for variables to see if the value would be out of the variable's bounds. First needs to "modern-up" a little. I mean, have you seen visual studio 2003 or 2005? It needn't be as complex as visual studio, just have some of the same features. regular c isn't nearly as complicated for the purpose of programming the robots.
Steve,

Just hold on a second... Have you even tried MPLAB? It already does everything you outline except for potential variable values (and it even does a bit of that).

It will even run your code in simulation with full watch variable and breakpoints. Do a search in last years fori and you will find a few discussions on the subject.

What you guys were originally talking about was what is called an in-circuit-emulator. That is what Dave was referring to when he said you would have to get access to the chip.

Regards,
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
  #9   Spotlight this post!  
Unread 09-12-2004, 09:51
stephenthe1 stephenthe1 is offline
Registered User
#1008
 
Join Date: Dec 2004
Location: Ohio
Posts: 113
stephenthe1 is on a distinguished road
Smile Re: c debugger

Quote:
Originally Posted by Mike Betts
Steve,

Just hold on a second... Have you even tried MPLAB? It already does everything you outline except for potential variable values (and it even does a bit of that).

It will even run your code in simulation with full watch variable and breakpoints. Do a search in last years fori and you will find a few discussions on the subject.

What you guys were originally talking about was what is called an in-circuit-emulator. That is what Dave was referring to when he said you would have to get access to the chip.

Regards,
lol, thanks. I did get a little carried away.
  #10   Spotlight this post!  
Unread 09-12-2004, 09:54
stephenthe1 stephenthe1 is offline
Registered User
#1008
 
Join Date: Dec 2004
Location: Ohio
Posts: 113
stephenthe1 is on a distinguished road
Re: c debugger

um, would this code cause two pistons to fire assuming they are hooked up to relay 1 and relay2. also, you'll notice in my if statements that I used if its 1, then to execute the stuff, is that the right way of asking if the switch is one, or should I do (p2_sw_trig01), I've seen that but didn't know what it meant. what's the correct way? thanks.

Code:
 if (p1_sw_trig = 1) {
  relay1_fwd = 1;
  relay1_rev = 0;
  relay2_fwd = 1;
  relay2_rev = 0;
}
  if (p1_sw_trig = 0) {
 relay1_fwd = 0;
 relay1_rev = 0;
 relay2_fwd = 0;
 relay2_rev = 0;
}
  if (p2_sw_trig = 1) {
  relay1_fwd = 0;
  relay1_rev = 1;
  relay2_fwd = 0;
  relay2_rev = 1;
}
  if (p2_sw_trig = 0) {
 relay1_fwd = 0;
 relay1_rev = 0;
 relay2_fwd = 0;
 relay2_rev = 0;
}
  #11   Spotlight this post!  
Unread 09-12-2004, 10:22
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: c debugger

Continued...

I was going to let my last post stand but this is still sticking in my craw...

First, you are comparing a desktop software package which sells several millions of copies (hence revenues) against an embedded processor software package which sells several thousands (they make their profit in chip sales).

Add to that the fact that Mr. Gates and company make a product which is no longer ANSI compatible (therefore code is not portable).

An embedded processor software package is targeted at degreed engineers who program for a living. An embedded program is usually very small and compact, no megabytes wasted in useless hooks to windows... The embedded programmer's task is to make his code as small and efficient as possible.

The smaller and more efficient the code, the less chance of bugs to begin with. We usually don't need (or want) a lot of fluff...

The design cycle is usually to build a prototype development platform which accepts ICE and also has extra debugging aids added by the engineer. You only build a couple of these. After you have developed your code and debugged your hardware interfaces, you then redesign for a bare bones production system. Debugging in the production system, if required, is usually done by oscilloscope, logic analyzer and (perhaps) by the single LED you left on the board...

Actually, I just exaggerated... We normally do put a diagnostic serial port on the board to aid in maintenance.

I have used a lot of embedded development systems and rate MPLAB as one of the best I have seen (especially for a target chip which costs $5 each).

If you want to work in large computer systems with object oriented code which fill volumes of notebooks (if you were to print it out), go and be at peace.

I, personally, don't want a Pentium with it's inevitable blue screen of death determining if the airbag in my truck is going to deploy or not... I'll take a nice, small uC (with nice, small expertly written code) any day.

'nuff said... Sorry about the rant.
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...

Last edited by Mike Betts : 09-12-2004 at 10:30.
  #12   Spotlight this post!  
Unread 09-12-2004, 10:24
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: c debugger

Quote:
Originally Posted by stephenthe1
lol, thanks. I did get a little carried away.
Steve,

I was typing my "rant" while you were posting this... Sorry.
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
  #13   Spotlight this post!  
Unread 09-12-2004, 10:29
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: c debugger

Quote:
Originally Posted by stephenthe1
um, would this code cause two pistons to fire assuming they are hooked up to relay 1 and relay2. also, you'll notice in my if statements that I used if its 1, then to execute the stuff, is that the right way of asking if the switch is one, or should I do (p2_sw_trig01), I've seen that but didn't know what it meant. what's the correct way? thanks.

Code:
 if (p1_sw_trig = 1) {
  relay1_fwd = 1;
  relay1_rev = 0;
  relay2_fwd = 1;
  relay2_rev = 0;
}
  if (p1_sw_trig = 0) {
 relay1_fwd = 0;
 relay1_rev = 0;
 relay2_fwd = 0;
 relay2_rev = 0;
}
  if (p2_sw_trig = 1) {
  relay1_fwd = 0;
  relay1_rev = 1;
  relay2_fwd = 0;
  relay2_rev = 1;
}
  if (p2_sw_trig = 0) {
 relay1_fwd = 0;
 relay1_rev = 0;
 relay2_fwd = 0;
 relay2_rev = 0;
}
In the code above, p1_sw_trig is not used (it is irrelevant). What do you want the function to be (in plain language)?
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
  #14   Spotlight this post!  
Unread 09-12-2004, 11:16
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
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,754
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: c debugger

Quote:
Originally Posted by stephenthe1
um, would this code cause two pistons to fire assuming they are hooked up to relay 1 and relay2. also, you'll notice in my if statements that I used if its 1, then to execute the stuff, is that the right way of asking if the switch is one, or should I do (p2_sw_trig01), I've seen that but didn't know what it meant. what's the correct way? thanks.

Code:
if (p1_sw_trig = 1) {
Needs to be:
Code:
if (p1_sw_trig == 1) {
And what Mike is referring to is that the check for p2_sw_trig will override any values you set after checking p1_sw_trig.

I assume you are looking for one button push to be forward and another to be reverse, and neutral if no button is pushed?

Just as an example, you could combine the checks on the neutral condition to make sure they don't override any other button push, e.g.,
Code:
if (p1_sw_trig == 0 && p2_sw_trig == 0) {
	 relay1_fwd = 0;
	 relay1_rev = 0;
	 relay2_fwd = 0;
	 relay2_rev = 0;
}
The p2 button will still override the p1 button if both are pushed at the same time.
Quote:
Originally Posted by stephenthe1
also, you'll notice in my if statements that I used if its 1, then to execute the stuff, is that the right way of asking if the switch is one, or should I do (p2_sw_trig01), I've seen that but didn't know what it meant. what's the correct way? thanks.
"if (p2_sw_trig01)" is treated the same as "if (p2_sw_trig01 == 1)"

[edit] Fixed my typo. (and I'm trying to be a good example). This is why you get other people to check your code. Thanks, Dave.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 09-12-2004 at 14:09.
  #15   Spotlight this post!  
Unread 09-12-2004, 13:12
Dave Flowerday Dave Flowerday is offline
Software Engineer
VRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 1995
Location: North Barrington, IL
Posts: 1,366
Dave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond repute
Re: c debugger

Quote:
Originally Posted by Mark McLeod
Just as an example, you could combine the checks on the neutral condition to make sure they don't override any other button push, e.g.,
Code:
if (p1_sw_trig == 0 & p2_sw_trig == 0) {
I think you want that to be:
Code:
if (p1_sw_trig == 0 && p2_sw_trig == 0) {
Generally it's best to use a logical AND (&&) and not a bitwise AND (&) when you're checking two expressions which evaluate to either true or false.
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Debugger and Simulation in new IDE? authgeek1218 Programming 1 08-12-2003 18:39


All times are GMT -5. The time now is 14:06.

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