I am trying to get the pic to send out a 10us pulse in order to trigger the ultrasonic receiver and then convert it inches to turn on an led or to drive motors help is appreciated
I am trying to get the pic to send out a 10us pulse in order to trigger the ultrasonic receiver and then convert it inches to turn on an led or to drive motors help is appreciated
The default clock on the 12F683 is 4MHz according to the datasheet found in REG 3-1 but still better to set it and define it along with turning OFF other peripherals not used:
But if using PBP3 then:Code:@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF & _BOD_OFF OSCCON = %01100001 ' Osc 4MHz ADCON0 = 0 ' A/D module OFF CMCON0 = 7 ' Analog comparators off GPIO = %00000000 ' Turn OFF all ports TRISIO = %00001101 ' Ports 0, 2 and 3 inputs, rest outputs (Example) DEFINE OSC 4 ' Declare FOR PAUSE and PAUSEUS statements
Code:#CONFIG __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF & _BOD_OFF #ENDCONFIG OSCCON = %01100001 ' Osc 4MHz ADCON0 = 0 ' A/D module OFF CMCON0 = 7 ' Analog comparators off GPIO = %00000000 ' Turn OFF all ports TRISIO = %00001101 ' Ports 0, 2 and 3 inputs, rest outputs (Example) DEFINE OSC 4 ' Declare FOR PAUSE and PAUSEUS statements
Louie
thanks I will give it a try I have chuck hellebuyck's book on picbasic are there any other recommendations for it that could better benefit me .
Chuck Hellebuyck's book is the best commercial basic-to-intermediate PBP book that I've seen. As far as other recommendations:
1. The manual that comes with PB3! There is a wealth of knowledge in there, and it is put together very well. I still find something new every time I look in it--I keep a shortcut for it on the Windows task bar.
2. The manual for whatever PIC you're using. It took me a while to learn how to understand the PIC manuals, it was a post in a precursor to this fine forum (email list) that clicked it for me. Which brings me to...
3. This forum. Use Darrel's excellent improved search tool (here). Commit to reading every new post for a few weeks and get a feel for the common troubles many have, drink in the wisdom of the regular posters (not me), and follow some of the posted code as it gets improved.
Best Regards,
Paul
The way to avoid mistakes is to gain experience. The way to gain experience is to make mistakes.
Bookmarks