Senior Project - Please Help
donfettuccini
Posts: 7
Hello everyone!
My partner and I are slimulating a RADAR device with the SRF04 sensor.
I am trying to import the data read from the SRF04 into excel, using the StampDaq program.
I tried using the "testcode" within the help file and add it into·the code I am using for the SRF04·and I am still having trouble.
I can connect to port 3 within StampDaq, but it is·not recieving any data from the SRF04 and entering into excel. The basic command to label the columns in excel are not even showing up in excel after connection is made.
Thanks
My partner and I are slimulating a RADAR device with the SRF04 sensor.
I am trying to import the data read from the SRF04 into excel, using the StampDaq program.
I tried using the "testcode" within the help file and add it into·the code I am using for the SRF04·and I am still having trouble.
I can connect to port 3 within StampDaq, but it is·not recieving any data from the SRF04 and entering into excel. The basic command to label the columns in excel are not even showing up in excel after connection is made.
Thanks
' {$STAMP BS2} ' {$PBASIC 2.5} ' ' ========================================================================= ' -----[noparse][[/noparse] Program Description ]--------------------------------------------- ' ' This program uses the Devantech SRF04 to measure the distance between the ' unit and a target. Display is raw value, centimeters, and inches. ' The sensor will be put onto of a moving robot which will make a sweep of 3 ' sectors. 'sector 1 = front 'sector 2 = robot moves to the left 'sector 3 = robot moves to the right 'Motion will be sector 1, sector 2, sector 1, sector 3 then loop ' -----[noparse][[/noparse] I/O Definitions ]------------------------------------------------- ' Trigger PIN 0 Echo PIN 1 ' -----[noparse][[/noparse] Constants ]------------------------------------------------------- #SELECT $STAMP #CASE BS2, BS2E Trig10 CON 5 ' trigger pulse = 10 uS ToCm CON 30 ' conversion factor to cm #CASE BS2SX, BS2P Trig10 CON 13 ToCm CON 78 #CASE BS2PE Trig10 CON 5 ToCm CON 31 #ENDSELECT sPin CON 3 'Serial Pin - P3, Programming port Baud CON 84 'Baud mode for a rate of 9600, 8-N-1 ' -----[noparse][[/noparse] Variables ]------------------------------------------------------- samples VAR Nib ' loop counter pWidth VAR Word ' pulse width from sensor rawDist VAR Word ' filtered measurment cm VAR Word ' centimeters inches VAR Word counter VAR Byte 'how many readings per sweep PAUSE 1000 'Allow data communications to stabilize SEROUT sPin,Baud,[noparse][[/noparse]CR] 'Send a lone CR to ensure StampDAQ buffer is ready ' -----[noparse][[/noparse] Initialization ]-------------------------------------------------- Configure: SEROUT sPin,Baud,[noparse][[/noparse]CR,"LABEL,Raw,Centi,Inches,Sector",CR] 'Label 4 columns with Raw, Centi, Inches and Sector SEROUT sPin,Baud,[noparse][[/noparse]"CLEARDATA",CR] 'Clear all data columns (A-J) in Excel Setup: LOW Trigger DEBUG CLS, "Devantech SRF04 Demo", CR, "--------------------", CR, "Raw........... ", CR, "Centimeters... ", CR, "Inches........ ", CR, "Sector........ " ' -----[noparse][[/noparse] Program Code ]---------------------------------------------------- Main: DO '---sector 1 --------------------------------------------------------------------- GOSUB Get_Sonar ' take sonar reading DEBUG CRSRXY, 15, 2, DEC rawDist, CLREOL cm = rawDist / ToCm ' convert to centimeters DEBUG CRSRXY, 15, 3, DEC cm, CLREOL inches = cm */ $03EF ' x 3.937 (to 0.1 inches) DEBUG CRSRXY, 15, 4, DEC inches / 10, ".", DEC1 inches, CLREOL ,CR DEBUG CRSRXY, 15, 5 DEBUG "1" 'display which sector objects in PAUSE 1000 ' delay between sector SEROUT sPin,Baud,[noparse][[/noparse]DEC rawDist, ",", DEC cm,",", DEC1 inches, ",", DEC 1, CR] '---sector 2 --------------------------------------------------------------------- GOSUB Get_Sonar ' take sonar reading DEBUG CRSRXY, 15, 2, DEC rawDist, CLREOL cm = rawDist / ToCm ' convert to centimeters DEBUG CRSRXY, 15, 3, DEC cm, CLREOL inches = cm */ $03EF ' x 3.937 (to 0.1 inches) DEBUG CRSRXY, 15, 4, DEC inches / 10, ".", DEC1 inches, CLREOL ,CR DEBUG CRSRXY, 15, 5 DEBUG "2" PAUSE 1000 ' delay between sector SEROUT sPin,Baud,[noparse][[/noparse]DEC rawDist, ",", DEC cm,",", DEC1 inches, ",", DEC 2, CR] '---sector 1 -------------------------------------------------------------------- GOSUB Get_Sonar ' take sonar reading DEBUG CRSRXY, 15, 2, DEC rawDist, CLREOL cm = rawDist / ToCm ' convert to centimeters DEBUG CRSRXY, 15, 3, DEC cm, CLREOL inches = cm */ $03EF ' x 3.937 (to 0.1 inches) DEBUG CRSRXY, 15, 4, DEC inches / 10, ".", DEC1 inches, CLREOL ,CR DEBUG CRSRXY, 15, 5 DEBUG "1" PAUSE 1000 ' delay between sector SEROUT sPin,Baud,[noparse][[/noparse]DEC rawDist, ",", DEC cm,",", DEC1 inches, ",", DEC 1, CR] '---sector 3 ---------------------------------------------------------------- GOSUB Get_Sonar ' take sonar reading DEBUG CRSRXY, 15, 2, DEC rawDist, CLREOL cm = rawDist / ToCm ' convert to centimeters DEBUG CRSRXY, 15, 3, DEC cm, CLREOL inches = cm */ $03EF ' x 3.937 (to 0.1 inches) DEBUG CRSRXY, 15, 4, DEC inches / 10, ".", DEC1 inches, CLREOL ,CR DEBUG CRSRXY, 15, 5 DEBUG "3" PAUSE 1000 ' delay between sector SEROUT sPin,Baud,[noparse][[/noparse]DEC rawDist, ",", DEC cm,",", DEC1 inches, ",", DEC 3, CR] ' NEXT LOOP END ' -----[noparse][[/noparse] Subroutines ]----------------------------------------------------- Get_Sonar: rawDist = 0 ' clear measurement FOR samples = 1 TO 5 ' take five samples PULSOUT Trigger, Trig10 ' 10 uS trigger pulse #SELECT $STamp #CASE BS2, BS2E RCTIME Echo, 1, pWidth ' measure pulse #CASE #ELSE PULSIN Echo, 1, pWidth ' measure pulse #ENDSELECT rawDist = rawDist + (pWidth / 5) ' simple digital filter PAUSE 10 ' minimum period between NEXT RETURN
Comments
you have used 84 as your baudmode value
"Baud·· CON·· 84· 'Baud mode for a rate of 9600, 8-N-1"
I don't think 84 is a valid number.
If you are running a BS2 and want 9600,8N1 and you're not going thru a RS232 tx chip then you want 16624 as your baudmode value.
That's the first thing I popped on...(I'm at work so don't have time to go thru the rest!!)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
http://members.rogers.com/steve.brady
http://www.geocities.com/paulsopenstage
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
84 is a valid number...but it is for a TRUE signal.· I think you only want TRUE if you are going thru an RS232 tx'r chip (like a MAX232).
(at least I had to use TRUE on my latest rig; while the inverted # worked for data w/o the chip).
So, you might want to try the inverted value for 96,8N1· which is 16468.
sorry for the confusion...hope this helps!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
http://members.rogers.com/steve.brady
http://www.geocities.com/paulsopenstage
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
I don't recieve any garbage values or any values.
I did notice when I use the "Simple Data Test Code" provided by StampDaq and set the port to 3 the same problem occurs.
The "Simple Data Test Code" works when I set the port to 1 within StampDaq.
But when I set the port to 1 using my code, error "StampDaq could not connect. Please check port setting."
-Hernan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
New Combo LCD Backpack
http://hometown.aol.com/newzed/index.html
·
if you're a windows user than you'll have to find it in through your Start button (Start>Programs>Accesories>Communications· ....may vary between some versions of windows).
Anyhow, load up hyperterminal.· They'll ask you for a connection profile name.· Just type anything you want...or something intelligable to be easier to go back to.
Next it'll ask you what you want to connect to.· At the bottom of the window there's a field for "Connect Using:".· Click this and select the com port you're on.· The next window asks you what port settings you want.· Select your 9600 N81 in there.
You're pretty well in it now.· If you're connected properly then you should be seeing your data.
how are you expecting to get your data?· You are outputting serial data on pin3 of the stamp (P3) and you are also debugging data through PBasic to your PC.
What kind of board are you using for your BS2?· A Board Of Education (BOE)? or something else?·
I'll guess that you want the data that's going out of pin3.· You'll have to attach a wire from I/O pin3 (not the physical pin3) to pin2 of your rs232 connector.· You'll also need a ground.· So connect a wire from pin5 of your Rs232 cable to Vss/Gnd of your BS2.
You'll have to make a cable yourself....or splice in to one and attach on to the right wires.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
http://members.rogers.com/steve.brady
http://www.geocities.com/paulsopenstage
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
·
I am using a BOE, BS2 and the SRF04. The SRF04 is connected to
Vss, Vdd, the trigger pulse input pin is connected to P0 and the echo pulse output pin is connected to P1.
·
The StampDaq help file said the sPin should be 16 and the baudmode value should be 84.
·
The “Simple Data Test Code” works with sPin = 16, baudmode = 84 and having the port set to 1 within StampDaq.
·
But when I connect the SRF04 and set the same values for sPin, baudmode and setting the port to 1 within StampDaq – error “StampDaq could not connect. Please check port setting” appears.
·
Any help is appreciated; I have to present the project to my teacher on Monday.
The error you describe tends to come from the 'new' device (the SRF04) pulling enough current that the BS2 can't run. This shouldn't happen with an SRF04, so I can only conclude your power-supply is weak.
I set this up and I was receiving ASCII errors in the Stamp DAQ box that look like this:
Error:· Data < ASCII 13 or ASCII 200
I'll look into it some more and see what I can come up with.
Dave
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dave Andreae
Tech Support
dandreae@parallax.com
www.parallax.com
·
Dave
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dave Andreae
Tech Support
dandreae@parallax.com
www.parallax.com
Post Edited (Dave Andreae (Parallax)) : 12/1/2004 11:24:43 PM GMT
Is it possible·to send me the code that worked for you. I commented out all of the debug statements·and I still can't read any data. Can you let me know what port within StampDaq you connected to.
Thanks
Here is the code that I used (attached).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dave Andreae
Tech Support
dandreae@parallax.com
www.parallax.com
Its seems to be reading inputs now.
Thanks