Welcome, Guest. Please Login.
Surveyor Corporation Surveyor SRV-1
Home Help Search Login

Surveyor Robotics Forum

Welcome to the user support forum for Surveyor SRV-1 robots, SRV-1 robot controllers and SVS stereo vision systems. To register for this forum, please send an email to support@surveyor.com which includes your desired forum user name, your registration email address, and a brief explanation of why you wish to join, and we will create a forum account for you.

Please note that there is a Search button in the forum toolbar for forum topics. Another effective search method for the entire surveyor.com site is to use Google, e.g. "xyz site://www.surveyor.com" where "xyz" is the search topic.



Pages: 1 2 3 
Send Topic Print
Using picoC (Read 26353 times)
mshapiro
Full Member
***




Posts: 145
Re: Using the new C interpreter
Reply #15 - 06/13/09 at 8:19pm
 
Quote from admin on 06/13/09 at 8:03pm:
Where are xoff, x1 and x2 declared ?  Do you have "extern" statements somewhere so that they can be referenced between different code modules ?

They are declared globally at the top of myfunc.c with extern statements in library_surveyor.c, just below the other variable declarations.
Back to top
 
 
  IP Logged
admin
YaBB Administrator
*****




Posts: 3676
Re: Using the new C interpreter
Reply #16 - 06/13/09 at 8:27pm
 
The picoC "int" is 32-bit signed.  You should probably print out intermediate results with all of the variables.
Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
mshapiro
Full Member
***




Posts: 145
Re: Using the new C interpreter
Reply #17 - 06/13/09 at 9:12pm
 
Well, as you can see from my previous post (and the output below), straight() is returning 219, while xoff = 196 and xoff_239 = 159.  The values for xoff and xoff_239 are correct and reasonable.  The return value from straight() should be -37.
Code:
Offset from straight: 219    xoff: 196     xoff_239: 159 


the return value of straight is computed directly on it's last line from these two values
Code:
return xoff_239 - xoff; 


I just ran the code, again.  With the surveyor just to the right of the center line, where the expected result is positive (the first line, below), it gives responds as expected, but when the surveyor is just left of center, and a negative number is expected (the second line, below), the return value is the two's complement, as if the value was 8 bit unsigned.
Code:
Offset from straight: 26    xoff: 142     xoff_239: 168
Offset from straight: 252    xoff: 172     xoff_239: 168 


What else could be causing this discrepancy?
 
Well, I just made a simple change to the picoC script and it seems to be working, now.
Code:
Offset from straight: -36    xoff: 198     xoff_239: 162 


The change that I made was in the declaration of 'x', the variable accepting the return value from straight().  I originally declared and set it to "0" in a single statement
Code:
int x = 0; 


This resulted in the incorrect result.  When I split the above line into two statements
Code:
int x;
x = 0; 


I get the correct results.
 
I know that there had been a problem in the past with declaring a variable and setting it in the same statement, but that resulted in an unchangeable variable.  This is something different.  Perhaps the fix for the previous bug has created a new one?
Back to top
 
 
  IP Logged
admin
YaBB Administrator
*****




Posts: 3676
Re: Using the new C interpreter
Reply #18 - 06/13/09 at 9:46pm
 
I don't know if this is an issue, but with the global variables in picoC, I have taken a somewhat different approach, declaring essentially a copy of the global variable in library_surveyor.c, and then copying from the SRV-1 global to the picoC global in the library function, rather than letting picoC code reach into SRV-1 firmware space.  I actually never tried your approach of directly linking to the SRV-1 global in the VariableDefinePlatformVar() call, so you may have uncovered a problem.
Back to top
 
« Last Edit: 06/13/09 at 9:47pm by admin »  

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
mshapiro
Full Member
***




Posts: 145
Re: Using the new C interpreter
Reply #19 - 06/13/09 at 10:28pm
 
Actually, the variable that I am having the problem with is not a global exposed by the interpreter.  It is the variable 'x' declared and used in the picoC script.
Code:
int True = 1;
int False = 0;
int leftMotor;
int rightMotor;

int x;
x = 0;

// Clear the serial input buffer

input();
input();

while (True) {
  vcap();

  x = straight();
  printf("Offset from straight: %d    xoff: %d     xoff_239: %d\n", x, XOFF, XOFF_239);

  leftMotor = 30-(x*5);
  if (leftMotor > 45) leftMotor = 45;
  if (leftMotor < 15) leftMotor = 15;

  rightMotor = 30+(x*5);
  if (rightMotor > 45) rightMotor = 55;
  if (rightMotor < 15) rightMotor = 15;

  motors(leftMotor, rightMotor);

  if (signal())
    break;
}

// Shut motors off

motors(0,0);

// Exit picoC

exit();
 

Back to top
 
 
  IP Logged
lukec
YaBB Newbies
*




Posts: 16
Re: Using the new C interpreter
Reply #20 - 08/30/09 at 1:18am
 
Is it possible to create multiple functions within PicoC? For example I would like to create some functions then call them up multiple times within a main() style function but im having some issues with the C interpretor recognising this.
 
Is this possible?
What is the correct format?
 
eg I tried this type of thing
 
// Decalare functions
void my_funct1(int,int);
int my_funct2(void);
 
// "main" function
int a;
int b;
 
while(1)
{
 my_funct1(5,10);
 b = my_funct2();
}
 
// Function Details
void my_funct1(int x, int y)
{//etc}
 
int my_funct2(void)
{//etc}
Back to top
 
 
  IP Logged
admin
YaBB Administrator
*****




Posts: 3676
Re: Using the new C interpreter
Reply #21 - 08/30/09 at 7:14am
 
This is an interpreter, so you need to define the functions before using them, e.g.
 
 
// Function Details
void my_funct1(int x, int y)
{
  printf("hello1  %d\n", x+y);
}
 
int my_funct2(int x)
{
  x = x+ 1;
  printf("hello2\n");
  return x;
}  
 
int a;
int b;
 
my_funct1(5,10);
b = my_funct2(3);
Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
DickC44
YaBB Newbies
*




Posts: 4
Re: Using the new C interpreter
Reply #22 - 02/19/10 at 8:01pm
 
I find picoC to be buggy.  Last summer (or was it Fall) I reported a bug that turned out to be a problem in memcpy.  That was fixed in a firmware update last Fall.
 
On Jan 3, 2010 I reported more problems - excerpt:
Three problems were encountered:
 
1)
This syntax is not permitted by picoC inside a function
struct ABC* eee;
 
This is a pointer to a structure, not a definition.
 
 
2)
ALSO NOTE THE GARBLED ERROR MESSAGE PREFIX!
I've seen this occur in other error reporting.
 
This is probably due to a memory management problem.
 
 
3)
CC##Version - SRV-1 Blackfin w/picoC 0.93 12:52:54 - Nov  9 2009
struct MC_MotorsCommand MC_Queue[MC_QUEUE_SIZE];
                                             ^
test.c:155: integer value expected instead of
leaving picoC
 
As my program grew larger, the above error began occurring.
Apparently the #define value stored for MC_QUEUE_SIZE gets clobbered.
Using an integer literal for the array size works fine.
The macro name worked fine when the program was smaller.
 
This is probably due to a memory management problem.
 
For the complete submission see:
http://code.google.com/p/picoc/issues/detail?id=69
 
In short, picoC is not yet reliable for doing anything other than minor experiments.
 
So, play with it, but don't have high expectations.
 
thingy Curtiss
Back to top
 
 
  IP Logged
admin
YaBB Administrator
*****




Posts: 3676
Re: Using the new C interpreter
Reply #23 - 02/20/10 at 7:08am
 
There was a memcpy problem in the SRV-1 firmware, not picoC, which seems to have been a GCC compiler bug, and that has since been resolved.  We have many users working with picoC and do not often receive any problem reports.  
 
If you can post a complete snippet of code that produces the error you wish to report, we can investigate.  From your message, I can't tell exactly what error you have found.  You can also post error reports and review other issues on the picoC source code website -  http://code.google.com/p/picoc/
Back to top
 
« Last Edit: 02/20/10 at 7:11am by admin »  

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
DickC44
YaBB Newbies
*




Posts: 4
Re: Using the new C interpreter
Reply #24 - 03/27/10 at 9:20pm
 

#define sss 5
 
int aaa[sss];
 
 
 
Test Result
-----------
##Version - SRV-1 Blackfin w/picoC 1.0 20:05:00 - Mar 20 2010
CC##Xmodem success. Count: 128
int aaa[sss];
          ^
test.c:4: integer value expected instead of
leaving picoC
 
... instead of ????
 
Is the macro definition value getting lost or are macros not permitted in array declarations?
 
Thanks,
thingy Curtiss
 
Back to top
 
 
  IP Logged
admin
YaBB Administrator
*****




Posts: 3676
Re: Using the new C interpreter
Reply #25 - 03/29/10 at 7:14am
 
Your code works fine for me - I don't get an error.  Maybe there are some extra control characters embedded in the script you're sending that are causing the problem.
Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
DickC44
YaBB Newbies
*




Posts: 4
Re: Using the new C interpreter
Reply #26 - 03/29/10 at 10:17pm
 
Sorry, I have been unable to reproduce the problem myself.
 
I made that small test after encountering the error in my larger program, the one that may be having stack overflow issues.
 
I don't think I reset the SRV1 after the larger program failure, so there may have been a residual effect from that.
 
Thanks
 
Back to top
 
 
  IP Logged
vaolaritei
Junior Member
**




Posts: 62
Re: Using the new C interpreter
Reply #27 - 04/03/10 at 5:48am
 
i have a srv-1 blackfin with last firmware.
i try C interpreter with this comand:
laser(3);
printf("laser on");
int i;
i=0;
servo(75,75);
i=range();
delay(1000);
servo(50,50);
laser(0);
printf("laser off distace %d",i);
 
and return
laser on
no valid function servo()
i want know what's wrong.
thanks
Back to top
 
 
WWW good4u_tomi   IP Logged
admin
YaBB Administrator
*****




Posts: 3676
Re: Using the new C interpreter
Reply #28 - 04/03/10 at 8:26am
 
The function is servos(), not servo().
 
What motor controller are you using ?
Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
vaolaritei
Junior Member
**




Posts: 62
Re: Using the new C interpreter
Reply #29 - 04/06/10 at 1:31am
 
i dont know, i think  it's standard because a buy SRV-1 kit.
Thanks for answers.
 
Back to top
 
 
WWW good4u_tomi   IP Logged
Pages: 1 2 3 
Send Topic Print