From owner-freebsd-arm@FreeBSD.ORG Thu Aug 21 18:44:38 2014 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B4DF9C8F; Thu, 21 Aug 2014 18:44:38 +0000 (UTC) Received: from mail-we0-x236.google.com (mail-we0-x236.google.com [IPv6:2a00:1450:400c:c03::236]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1F49938C0; Thu, 21 Aug 2014 18:44:37 +0000 (UTC) Received: by mail-we0-f182.google.com with SMTP id k48so9793065wev.27 for ; Thu, 21 Aug 2014 11:44:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=B1/ewZ1OdJFJh8Vv2nWLI0I0GdhLUzqG/Jl7DJGbUn0=; b=RYBA5pTHPIj5AnQY6XS6R8VdFV1fK8ZZMNd2Nj3ibhhoSbwQgeuvYAE1HwForKzJn0 nu/1qh3TZGeBpr7BiToyofymL9A9hOqRTjTZkiEvRw9WNPeDLlag6iAxPcdbRD/MJ47i m+D9DqwFHe9Khg6oVMGeF2zU/GaAsUanFBv3rpmPyxCxjNtoDbMuMPU3Z2kAMFRwG7vP Yk5AfE47rOJtgpyi1yo/ZcQn1MHGF8WyHJHsjnvENusOKyIXDigoaTGQ9hefc83Rl5hx VYokTCtq8llJoE+jLBnjkRtVQll/C9wZ3IJ8QL+XHn4kgZbZEzaucQBhIjNb7jRlfw2B Yn2Q== MIME-Version: 1.0 X-Received: by 10.194.119.98 with SMTP id kt2mr380293wjb.96.1408646676371; Thu, 21 Aug 2014 11:44:36 -0700 (PDT) Received: by 10.217.125.66 with HTTP; Thu, 21 Aug 2014 11:44:36 -0700 (PDT) In-Reply-To: References: <5D802942-2D0F-4324-8212-C2871EEB6327@FreeBSD.org> <01562FB1-32C6-45AF-AB77-5BB80526E18C@FreeBSD.org> Date: Thu, 21 Aug 2014 15:44:36 -0300 Message-ID: Subject: Re: HC-SR04 and FreeBSD From: Evandro Nunes To: Rui Paulo , freebsd-arm@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Aug 2014 18:44:38 -0000 On Thu, Aug 21, 2014 at 1:24 PM, Rui Paulo wrote: > On Aug 20, 2014, at 22:34, Evandro Nunes wrote: > > > On Thu, Aug 21, 2014 at 2:05 AM, Rui Paulo wrote: > > On Aug 20, 2014, at 21:52, Evandro Nunes > wrote: > > > > > On Thu, Aug 21, 2014 at 1:51 AM, Rui Paulo wrote: > > > On Aug 20, 2014, at 21:48, Evandro Nunes > wrote: > > > > > > > hello, > > > > > > > > ive got a ultrasonic sensor model HC-SR04 and a beaglebone black as > well as > > > > a cubieboard2, both running FreeBSD 11 built from crochet and wiki > > > > instructions > > > > > > > > thanks to the help from loos@ I could manage to use a 5v relay with > BBB > > > > now, how can I read data from HC-SR04 sensor? do we have any library > > > > available? or do we have any GPIO utility to do that? > > > > btw how can I read values from GPIO pins when they are set to input? > > > > > > I wrote a library to handle GPIO on FreeBSD: > > > > > > https://bitbucket.org/rpaulo/libgpio > > > > > > very good :-) I will play with that > > > > > > You can also use the gpioctl utility in FreeBSD to read values. > > > > > > how? can you point me to any further reading, blog entry, or examples? > > > > There's a man page, but "gpioctl -c IN" will set the pin in input > mode. Then, "gpioctl " will read the value. > > > > so this way I should read something from HC-SR04 echo pin on BBB? > > I am using another gpio pin in output mode as a trigger, according to > what I've read, 3.3v is OK as a trigger for this sonar > > > > but when I read the GPIO pin in input mode just as you mentioned, I > always get a 0 value... > > I am using BBB's P9_1 and P9_5 for +5v and ground, P9_21 as a trigger > and P9_23 as echo; set GPIO 3 (P9_21) as output and GPIO 49 (P9_23) as input > > I made a loop to read GPIO 49 every 100ms and another loop to trigger > (gpioctl -t 3; sleep .100; gpioctl -t 3) every 2 seconds. > > > > what I am doing wrong? feeding 3.3v for 0.1 seconds as a trigger > should't cause something to echo? > > Don't you have a multimeter? Have you measured the voltage on the output > pin when you switch it to 0 and then back to 1? > no, I don't have a working multimeter, mine is dead. I will buy another one and test it as suggested, yes you are right, although I dont have an idea on what value it should be expected but for curiosity, will gpioctl 49 show values anyhow equivalent to what a multimeter would display? or I should not expect anything similar? sorry for that question if this is too dummy, yes I completely lack on GPIO basics, it's my first experience rss > -- > Rui Paulo > > > >