Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Aug 2014 00:43:45 -0300
From:      Evandro Nunes <evandronunes12@gmail.com>
To:        Rui Paulo <rpaulo@felyko.com>, freebsd-arm@freebsd.org
Subject:   Re: HC-SR04 and FreeBSD
Message-ID:  <CAG4HiT4EbX=Lar_o8YZc5B51Yao1-B=Ebck0vQajyzoZwesWwQ@mail.gmail.com>
In-Reply-To: <EA5A973C-960A-4B0F-A690-8AA9BF66244A@felyko.com>
References:  <CAG4HiT6wwbmSA_KWsgHOqdeZVOCUsdhRxDhMubvkG1tEwVH5Sw@mail.gmail.com> <5D802942-2D0F-4324-8212-C2871EEB6327@FreeBSD.org> <CAG4HiT6fiqVXMoqcJra1Yh8aFVbOcezP8rRqst6WC8aHuaF_rA@mail.gmail.com> <01562FB1-32C6-45AF-AB77-5BB80526E18C@FreeBSD.org> <CAG4HiT4kKz18iauXfuF0Dpv-USghunssUvwkTF7bDx_gE_VS2w@mail.gmail.com> <CCD5AEE5-798D-4EAC-BAE7-A086DE55B5D2@FreeBSD.org> <CAG4HiT6YUBCxXrK_KyRW6zTthPa-wDe=A9=CmMHQf-Gh54s7QA@mail.gmail.com> <EA5A973C-960A-4B0F-A690-8AA9BF66244A@felyko.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Aug 21, 2014 at 4:13 PM, Rui Paulo <rpaulo@felyko.com> wrote:

> You can use an led instead of a multimeter. The point I'm trying to make
> is to make sure the gpio number really corresponds to that port number.
>

still no success, but just an update...

ok I added two led:

pin 02:    0    gpio_2<IN>  ===> echo (orange LED)
pin 03:    0    gpio_3<OUT> ===> trigger (blue LED)
pin 49:    0    gpio_49<IN> ===> previous echo

and I have the two simple loops below.

when I run loop1, BLUE LED blinks every second;
when I run loop2 while loop1 stills run, ORANGE LED won't blink, and loop2
value still shows 0 value

if I "gpioctl -c 2 OUT ; gpioctl -t 2", ORANGE LED will light, confirming
LED is OK; thoses leds will light with 2-5v input... however I have no idea
if the sonar output will range 2-5 or if it will be below 2 (i tried adding
my hand very close and far away from the sensor but led was never lit)

so I'd better use a multimeter for sure...

loop1:
while true ; do
 gpioctl -t 3; sleep .200; gpioctl -t 3
 #gpioctl 3
 sleep 1
done

loop2:
while true ; do
 gpioctl 2
 sleep .500
done










>
> --
> Rui Paulo
>
> On 21 Aug 2014, at 11:44, Evandro Nunes <evandronunes12@gmail.com> wrote:
>
> On Thu, Aug 21, 2014 at 1:24 PM, Rui Paulo <rpaulo@freebsd.org> wrote:
>
>> On Aug 20, 2014, at 22:34, Evandro Nunes <evandronunes12@gmail.com>
>> wrote:
>>
>> > On Thu, Aug 21, 2014 at 2:05 AM, Rui Paulo <rpaulo@freebsd.org> wrote:
>> > On Aug 20, 2014, at 21:52, Evandro Nunes <evandronunes12@gmail.com>
>> wrote:
>> >
>> > > On Thu, Aug 21, 2014 at 1:51 AM, Rui Paulo <rpaulo@freebsd.org>
>> wrote:
>> > > On Aug 20, 2014, at 21:48, Evandro Nunes <evandronunes12@gmail.com>
>> 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 <PIN> IN" will set the pin in input
>> mode.  Then, "gpioctl <PIN>" 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
>>
>>
>>
>>
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG4HiT4EbX=Lar_o8YZc5B51Yao1-B=Ebck0vQajyzoZwesWwQ>