when i use: pulsin portf.0, 5
it should put pin f.0 high for .005 seconds right??? i am really realizing how much i dont know about this stuff. most of my robots have been made by trying different code until it works. on this one, i am learning a little more code but i still dont know how all this works..
heres the code:
DEFINE OSC 20
TRISF.1 = 0
'variables
'----------------------------------------------------------------------------------
baudLCD CON 32 'baud rate for lcd
lcd VAR PORTF.0 'lcd port
ping VAR WORD
ultra VAR PORTF.1
Low PORTF.1
High PORTF.0
ping = 0
'Startup Program
'-------------------------------------------------------------------------------------- 'start motor driver
Pause 3000 'pause for LCD startup screen 'reset motor driver 'wait a few seconds
SerOut2 lcd, baudlcd,[254,"X"] 'clear screen
Pause 100
SerOut2 lcd, baudlcd,[254,"X"] 'clear screen again
SerOut2 lcd, baudlcd,[254,"P",140] 'change resolution
SerOut2 lcd, baudlcd,[254,71,1,1,"Ping Test"] 'display test on lcd in position 1,1
'main program
'----------------------------------------------------------------------------------------
start:
PulsOut ultra, 5 'send trigger to ping
PulsIn ultra, 1, ping 'wait for ping variable
Pause 1000
SerOut2 lcd, baudlcd,[254,71,5,3,DEC ping," "]
Pause 1000
GoTo start
End
and heres a video or whats happening...
http://s163.photobucket.com/albums/t...adbotultra.flv
unfortunately, its not easy to see the LCD screen, so it may not help much
thanks for all the help...
RF0 is AN5
RF1 is AN6/C2OUT
So these might help.<br>Code:ADCON1 = $0F CMCON = 7
DT
once again, you are amazing!!! i know somehow that makes then digital instead of analog, but i havent ever figured out how all that works...
maybe there will be a video later on...
Then I wouldn't worry about the A/D stuff right now. So far none of your project will be using analog. So you can just leave them turned off.
I think you've got "Bigger Fish to Fry".
If you do add analog stuff later, just take a look at the ADCON1 register (19-2) in the data sheet. There's a table that shows what values to use for whatever analog inputs you need. Same for CMCON.
<br>
DT
i definately have a lot of "frying" to do!!! i enjoy the challenge of trying to make this stuff work but sometimes its nice to have help from you guys that know what you are doing.
i have another small problem right now. i used if/then (i know they arent the best way to do stuff, but its easy) statements so if the distance is more than "900" then it will drive fast, if its lower than "900" then it will slow down, and if its lower than 350 it will stop and turn, then drive fast again until it senses something..
so it will drive fast, and then when it gets to under "900", it slows down, but then it stays at that speed, and it doesnt send out pings.
im almost positive that im either missing something or things arent in the right order.
im going to play around with it a little more before i "officially" ask for help. that way i can learn all the things that dont work!!!
Bookmarks