Subject:
|
IC Pointer Questions
|
Newsgroups:
|
lugnet.robotics.handyboard
|
Date:
|
Sun, 15 Mar 1998 12:27:01 GMT
|
Original-From:
|
Jaron Paludanus <j.paludanus@STOPSPAMtip.nl>
|
Viewed:
|
1513 times
|
| |
| |
Howdy all,
I finally attached an infrared reflectance sensor to my handyboard and it
works! With my non-existent electronic experiences I managed to solder a
resistance (330 ohms) to a three-legged sensor similar to the four-legged
variant mentioned in the FAQ.
So I ordered IC 3.2 and received a registration key the following day (good
work Newton) and started setting up the project for my LARVE (Little
Autonomous Robot VEhicle). I used to be an administrative programmer in
dBase and Clipper 87 but am new to C and have to rely on the excellent book
"The C Programming Language" from Kernighan/Ritchie (Prentice-Hall).
I now come across the first two problems I just can't find a solution for
myself,
I'm probably overseeing something or what?
-1- My robot has four drivewheels, each connected to a motor and a
reflectance sensor. I want to use a data structure array to store all
parameters, settings and readings for each wheel. The m/c routine creates a
variable "encoder0_counts" while I want to use the structure element
"wheel[i].encoder.count".
When I use pointers in the declarations of the encoder structure I also
have to change the syntax of the routines to deference the pointers. This
is NOT what I want.
struct _wheel {int radius;int ticks;};
struct _encoder {int port;int *velocity ;int *count;};
struct drivewheel {struct _encoder encoder;struct _wheel wheel;}
wheel[4];
wheel[0].encoder.count= &encoder0_counts;
*wheel[0].encoder.count= 0; /*I want to get rid of that dereferencing
asterix ...*/
Is there a way I can declare "wheel.encoder.count" so that it exists as an
integer pointing to the same memory location as "encoder0_counts"? Can I
change the pointer of an existing integer?
"wheel[0].encoder.count= 0;" Would then be the same as "encoder0_counts=
0;"
-2- I want to initialize an array "char readings[256]" to hold the
measurements during calibration. But it leads to one of those well
explained <lol> memory errors. Of course it can be declared globally but
then it will take up space while only used when calibrating. Can I increase
the stack size for a function without starting it as a seperate process? Or
can I set TICKS to 1000 and will the process act as a normal function?
Can anyone be of help?
Thanks,
Jaron Paludanus
j.paludanus@tip.nl
The Netherlands
Europe
|
|
Message has 1 Reply: | | Re: IC Pointer Questions
|
| (...) If I am understanding you right... I haven't looked at the encoder routines yet, but I am assuming encoder0_counts is global. Why not, just omit the pointer count from the _encoder struct and just use the global, since you already have it? (...) (27 years ago, 15-Mar-98, to lugnet.robotics.handyboard)
|
2 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|