Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   SONAR Sensor Software Driver (http://www.chiefdelphi.com/forums/showthread.php?t=42717)

Roger 16-01-2008 08:47

Re: SONAR Sensor Software Driver
 
Okay, now I'm getting a little annoyed. It's time to get this sonar working once and for all!

We got Qbranch's code working with our 2006 robot and code. We haven't tried it with newer code, but the major difference I believe was Kevin Watson's updated PWM routine. (Sorry, I don't have the code in front of me to quote chapter and verse.) It's been a month since I stuck my toe into the wonderful world of interrupts, but now I want to dive in and get it done. I'm going to throw some programmers at this and see how far we get this time.

Jungle_Ed 16-01-2008 14:12

Re: SONAR Sensor Software Driver
 
Hey I just got assigned to a 2008 FRC team. I am going to try using Mike 0.3 code then Qbranch's Code. Anyone, please let me know of you get some ok readings for the Sonar on and FRC robot, and I will be sure to do the same.

gnormhurst 16-01-2008 14:32

Re: SONAR Sensor Software Driver
 
We got the Vex sonar working last night using Mike's driver. I'm really impressed by the whole thing -- it can see a 3' x 4' board at about 15 feet!

Note: the documentation that came with the Sonar sensor I got (from Radio Shack, back when they sold Vex stuff) had the "input" and "output" functions backwards. See my earlier post in this thread.

The wire marked "input" is an input to the sonar, and it needs to come from a rc_digital_io_NN pin configured as an output. You need to set a couple of macros in sonar.h to tell it which pin you are using for the sonar input.

The output needs to go to a digital_io pin that acts as an interrupt. We used rc_digital_io_01. I think that is the default in Mike's code.

Qbranch 16-01-2008 14:46

Re: SONAR Sensor Software Driver
 
Quote:

Originally Posted by gnormhurst (Post 679357)
We got the Vex sonar working last night using Mike's driver. I'm really impressed by the whole thing -- it can see a 3' x 4' board at about 15 feet!

Beware of off-axis error! Depending on what sensor you're using (Parallax PING))) is pretty much your best bet) the further a wall is off axis the worse your measurements will be.

For example, if you were, say, following along a wall and servoing off of the distance from the wall (no idea why you'd want to do that :rolleyes: ) you're robot will swerve further and further until it crashes, because, each time the robot veers left or right it alters the distance the ping sensor percieves, even though the distance has barely changed. This escalates until, like I said, you crash.

Instead (and we've used this in the past) use encoders to drive your robot straigh, and use ultrasonics for obstacle detection/avoidance.

Getting a reliable distance to anything at any angle is our current goal at 1024.

-q

cprogrammer 31-01-2008 09:27

Re: SONAR Sensor Software Driver
 
I have a quick question Mike Dubreuil. YOu ping the sonar with Ping_Sonar and turn the timer on. Then once it interrupts it goed into Hardware_Interrupt_Sonar an into the switch statement for SONAR_WAIT status and you turn the timer on again. Then it goes into the switch statement for SONAR_TIMING for the next interrupt and get phase width as a measurement. Is the phase_width the time it takes for the actuall sound wave to go through the sonar, not the echo from the wall? If it is the echo value, then why start the timer in SONAR_WAIT?

Thanks Stephen

seg9585 02-02-2008 13:29

Re: SONAR Sensor Software Driver
 
I have the code setup as gnornhurst posted in the "SONAR Sensor Software Driver" and i'm using rc_dig_out16 for input and digital IO port 1 for "output", but I'm getting a "Cannot find Sonar" error.
I was wondering if there were any additional code changes you needed to make to get this to work with this year's Kevin Watson code?

Thanks.

GregK 12-02-2008 14:07

Re: SONAR Sensor Software Driver
 
Last nite, I set to work adding a second sonar. Because of the limited time, I just made a second copy of Mike's sonar.c and sonar.h (which we are using for the first sonar). I named the second copy sonar2.c & h and changed the global variable names. While checking around to find what else I should change (which interupts and pins I should use), I found out that Mike has written another sonar named jvex_sonar.c routine that handles four sonars (at http://www.koders.com/c/fid735E99BB5...A82C4454.aspx).

What the story with that routine? Would I be better off starting with that code or continue with my approach?

dadamson 13-02-2008 08:49

Re: SONAR Sensor Software Driver
 
Quote:

Originally Posted by seg9585 (Post 690724)
I was wondering if there were any additional code changes you needed to make to get this to work with this year's Kevin Watson code?

After a fair bit of wrestling yesterday, we got the 0.3 Sonar driver talking to Kevin W's 3.0 code. We ripped out references to his pwm.h, mostly (except for #includes) in ifi_frc.c Both it and the sonar driver want to use timer 3.

B_Dubbs 15-02-2008 23:03

Re: SONAR Sensor Software Driver
 
We, about 2 hours ago, have gotten all of our sonars to work with Kevin's encoder code. We did this by using both Mike's and Kevin's code together. Once we get everything perfectly straightened out, we could post it.

mandrews281 06-03-2008 19:26

Re: SONAR Sensor Software Driver
 
Quote:

Originally Posted by dadamson (Post 697961)
After a fair bit of wrestling yesterday, we got the 0.3 Sonar driver talking to Kevin W's 3.0 code. We ripped out references to his pwm.h, mostly (except for #includes) in ifi_frc.c Both it and the sonar driver want to use timer 3.

I'm trying the same thing with the Vex sensor and haven't had much luck. I ripped out ALL the pwm references and if I interpret the code correctly (a big if), it's using interrupt2, so I've connected the sensor to dig_in_02. Depending on which output/input I connect to dig_out_16/in_02, I get software malfunction or reversed I get an occasional "device not detected" (usually when I press or release the trigger). Anyway, in all cases the pulse_width (and therefore the distance) is 0.

Any chance of getting more details what you did so I can see what am I doing wrong? Thanks

eaglesfan10 08-03-2008 11:03

Re: SONAR Sensor Software Driver
 
Any ideas on how to make an ultrasonic sensor work with Kevin's new 2008 code? I know it handles interrupts differently, and I really don't have a great understanding on how to use interrupts. We're using a Vex UltraSonic Sensor (and it looks like it's digital).


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

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