Go to Post Yes ONE blue banner would be nice one of these days, but I've never lost focus of why we as mentors do what we do. It's about preparing the students for "defense" in life, and laugh when your robot gets scored into a goal. - Chris_Elston [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 08-11-2007, 11:32
Qbranch Qbranch is offline
wow college goes fast.
AKA: Alex
FRC #1024 (Kil-A-Bytes)
Team Role: Alumni
 
Join Date: Apr 2006
Rookie Year: 2006
Location: Indianapolis
Posts: 1,174
Qbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond repute
Re: SONAR Sensor Software Driver

People have been PM'ing me about my single-pin ultrasonic driver for the Parallax PING))) ultrasonic sensor module.

I've cut out most of the signal processing, noise filtering, and object tracking code that I wrote, but there is enough here to get you your pulse-timing (raw distances). If you have questions post, please don't PM since many end up asking the same questions.

I realize it isn't the prettiest code, but then again I was never intending on posting it when it was written...

Enjoy... I attached the related files below. *cringes waiting for flood of 'this is bad programming convention' posts*

-q
Attached Files
File Type: c EDITEDusdriver.c (4.5 KB, 260 views)
File Type: h EDITEDusdriver.h (1.2 KB, 204 views)
File Type: c user_routines_fast.c (9.6 KB, 240 views)
__________________
Electrical Engineer Illini
1024 | Programmer '06, '07, '08 | Driver '08
  #2   Spotlight this post!  
Unread 08-11-2007, 14:39
Protronie's Avatar
Protronie Protronie is offline
Have big wrench...and will use it!
no team
 
Join Date: Dec 2006
Rookie Year: 2006
Location: North Carolina
Posts: 617
Protronie has much to be proud ofProtronie has much to be proud ofProtronie has much to be proud ofProtronie has much to be proud ofProtronie has much to be proud ofProtronie has much to be proud ofProtronie has much to be proud ofProtronie has much to be proud of
Send a message via ICQ to Protronie Send a message via Yahoo to Protronie
Re: SONAR Sensor Software Driver

Quote:
Originally Posted by Qbranch View Post

Enjoy... I attached the related files below. *cringes waiting for flood of 'this is bad programming convention' posts*

-q
Your right... it ain't pretty but it works and thats what matters...
thanks for posting!
__________________
Protronie rule 5 - When the big wrench starts swinging, get out of the way!
  #3   Spotlight this post!  
Unread 09-11-2007, 07:52
Roger Roger is offline
Registered User
FRC #1153
 
Join Date: Jan 2006
Rookie Year: 1900
Location: Walpole MA
Posts: 688
Roger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond repute
Re: SONAR Sensor Software Driver

Hey, it has plenty of good comments -- is that what you mean by "bad programming convention"? Thanks Qbranch!

We did get Mike's sonar code working last night (oh, the simple errors we made) -- the places we can now go!

______________________________
It's kind of fun to do the impossible. -Walt Disney
  #4   Spotlight this post!  
Unread 15-01-2008, 10:33
gnormhurst's Avatar
gnormhurst gnormhurst is offline
Norm Hurst
AKA: gnorm
#0381 (The Tornadoes)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Trenton, NJ
Posts: 138
gnormhurst will become famous soon enoughgnormhurst will become famous soon enough
Re: SONAR Sensor Software Driver

Back in 2006 I installed Mike's sonar driver and it worked great. I followed his instructions for modifying InterruptHandlerLow () and everything was good.

I want to do it again, but when I look at the current code, InterruptHandlerLow () looks very different!

Can someone have a quick look at this and tell me if I have created any obvious conflicts? My modifications are in color.

Thanks!

Norm

Code:
void InterruptHandlerLow ()     
{
	if (PIR1bits.RC1IF && PIE1bits.RC1IE) // rx1 interrupt?
	{
		#ifdef ENABLE_SERIAL_PORT_ONE_RX
		Rx_1_Int_Handler(); // call the rx1 interrupt handler (in serial_ports.c)
		#endif
	}                              
	else if (PIR3bits.RC2IF && PIE3bits.RC2IE) // rx2 interrupt?
	{
		#ifdef ENABLE_SERIAL_PORT_TWO_RX
		Rx_2_Int_Handler(); // call the rx2 interrupt handler (in serial_ports.c)
		#endif
	} 
	else if (PIR1bits.TX1IF && PIE1bits.TX1IE) // tx1 interrupt?
	{
		#ifdef ENABLE_SERIAL_PORT_ONE_TX
		Tx_1_Int_Handler(); // call the tx1 interrupt handler (in serial_ports.c)
		#endif
	}                              
	else if (PIR3bits.TX2IF && PIE3bits.TX2IE) // tx2 interrupt?
	{
		#ifdef ENABLE_SERIAL_PORT_TWO_TX
		Tx_2_Int_Handler(); // call the tx2 interrupt handler (in serial_ports.c)
		#endif
	}

        // the following added to support sonar:
        //
        else if (INTCON3bits.INT2IF && INTCON3bits.INT2IE)/* The INT2 pin is RB2/DIG I/O 1. */
        { 
          Hardware_Interrupt_Sonar(); 
          INTCON3bits.INT2IF = 0;
        }

        else if ( PIR2bits.TMR3IF && PIE2bits.TMR3IE )
        {
            Timer_Interrupt_Sonar();  
        }


}
__________________
Trenton Tornadoes 381
2004 Philadelphia Regional Winners
2006 Xerox Creativity Award
---
My corner of the USPTO.
My favorite error message from gcc: main is usually a function
My favorite error message from Windows: There is not enough disk space available to delete this file.
  #5   Spotlight this post!  
Unread 16-01-2008, 08:47
Roger Roger is offline
Registered User
FRC #1153
 
Join Date: Jan 2006
Rookie Year: 1900
Location: Walpole MA
Posts: 688
Roger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond repute
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.
  #6   Spotlight this post!  
Unread 16-01-2008, 14:12
Jungle_Ed Jungle_Ed is offline
Registered User
FRC #0405
 
Join Date: Jan 2008
Location: Richmond
Posts: 1
Jungle_Ed is an unknown quantity at this point
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.
  #7   Spotlight this post!  
Unread 16-01-2008, 14:32
gnormhurst's Avatar
gnormhurst gnormhurst is offline
Norm Hurst
AKA: gnorm
#0381 (The Tornadoes)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Trenton, NJ
Posts: 138
gnormhurst will become famous soon enoughgnormhurst will become famous soon enough
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.
__________________
Trenton Tornadoes 381
2004 Philadelphia Regional Winners
2006 Xerox Creativity Award
---
My corner of the USPTO.
My favorite error message from gcc: main is usually a function
My favorite error message from Windows: There is not enough disk space available to delete this file.
  #8   Spotlight this post!  
Unread 16-01-2008, 14:46
Qbranch Qbranch is offline
wow college goes fast.
AKA: Alex
FRC #1024 (Kil-A-Bytes)
Team Role: Alumni
 
Join Date: Apr 2006
Rookie Year: 2006
Location: Indianapolis
Posts: 1,174
Qbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond repute
Re: SONAR Sensor Software Driver

Quote:
Originally Posted by gnormhurst View Post
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 ) 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
__________________
Electrical Engineer Illini
1024 | Programmer '06, '07, '08 | Driver '08
  #9   Spotlight this post!  
Unread 31-01-2008, 09:27
cprogrammer's Avatar
cprogrammer cprogrammer is offline
Registered User
FRC #1595 (Gremlins)
Team Role: Programmer
 
Join Date: Feb 2005
Rookie Year: 2005
Location: Washington
Posts: 42
cprogrammer will become famous soon enoughcprogrammer will become famous soon enough
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
  #10   Spotlight this post!  
Unread 02-02-2008, 13:29
seg9585's Avatar
seg9585 seg9585 is offline
Registered User
AKA: Eric
FRC #4276 (Surf City Vikings)
Team Role: Engineer
 
Join Date: Feb 2006
Rookie Year: 2001
Location: Boeing (Seal Beach, CA)
Posts: 520
seg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond repute
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.

Last edited by seg9585 : 02-02-2008 at 17:56.
  #11   Spotlight this post!  
Unread 12-02-2008, 14:07
GregK GregK is offline
Registered User
FRC #0381
 
Join Date: Feb 2008
Location: Princeton, NJ
Posts: 1
GregK is an unknown quantity at this point
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?
  #12   Spotlight this post!  
Unread 13-02-2008, 08:49
dadamson's Avatar
dadamson dadamson is offline
Registered User
FRC #2546
 
Join Date: Jan 2008
Location: Baltimore, MD
Posts: 4
dadamson is an unknown quantity at this point
Re: SONAR Sensor Software Driver

Quote:
Originally Posted by seg9585 View Post
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.
  #13   Spotlight this post!  
Unread 15-02-2008, 23:03
B_Dubbs B_Dubbs is offline
Registered User
AKA: Brian
FRC #1153
Team Role: Programmer
 
Join Date: Mar 2007
Rookie Year: 2006
Location: Walpole, MA
Posts: 29
B_Dubbs is an unknown quantity at this point
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.
  #14   Spotlight this post!  
Unread 06-03-2008, 19:26
mandrews281 mandrews281 is offline
Registered User
FRC #0281
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Greenville SC
Posts: 83
mandrews281 is a splendid one to beholdmandrews281 is a splendid one to beholdmandrews281 is a splendid one to beholdmandrews281 is a splendid one to beholdmandrews281 is a splendid one to beholdmandrews281 is a splendid one to beholdmandrews281 is a splendid one to behold
Re: SONAR Sensor Software Driver

Quote:
Originally Posted by dadamson View Post
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
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Toshiba Cardbus Problem? jpsaul7usa Chit-Chat 12 01-01-2006 02:37
Introducing the Driver Strategy Database's Online Database impulse3D Rules/Strategy 17 17-03-2005 03:04
Updated: Serial Port Driver Code Kevin Watson Programming 4 05-02-2005 18:39
New Serial Port Driver Kevin Watson Programming 16 09-01-2005 01:56
Middle School Drivers ram General Forum 40 26-02-2003 17:01


All times are GMT -5. The time now is 21:12.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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