Tracking and Beacon off of one Edu

Our team’s mentor decided its time for a vacation already, and so he’s gone for the rest of the week. That means no access to the robot rc for me =( Luckily, I did manage to yoink the edu and beacon stuff before he left :wink:

Anyways, this makes me want to try and run the beacon and the tracking code off of one Edu. I got something, but well, it’s not working (and unfortionately, this is the first day I’ve managed to really tackle this new c-programming micro stuffs). Anyways, one with what I did:
First, I downloaded the beacon code and the edu_tracker code (the version that doesn’t have the navigation built in). I used the tracker project as a base.

I first changed the tracking servos to pwm03 and pwm04 so pwm01 and pwm02 could be used for the left and right beacons. The optical sensors were put on interrupts 3, 4, 5, 6.

I then brought beacon.c and beacon.h into the project and added #include “beacon.h” in the user_routines.c and user_routines_fast.c. In the init section of user_routines.c, I added Initialize_Tracker();

I might have done something else, but thats all I seem to remember. I added some printf’s to tell me when the beacon was turned on.

In the console, I get “Tracker x: still searching” while the servos are going back and forth. These lines are interrupted by my “BEACON ON!” printf’s, as expected. Basically, the beacon code is outputing, the servos are searching.

I put the servos in front of the infrared LEDs, but it still says “still searching.” After a while, the console stops outputing my “BEACON ON!”'s. Soon after, the Program State LED turns blinking red, thus ending my hybrid program in a glorious infinite loop.

Any suggestions on how I can combine the beacon code and the tracking code onto one edubot?

-I assume you meant to say you added “Initialize_Beacon();” to user_routines.c
-Did you select the correct beacon to track (digital input 7)?
-Did you add the beacon interrupt handler to user_routines_fast.c?

If you email me the code I can help you debug the problem.
I’m also within a couple of miles of you. I’ll be at Hauppague robotics part of tonight if you’d like to come by and do it together.

  • Yes, thats what I meant - I did add Initialize_Beacon(); to user_routines.c (right above Initialize_Tracker():wink:

  • I didn’t select which beacon to track, but I changed the beacon PWM wire from PWM1 (left one) to PWM2 (right one), and nothing changed.

  • I did add Timer_0_Int_Handler(); to user_routines_fast.c in the appropriate spot in InterruptHandlerLow().

I’m not available tonight, but I’ll e-mail you the code. What really puzzles me is why the controller goes into an infinate loop. Does anyone know if the beacon and the tracker share an interrupt or a input or something, and maybe thats causing a conflict? I changed the tracker PWMs to 3 and 4, so its not that… the beacon uses timer0 while the tracker uses timer1… I don’t believe the beacon uses interrupts 3, 4, 5, or 6… I’m clueless. :frowning:

They don’t conflict for timers or interrupts.
I duplicated what you did over my lunch hour, but I won’t be able to test it until I get to the school tonight. If it works I’ll send it to you.

it would be fun to have the emiters on the edu and have the big 130 pounder chace after it atonoumsly also dangerous bbut it would be a great promotion

This should work because the beacon, receiver and tracker code was developed on a single EDU-RC. I’ll try to build it with the latest code and see it it works (or try to figure out what’s broken).

-Kevin

It works.
I took the reverse tack and added the tracker to the beacon s/w just because I already had our printf replacements in it.
BEWARE: printf isn’t included in this, but replacement print statements are.

PWM1 = beacon type 0
PWM2 = beacon type 1
The beacon digital switch is currently hardcoded to the beacon on PWM1
PWM7 = servo A
PWM8 = servo B
IR sensors are on interrupts 1,2 and 4,5 from an earlier version of Kevin’s tracker code.

You have to build a new project. I stripped out the project files because they sometimes don’t port to new machines well.

I’ll probably use your idea in a workshop we’re running for local teams on the IR beacon, sensors and s/w.

[edit]
I left the wrong print statements in tracker.c. It’s fixed now. It didn’t affect execution of the code only the printout of the diagnostic messages.
[/edit]

EduBeaconTracker.zip (46.7 KB)


EduBeaconTracker.zip (46.7 KB)

I’d call it more circumstance than idea. Anyways, thanks for the code… I’ll try it out later tonight and let you know how it worked out for me.

[Edit] Alright, I rebuilt parts of the edubot and plugged everything in, and sure enough, your version works. Thanks.

Now to go figure out why my version doesn’t work and/or adjust those sensors… didn’t realize they’re so sensitive that they can catch the reflection off just about anything…