collapse

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

jinx

  • calling from free Europe
  • Sr. Member
  • *****
  • Posts: 470
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 513 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 1174 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

The unnamed (yet) quatruped spider project by tinhead
[July 01, 2020, 04:22:11 PM]


"1984 Nixie Time" by 1 what
[May 08, 2020, 01:04:18 AM]


2D Side Scroller Cyberpunk themed by Killer Angel
[February 06, 2020, 06:39:40 AM]


A new wing design for model aircraft / drones by OddBot
[February 06, 2020, 04:42:06 AM]


SDR (Software Defined Radio) by Gareth
[February 02, 2020, 06:15:42 AM]


Circuit Math by ZeroMax
[January 31, 2020, 01:50:18 PM]


NanOMeter by Protowrxs
[January 01, 2020, 12:59:44 PM]


Investigating the VL53L0X Laser Rangefinder by erco
[December 30, 2019, 10:45:44 PM]


PS4 Single Handed Controller Deployed (part 7 of 7) by Gareth
[December 30, 2019, 09:52:29 AM]


"D" -Pad Workio just like Magic (Will Merlin stay or Go) (part 6 of 7) by Gareth
[December 30, 2019, 09:51:27 AM]


PS4 Joystick Digitals 4,5,6,7,10 - Analog's Lx,Ly,Rx,Ry Workio (part 5 of 7) by Gareth
[December 30, 2019, 09:50:37 AM]


Menu Workio ! (part 4 of 7) by Gareth
[December 30, 2019, 09:49:49 AM]


L1 trigger design Workio (Hori controller) (part 3 of 7) by Gareth
[December 30, 2019, 09:48:50 AM]


Hori aka PS4 Joystick Mappings (part 2 of 7) by Gareth
[December 30, 2019, 09:47:17 AM]


PS4 Single Left-Handed Controller (part 1 of 7) by Gareth
[December 30, 2019, 09:44:58 AM]

* Recent Posts

Re: The unnamed (yet) quatruped spider project by tinhead
[July 01, 2020, 04:22:11 PM]


Re: The unnamed (yet) quatruped spider project by jinx
[July 01, 2020, 04:06:19 PM]


Re: "1984 Nixie Time" by 1 what
[May 08, 2020, 01:04:18 AM]


Re: "1984 Nixie Time" by tomasp
[April 13, 2020, 06:03:28 PM]


Re: 2D Side Scroller Cyberpunk themed by Killer Angel
[February 06, 2020, 06:39:40 AM]


A new wing design for model aircraft / drones by OddBot
[February 06, 2020, 04:42:06 AM]


Re: "1984 Nixie Time" by Gareth
[February 02, 2020, 06:23:01 AM]


Re: SDR (Software Defined Radio) by Gareth
[February 02, 2020, 06:15:42 AM]


Re: SDR (Software Defined Radio) by ZeroMax
[January 31, 2020, 01:54:21 PM]


Re: "1984 Nixie Time" by ZeroMax
[January 31, 2020, 01:52:29 PM]


Circuit Math by ZeroMax
[January 31, 2020, 01:50:18 PM]


Re: 2D Side Scroller Cyberpunk themed by ZeroMax
[January 31, 2020, 01:45:33 PM]


NanOMeter by Protowrxs
[January 01, 2020, 12:59:44 PM]


Re: Investigating the VL53L0X Laser Rangefinder by erco
[December 30, 2019, 10:45:44 PM]


PS4 Single Handed Controller Deployed (part 7 of 7) by Gareth
[December 30, 2019, 09:52:29 AM]