collapse

Author Topic: Interfacing SRF05 to PICAXE  (Read 4296 times)

jinx

  • calling from free Europe
  • Sr. Member
  • *****
  • Posts: 469
Interfacing SRF05 to PICAXE
« on: November 10, 2015, 05:42:38 AM »
pic srf small.PNG
*pic srf small.PNG (204.12 kB . 671x191 - viewed 426 times)

parts required:
                       PICAXE base shield
                       srf05 ultra sonic sensor
                       Dupont Male to Female Jumper

                          This snippet written in Picaxe BASIC and is  written for the axe 401 shield with the distance displayed in the terminal window of the editor.  first note that am using the shield pin definition "s.2"  rather than the PICAXE pin definition  c.0  but either will do the compiler will sort it out. Second is the setfreq which sets the internal clock frequency of the MCU and the 28x2 defaults to 8MHz which is fine but the maths will need altering on this line in the code :                                                                                                                                                let range = range * 10 / 62    
  refer to the manual for more on the maths.


 
wiring connection:   
srf05 wiring.PNG
*srf05 wiring.PNG (211.95 kB . 635x452 - viewed 1022 times)
   

 with the code snippet
Code: [Select]
#picaxe 28x2
#no_data
#no_table

symbol trig     = S.2            ' pin b.2 Define output pin for Trigger pulse
symbol echo   = S.8            '  pin C.0 Define input pin for Echo pulse
symbol range  = w1             ' 16 bit variable for range

symbol delay = 30

init:
    setfreq m4             '
    pause 100
do
    pulsout trig,2                                       ' produces a  20uS pulse (must be minimum of 10uS)
    pulsin echo,1,range                             ' measures the range in 10uS steps
    pause 10                                              ' recharge period after ranging completes
    let range = range * 10 / 62                  ' multiply by 10 then divide by 62
    sertxd("Range is" ,#w1,13,10)         ' display range via terminal
    pause delay                                               
loop

                                                      happy building Jinx.

LINKS:
   SRF05 data sheet: http://www.picaxe.com/docs/srf005.pdf
  technical sheet :http://www.robot-electronics.co.uk/htm/srf05tech.htm
« Last Edit: November 10, 2015, 08:34:11 AM by jinx »
I build bots

 

* Search


* Recent Topics

2D Side Scroller Cyberpunk themed by Killer Angel
[November 12, 2019, 07:56:15 AM]


The unnamed (yet) quatruped spider project by tinhead
[November 09, 2019, 05:58:16 AM]


Ebot SL by erco
[October 31, 2019, 04:27:36 PM]


Discord anyone? by tinhead
[October 20, 2019, 05:35:59 AM]


MKS Gen L 1.0 by lllloydo
[October 06, 2019, 01:24:26 AM]


Saturn pics anyone by viswesh
[September 28, 2019, 11:55:53 PM]


Hello Robot Rebels by Passixs
[September 15, 2019, 10:19:10 PM]


All Ya'll. And me. by James
[September 09, 2019, 10:35:19 PM]


MSD - Motorized solder dispenser (Work in progress) by James
[September 09, 2019, 08:45:29 PM]


It may be dangerous to work in the virtual realm by ZeroMax
[September 05, 2019, 05:55:16 PM]


"1984 Nixie Time" by Gareth
[August 25, 2019, 12:21:58 PM]


Just wanted to say Hi. by ErwinCanto
[August 18, 2019, 10:11:28 PM]


SDR (Software Defined Radio) by Gareth
[August 14, 2019, 01:12:21 PM]


PLX-DAQ by AmandaG
[August 06, 2019, 01:58:42 PM]


DIY Yellow Servo by AmandaG
[August 06, 2019, 01:08:09 PM]

* Recent Posts

Re: 2D Side Scroller Cyberpunk themed by Killer Angel
[November 12, 2019, 07:56:15 AM]


Re: The unnamed (yet) quatruped spider project by tinhead
[November 09, 2019, 05:58:16 AM]


Re: The unnamed (yet) quatruped spider project by Nemesis
[November 09, 2019, 03:29:02 AM]


Re: Ebot SL by erco
[October 31, 2019, 04:27:36 PM]


Re: 2D Side Scroller Cyberpunk themed by Killer Angel
[October 31, 2019, 09:57:48 AM]


Re: 2D Side Scroller Cyberpunk themed by Killer Angel
[October 31, 2019, 06:01:53 AM]


Re: 2D Side Scroller Cyberpunk themed by maelh
[October 30, 2019, 03:06:28 AM]


Discord anyone? by tinhead
[October 20, 2019, 05:35:59 AM]


The unnamed (yet) quatruped spider project by tinhead
[October 20, 2019, 05:28:14 AM]


Re: 2D Side Scroller Cyberpunk themed by Killer Angel
[October 17, 2019, 09:44:06 AM]


Re: 2D Side Scroller Cyberpunk themed by Killer Angel
[October 17, 2019, 08:16:11 AM]


Re: 2D Side Scroller Cyberpunk themed by Killer Angel
[October 14, 2019, 08:52:20 AM]


2D Side Scroller Cyberpunk themed by Killer Angel
[October 14, 2019, 03:32:40 AM]


Re: MKS Gen L 1.0 by lllloydo
[October 06, 2019, 01:24:26 AM]


Re: Saturn pics anyone by viswesh
[September 28, 2019, 11:55:53 PM]