Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 05:22 20 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Problem with ultrasonic range

     Page 5 of 6    
Author Message
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5923
Posted: 05:15pm 15 Mar 2014
Copy link to clipboard 
Print this post

  WhiteWizzard said   Jim,

I assume your code is only correct when running at default MPU speed. Please confirm as its very early in the morning here and my head is 'battered'.

Thanks . . .

Yes I was going to mention that!
It would still work OK but the distance returned would be out.
The trigger pulse is not upset by speed changes, only my old-fashioned timing loop.
It reminds me of my Z80 days, playing around with NOP's to get the timing just right.

Jim

VK7JH
MMedit   MMBasic Help
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3167
Posted: 05:18pm 15 Mar 2014
Copy link to clipboard 
Print this post

OK Paul (or any any one else with a flaky sensor) could you please try the attached firmware (it is beta 12 for the 28-pin chip). 2014-03-16_031931_Micromite_V4.5B12_28-pin.zip

It closely resembles TassyJim's BASIC code. ie:
- 20 uS trigger pulse
- wait for the echo to go low
- wait for echo to go high
- time the echo

This is a hard way to get the firmware working for all sensors but I cannot think of a better way.

GeoffEdited by Geoffg 2014-03-17
Geoff Graham - http://geoffg.net
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1805
Posted: 05:50pm 15 Mar 2014
Copy link to clipboard 
Print this post

@GEOFF
I got a bit confused, instead of increasing the trigger width I deleted the divide by 1000.
OK I am now using TassyJim's original code and I need a value of 4000uS for it to work. IE in line 5 I need a value of 4000 instead of 10. So I assume my module is at fault. I have two more modules here I will try another one.
Paul.

Edit.
Just tried another module and it is the same, seems these modules I have from DX.com need at least 4mS to operate.Edited by palcal 2014-03-17
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3167
Posted: 07:35pm 15 Mar 2014
Copy link to clipboard 
Print this post

OK Paul, try this version: 2014-03-16_053114_Micromite_V4.5B13_28-pin.zip

In this you can add a third (optional) argument to the DISTANCE() function which is the pulse width in uS. For example:
d = DISTANCE(21, 22, 4000)

Try this and see how you go. Try increasing and/or decreasing the third argument (4000 in the above example) and let me know the minimum value that reliably works.

Thanks,
Geoff
Geoff Graham - http://geoffg.net
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1805
Posted: 07:45pm 15 Mar 2014
Copy link to clipboard 
Print this post

@GEOFF
Loaded version 12 and the module works as before. The program stops with the error when the target gets too close.
I just have dud modules.
Paul.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3167
Posted: 07:53pm 15 Mar 2014
Copy link to clipboard 
Print this post

But you cannot have dud modules if they worked with TassyJim's code.

Have you tried beta 13 with the variable pulse width? It is two posts back.

Geoff
Geoff Graham - http://geoffg.net
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1805
Posted: 08:35pm 15 Mar 2014
Copy link to clipboard 
Print this post

@GEOFF
It works down to a value of 5, with 4 it gives error 'number out of bounds'.
But with any value when the target gets too close it shows a distance of -1 and the error "Transducer not responding"
Paul.

Edit. I don't understand why it works with 5uS with my simple program, but needs 4000uS with TassyJim's code.
Edit. Just tried Jim's code again and it works down to 1500uSEdited by palcal 2014-03-17
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3167
Posted: 09:10pm 15 Mar 2014
Copy link to clipboard 
Print this post

OK, we are on its tail.

Try the attached beta 14. 2014-03-16_071009_Micromite_V4.5B14_28-pin.zip

In it I have disabled the "Transducer not responding" error and instead the function returns -2. But the important thing is that it will not abort your program. Try moving the target very close and then move it out again - hopefully your module will now recover and resume giving you useful data.

I can understand TassyJim's code needing 1500uS - in BASIC you have less control over what is going on.

Hopefully this version will nail it.

Geoff
Geoff Graham - http://geoffg.net
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1805
Posted: 09:30pm 15 Mar 2014
Copy link to clipboard 
Print this post

@GEOFF
OK that's it, it works well. With the target at zero distance it gives -2 then goes back to measuring as I move the target away, until the target is too far then gives -2 again then proceeds to work again.
We used up a few Beta numbers on that one.
The code I used was
Do
x = Distance(22,21)
Print Int(x)" cm."
Pause 100
Loop

Paul.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3167
Posted: 09:50pm 15 Mar 2014
Copy link to clipboard 
Print this post

Brilliant. Thanks for your help.

Geoff
Geoff Graham - http://geoffg.net
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2794
Posted: 09:55pm 15 Mar 2014
Copy link to clipboard 
Print this post

Geoff,

Please can you send out a 44pin version of the latest Beta whenever you are ready.

Have managed to get five hours sleep just now (the most since Beta testing began!) so am ready to try your latest code with my suspected faulty unit (perhaps my UltraSonic module will work again now that it has had a rest for a few hours too)

Thanks . . .

For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
plasma
Guru

Joined: 08/04/2012
Location: Germany
Posts: 437
Posted: 12:42pm 16 Mar 2014
Copy link to clipboard 
Print this post

wow will geoff ever sleep ?
 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 712
Posted: 01:15pm 16 Mar 2014
Copy link to clipboard 
Print this post

Beta 14?????

Last Version Geoff send me per Mail, was V11 from 15.March 2014.

Did i miss something?
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2794
Posted: 01:20pm 16 Mar 2014
Copy link to clipboard 
Print this post

Read the last couple of pages of this topic - We're trying to fix issue with UltraSonic Modules and Geoff been releasing a few Beta's on this matter for pal cal to test.

Will be sent to everyone soon I believe (as in minutes . . .)


For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 815
Posted: 08:50am 17 Mar 2014
Copy link to clipboard 
Print this post

Hi!

My two sensors are looking similar at first sight to Pauls but they are a little bit different!
They work very well with MicroMite Beta 15:

"to near" => -1 (nearer than 2cm!!!) and "no object" => -1!

I am very pleased!!!

Thanks Geoff!!!

Frank
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2794
Posted: 08:59am 17 Mar 2014
Copy link to clipboard 
Print this post

Hi Frank,

If possible can you please post a picture of the front and the back of your module. I will do the same when Im next at home.

This is purely from an interest point of view. Main thing is Beta 15 seems to have fixed anyone who still had issues with the Distance command halting a program with an error.

Thanks

For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
plasma
Guru

Joined: 08/04/2012
Location: Germany
Posts: 437
Posted: 02:14pm 17 Mar 2014
Copy link to clipboard 
Print this post

some interesting things about the modul
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 815
Posted: 09:40am 18 Mar 2014
Copy link to clipboard 
Print this post

Hi White Wizzard,

here are pictures of my modules:







@Plasma: That's really a very interesting site!

Frank
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2794
Posted: 10:10am 18 Mar 2014
Copy link to clipboard 
Print this post

Hey Frank,

That is EXACTLY like mine. Thanks for just saving me the time to take photo's here!

As you say, a very slight difference from palcal's when you look closely at component positions.

At least we all have working programs thanks to Geoff's Beta 15.

I am still waiting for three more cheap HC-SR04s to turn up here. Hopefully they may be different again to these two types and will also work with Beta15.

Will update you again when they arrive. . . .





For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 04:38pm 18 Mar 2014
Copy link to clipboard 
Print this post

I've just gotten around to testing an HC-SR04 module that I bought in Jan last year. I've connected it to Phil's 44 pin board and it works fine using uMite Basic V15. This module also looks exactly like Frank's (and Phil's apparently)- same chips and placement on the rear. I used the same code that Paul tested his with but on pins 2&3 of the 44 pinner.
Do
x = Distance(2,3)
print x
Pause 100
Loop


Everything seems OK, it reads down to 2cm and then in closer just keeps repeating around the 1.7 - 2cm mark. I could get it to read reliably out to 280cm in my lounge room with an 80cm square glass fronted painting for a target, but beyond that it returned -1. There were other chairs walls etc that might have interfered after that distance. The documentation says the transducer angle is 15 deg, so interference was quite likely.

This HC-SR04 was purchased from "dreammacy6com" e-Bay seller 106429, and was delivered Jan. 2013, cost A$2.79, nil postage. I've just checked their site and they no longer have them available - no doubt others do.

There was some 'documentation' (a bit Chinglish) given with the module which I copied from the site at the time of order. It's uploaded in the link below.
2014-03-19_022640_Ultrasonic_module.pdf

GregEdited by paceman 2014-03-20
 
     Page 5 of 6    
Print this page
© JAQ Software 2024