Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   c debugger (http://www.chiefdelphi.com/forums/showthread.php?t=31654)

stephenthe1 08-12-2004 10:01

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?

krhs_programmer 08-12-2004 12:41

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.

Mike 08-12-2004 20:57

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.

Dave Flowerday 08-12-2004 23:07

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.

Rickertsen2 09-12-2004 00:39

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.

Dave Flowerday 09-12-2004 00:50

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.

stephenthe1 09-12-2004 09:24

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.

Mike Betts 09-12-2004 09:44

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,

stephenthe1 09-12-2004 09:51

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. :D

stephenthe1 09-12-2004 09:54

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;
}


Mike Betts 09-12-2004 10:22

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 09-12-2004 10:24

Re: c debugger
 
Quote:

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

Steve,

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

Mike Betts 09-12-2004 10:29

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)?

Mark McLeod 09-12-2004 11:16

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.

Dave Flowerday 09-12-2004 13:12

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.


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

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