Senscomp transducer

rkim01

Member
Hi, I was trying to use Senscomp modules and transducer
http://www.senscomp.com/specs/6500%20module%20spec.pdf
http://www.senscomp.com/specs/600%20instrument%20spec.pdf

with simple code

symbol trigger = 4 'output

symbol echo = 3 'input

symbol range = w1

symbol trigger_low = %00000000

main:
let pins = trigger_low
pause 10
pulsout trigger,2
pulsin echo,1,range
pause 10
let w1 = w1 *10/62
debug w1
pause 50

goto main

but i couldn't get it to work. It is not picking up any ojbects. i checked all lines and they were fine and my code looks right.
Is there anything that i am missing?
i'm just using 08M.
this should work just as a normal sonar....


Edited by - rkim01 on 31/07/2006 14:28:48

Edited by - rkim01 on 31/07/2006 14:30:07
 
Their timing diagram shows "INIT" held high for the entire duration. That is, INCLUDING whilst the echo comes back. Try putting the line high instead of just a pulsout,2.
 
thanks.
I have tried putting simple line
high 4
just before pulsout
was that what you meant? cos i tried but it didn't work. i didn't add pause functio though.
or is there any other way that i can test the sonar is working?
Sorry i'm just a beginner..
 
I haven't played with sonar for 20 years. The technology has changed at lot!

I remember there was a faint ticking sound that came from the Tx transducer when it transmitted the pulse chain. Best checked in a repetative test (Eg 4 echoes a second: you may hear a tick, tick, tick).

You may be able to poke around with a logic probe if you have one: it should pick up, extend and show the digital pulsing. Logic probes are fairly cheap.

These methods may help you determine if the transmitter is working. The logic probe may help diagnose things on the receiver end too.
 
From what I can gather, you should not pulse the line. Simply put it high and then wait for the echo. I guess this is to keep the 200v (ouch!) active on the receiver.
Once the echo is received or after a time out period, drop the line and start again.
To be honest, the sheet is not very informative. Might be worth trying google to find more info or better still an application that uses this interface.
Personally, I'd stick with the more traditional US sensors. Electrostatic sensors are very fussy and the 400v (bigger ouch!) required to drive them can play all sorts of havoc with nearby electronics.
As suggested by c930174, it might be worth going to a very quiet area and see if you can at least hear the "clicks" each time it is activated.

Actually, it would be very easy to test if it is active. I've just noticed that it pulls a whopping 2A during transmit!
Also note that all outputs are open collector, you will need pullup resistors on them.



Edited by - beaniebots on 01/08/2006 08:27:33
 
this is a program that deals with basic stamp for this sonar. I have no idea about basic stamp and if this is any help of understanding or maybe someone can interpret this to suit picaxe?


' POLAROID RANGER TEST PROGRAM
' 6-30-2000

'--------------------------------------------------------
' variable declarations

dist var word ' working variable for distance calculation


'--------------------------------------------------------
' constant declarations

ECHO con 15 ' sonar module echo detection output
INIT con 14 ' sonar module control input
' 1 starts a measurement
' 0 resets the module

settle con 1 ' delay to ensure proper initialization
delay con 20 ' time between sonar samples

' CONVERSION FACTORS
'
' The RCTIME command returns the round-trip echo time in 2us units
' which is equivalent to the one-way trip time in 1us units.
'
' Taking sonar samples in rapid succession may occasionally cause
' a false measurement. A delay between starting a sonar reading
' and measuring the time to receive an echo helps prevent this
' problem. Because of this delay, the distance calculation
' must include an offset.
'
' distance = (echo time + offset time) / (conversion factor)
'
' use 74 for inches (73.746us per 1 in)
' use 29 for centimeters (29.033us per 1 cm)

convfac con 74 ' use inches
offset con 700 ' (determined experimentally)



'--------------------------------
' main loop

loop:
gosub sr_sonar
debug dec dist,cr
pause delay
goto loop

sr_sonar:

high INIT
pause settle ' be certain that ECHO is low
rctime ECHO,0,dist ' wait for ECHO to go high
low INIT ' reset module

dist=(dist+offset)/convfac

return
 
2 Amps! That's serious current around a PICAXE. Is your power supply up to the task? While you won't need 2A continuous from the supply, it will need a fairly big capacitor.

The dip in the supply rail may be resetting the PICAXE so that it never completes the loop (code).

An option would be to put a diode in series with the PICAXE V+ leg. Connect a capacitor (say 220uF) across the PICAXE V+ to V- to keep its supply stable during the pulse surge.
 
The PICAXE code would be almost identical.
(as I suggested earlier after looking at the timing diagram)

High 'control pin'
pause 'not too sure how long, try 2'
pulsin inputpin,variable
low 'control pin'

test 'variable' for valid echo value or timeout
go back and do it again.
might be a good idea to check that the output is low.

The device draws a SIGNIFICANT current when it is active. This is because it is generating the 400v drive voltage from the 5v supply. The current will also be quite high whilst waiting for the echo because the receiver is driven at 200v. Your power supply needs to be very robust to cope with these demands. Layout and shielding will also be important.
This is not really a sensor for the beginner. You would have been much better off with the more common/usual SR004 or similar. Anyway, you've got what you've got so let's make it work.
 
Thanks for your feedback. I am going to try the capacitor and see what happens. Hope that solves the problem. currently, it is not in working condition so gotta try more :(
 
beaniebots

Also note that all outputs are open collector, you will need pullup resistors on them.

what do you mean by pullup resistors? what kind of resistor do i need and where?


c930174

An option would be to put a diode in series with the PICAXE V+ leg.

A diode? any diode? Coudl you explain why I need diode? Is it to prevent much current going through?
 
The transducers are likely to cause the supply rail voltage to drop when they draw the heavy currents mentioned previously.

The capacitor and diode are to stabilise the supply voltage applied to the PICAXE. The diode prevents the capacitor discharging back to V+ rail should the V+ voltage go below that of the capacitor. This allows the PICAXE to have a stable supply voltage, minimising the chance of instability or being reset.

Almost any diode will do provided it can handle the current required by the PICAXE. 1N400x (1A) or you may even get away with something like a 1N914 (75mA).

Eg. <code><pre><font size=2 face='Courier'>
+V-----------------+----------------------+
| |
_|_ |
1N4002 \ / |
--- |
| ( )
| ( Ultrasonic )
______________| ( Transducers)
| | ( etc )
| _____+_____ ( )
| | +----&gt;-----( )
+ | | PICAXE | ( )
===== | +----&lt;-----( )
----- | | ( )
| |___________| ( )
| | |
| | |
| | |
| | |
GND--+--------------+-----------------------+
</font></pre></code>
 
The outputs can only sink current. They cannot source current. When the output is &quot;on&quot;, it will pull the line down to 0v. When the output is &quot;off&quot;, it will look like an open circuit and hence your PICAXE input will be floating. This will lead to undefined states. It must be wired as if it were a push button that pulls down to 0v. For the input to ever see a high, you must fit a pull-up resistor. 10k should be OK but the datasheet probably suggests a better value.
c930174's suggested capacitor and diode will prevent the PICAXE from crashing during a power rail collapse but the device itself may still have problems. The current peak is not a short duration spike. It pulls that current the whole time the device is active. Your power supply MUST be able to cope with that for reliable opperation.
 
Thanks.
I forgot to buy a diode!!
Just realised that i am using two different power supply for picaxe and the transducer.
Does it still drain the power from picaxe while it's working?
 
Then i don't need to worry about capacitor and diode? Well I have already setup capacitor anyway so should be ok.
For now the problem is the programming...
try my best!
 
I have not closely studied the datasheets for the tranducers that you are using but there are some basic practical concepts that need to be understood when working with sonar.

At sea level, sound (even ultrasonic sound) travels at about 320 metres per second. If we take an extreme case, this means that a 1-second pulse from the transmitter will be 320 metres 'long'. A 10 mS pulse will be 3.2 metres long.

The echo from a close object will be stronger than that from a distant object. I understand that the receiver gain in the modules you are using can be controlled so that the receiver is least sensitive immediately after the pulse is sent. The receiver gain is increased as time passes, to compensate for the extra losses.

The receiver also needs to be disabled (or ignored) during the pulse transmission phase so that it does not trigger on the transmitted (outgoing) ultrasound pulse. Once the pulse has finished, the receiver needs to be enabled so that it can start 'listening' for echoes.

What does all this mean? When you get to testing your setup, make sure that the test echo surface is sufficiently far away so that an echo is not masked by the receiver being disabled.

Using my example above, if the pulse is 10mS in duration, you will not be able to detect a object less than 1.6 metres away (echo must travel 2 x 1.6m = 3.2m). I don't know how long or short you want the transmitted pulse to be: the shorter it is, the closer you can detect objects. Conversely, the longer the pulse is, the more energy is transmitted, allowing detection of more distant objects.

With clever design with a PICAXE you can get the best of both worlds by varying the ultrasound pulse length and receiver blanking period.

Let us know how you progress.

Edited by - inglewoodpete on 09/08/2006 08:26:21
 
I have tried, tried and tried.....for last two days. no good luck what so ever...
I will start one by one so if you think something is wrong, please let me know. I'm running out of time and getting very frustrated. So thanks in advance for any help. I mean a lot.

The setup
PICAXE is 08M and getting 4.5V from battery with 100mF capacitor so no problem with power.
pin 3 is input and pin 1 is output
Currently output is set to high all the time.

Sensor gets 4.8V separate power and have 1000mF capacitor between + and -ve of their pin to draw whopping 2A.
The INIT gets input from PICAXE pin 1.

With the right program, it should pick up the echo and some kind of debugging number should show up. Below is my code.

symbol INIT = 1 'output
symbol echo = 3 'input
symbol range = w1
symbol lowAll = %00000000

main:
let pins = lowAll 'Initialise all
pause 10 'minimum 5mS for sensor to reset all
gosub sonar
end

sonar:
high INIT 'INIT is high according to datasheet
pulsin echo,1,range 'get the pulse
low INIT 'to get echo, INIT sets to low? from datasheet
let w1 = w1 *10/62
debug w1
'if w1 &gt; 0 then high 4 'I tried this line but some reason it gives me with error 'mistake in this line'
'The if then function does not work. ???
goto sonar

Here is what I don't understand.
1. In the datasheet it says, it sends 16 pulses at 49.4kHz. Is there anything to do with PICAXE 40MHz? Or do I need to convert the signal that I got from sensor? How PICAXE receives pulse?

2.How do I check if INIT is high, output occurs?

3. What is it mean by recycle period 80mS in the datasheet? Does it mean I need to wait at the end of getting echo?

4. when I run, I get something like 174 on b2 when the sensor is not connected. If sensor is connected there is no reading.

What am I doing wrong or missing?


Another link to try for better understanding.

http://rkim01.mireene.com/senscomp6500appnote.pdf

http://rkim01.mireene.com/2004-86500andtransducerconnections.pdf

Edited by - rkim01 on 09/08/2006 13:29:41
 
btw who sells the SRF08 or SRF10?
I might get them since they will use same code as SRF04.
It must be heaps easier!!
 
The SRF08 is sold by &quot;TotalRobots&quot; amoungst others.
It is TOTALLY DIFFERENT to the SRF04 and will use completely different code.
It is controlled by I2C commands.

I will have a look at the links you posted later and get back to you.
 
The app note explains it quite clearly.
Make INIT high.
wait a few milliseconds during blanking
wait for and measure echo
drop INIT line
wait 80mS
repeat.

All the tricky bits are done by the module, you do not need to worry about the 16 pulses and/or the 40kHz.

It is very similar to using an SRF04 except that the &quot;start&quot; signal must remain high during the listening phase.

The compiler is complaining about your IF/Then line because &quot;then&quot; must be followed by an address. You have a command.

As mentioned earlier, don't forget that the module outputs are open collector and MUST have pull-up resistors fitted.
Also don't forget that when using seperate power supplies, the 0v of each supply must be connected together.

try this:-

symbol INIT = 1 'output
symbol echo = 3 'input
symbol range = w1

main:
low INIT
pause 85
high INIT
pause 2
pulsin ECHO,1,range
debug
goto main

might also be worth trying the line &quot;pulsin ECHO,0,range&quot; if it still does not work.

Edited by - beaniebots on 09/08/2006 15:02:50
 
Two things to note ...

You are using Pin 1 as an output, by default Pin 1 on an 08/08M is an input and only becomes an output when you issue the HIGH to set the INIT. It may be advisable to issue a LOW on the INIT as soon as the program starts, so the sensor is guaranteed to have INIT low before the HIGH is issued later.

More importantly, according to http://rkim01.mireene.com/senscomp6500appnote.pdf, it says that by using the time between INIT and ECHO the distance can be calculated. The code you have doesn't measure the time between INIT and ECHO, but measures the length of the ECHO pulse which is likely to be something else entirely.

This is an issue pertinent to other sonar sensors and more details will be found in a Forum Search.

I believe BeanieBots was misled by what the Basic Stamp 2 code does and thus didn't spot this earlier. Deserving of a self-inflicted D'oh! moment but no more than that.

The BS2's RCTIME command measures the time from when the command starts executing to when the pulse arives, for which there is no directly equivalent PICAXE command, and unlikely to be any alternative coding which gives the uS accuracy you would require.

Unless you want to get involved in designing hardware which can delay the INIT pulse and provide a return pulse where its length is proportional to distance for this sensor, it would probably be easier and quicker to use an alternative sensor which supports the PICAXE.

The additional hardware is another nuisance rather than difficult, and it could be created using just another 08/08M and a 74HC00. This issue seems to crop up repeatedly and I can produce a posting showing how this could be done if people are interested ?
 
Quite right Hippy. D'oh!
Not helped by too much thinking along the lines of the SRF04 mechanism and not printing the datasheet prior to posting.
So, in conclusion, extra hardware will be required. I beleive one of Jeremy's threads came up with a simple solution to this issue recently.

Get an SFR08, they really are good and simple to use.
Never had one not work first time with either a PICAXE or an OOpic.
 
If you do consider using a different sensor, please note that the SRF04 (sold by tech supplies) will work with the 08M PICAXE. However, if you want to use the better SRF08, then you will need to use an X range PICAXE because the interface is I2C.
For an example of using the SRF08 with a 28X, have a look here.
http://www.robot-electronics.co.uk/htm/srf08axe.htm
 
its ok beaniebots. You still helped me a lot. Thanks.

Ah.... so my luck has elapsed with this sensor.............? :(
Or still there is a solution with additional device? i really want to make this work otherwise i will waste much money and importantly valuable time... it's not helping me much... sadly..
From hippy's posting, i guess first point can be fixed. for second, i was only trying to get it work so the program was not in great detail. If it detects an object and value is something like 200, then i will use it as a threshold to do something like light LED.
So all I need is quite rough measurement of distance. But there is no such a command in PICAXE?
Please hippy. Let your knowledge be the saviour :)

I might get SRF08.. soon after I get stuck again.
What's the difference between SRF08 and SRF10? I can only find SRF10 is being smaller and SRF08 has LDR and all others are identical right?
Also does it work relatively well in outdoor condition with wind and etc?


Edited by - rkim01 on 10/08/2006 04:29:22
 
I'me sure now that the requirements of what the code needs to do are fully understood, somebody will come up with a solution. A thought I was having goes like this.

Count=0
High INIT
pause 2
Inc_Count:
Count=Count+1
If PinECHO=Low then Inc_Count

This would only give a resolution of about 500uS which is no good and could even miss the the echo pulse but with overclocking there might be some mileage. Need to do the sums to be sure.
The hardware solution should not be too complex to implement. A second 08M probably being the easiest option.

As far as I can tell, the difference between SRF08 and SRF10 is as you describe. I've never used the SRF10 so cannot comment further. Also, I've never tried the SRF08 in an outdoor situation. Saying that, it is one of the best modules on the market so if it does suffer badly, then so will any other US module.

Edited by - beaniebots on 10/08/2006 08:03:23
 
The problem is how to measure the time between INIT going high and the echo comming back. The PICAXE does not have a command which can do timing that is initiated to start the timer under software control.
The pulsin command requires both a leading and a trailing edge.
Hence, one option might be to use one 08M to control the signals and another one to do the timing.

By using the software method I described in my previous post, doing the sums (assuming I got them right) I calculate that you should get a resolution of about 100mm in round numbers.
Overclocking would improve on that figure.
 
This is one way I'd consider doing it. PULSE is there for other types of sensors which just need an initiating pulse to start the sensor going. You'd have to tweak logic levels and timings to match the sensor being used. This is just an example of doing it, and isn't tested. E&amp;OE.<code><pre><font size=2 face='Courier'> .---------.
TRIGGER --&gt;| I3 O0 |---&gt; INIT ------------&gt; INIT
| O1 |---&gt; PULSE
| O2 |- BLANK
| O4 |--. VALID
`---------' |
.---. |
/ |-----'
SIGNAL &lt;----( &amp; | /|
\ |&lt;-----------O&lt; |--------&lt; ECHO
`---' \| </font></pre></code> <code><pre><font size=2 face='Courier'> ___________________________
TRIGGER ___| |___
______________________
INIT ________| |___
_
PULSE ________| |________________________
___
BLANK __________| |____________________
________________
VALID ______________| |___
_____
ECHO __________|||___________| |____
_________
SIGNAL ______________| |__________ </font></pre></code> Code on the Master PICAXE ... <code><pre><font size=2 face='Courier'> HIGH TRIGGER
PULSIN SIGNAL,1,w0
LOW TRIGGER </font></pre></code> Code on the Slave PICAXE ... <code><pre><font size=2 face='Courier'>Init:
pins = 0
OUTPUT 1
OUTPUT 2
OUTPUT 3
MainLoop:
IF pin3 &lt;&gt; 0 THEN MainLoop
pins = 0
WaitForTrigger:
IF pin3 &lt;&gt; 1 THEN WaitForTrigger
PAUSE 1
pins = %00011 ; Set PULSE and INIT
LOW 1 ; Clear PULSE
PULSOUT 2,100 ; Pulse BLANK ( tweak as necesary )
HIGH 4 ; Set VALID
GOTO MainLoop </font></pre></code>

Edited by - hippy on 10/08/2006 15:10:38
 
ok many thanks.
i'm going to go shopping for another 08M and gonna try out and let you know.
I still don't quite understand why i need master and slave picaxe but well gonna figure out. thanks hippy
 
The problem is that you need to measure the time from between the rising edge of INIT to the rising edge of ECHO and use that to determine the distance ...<code><pre><font size=2 face='Courier'> _________________________
INIT ________| |__
_____
ECHO ____________________________| |___ </font></pre></code> <code><pre><font size=2 face='Courier'>
|&lt;-----------------&gt;| </font></pre></code> The PICAXE doesn't provide any means to measure a time to a rising edge with the uS resolution required to determine distance accurately, but by triggering external hardware which delays the issuing of INIT and creates a SIGNAL which is a pulse of the same length as the time between the two rising edges you get something which can be read by the PULSIN command. The delay in issuing INIT gives the PICAXE time to complete the command which triggers it and be executing PULSIN so the pulse isn't missed ...<code><pre><font size=2 face='Courier'> ______________________________
TRIGGER ___| |__
_________________________
INIT ________| |__
_____
ECHO ____________________________| |___
___________________
SIGNAL ________| |_________ </font></pre></code> <code><pre><font size=2 face='Courier'> |&lt;-----------------&gt;| </font></pre></code>
 
I think you should still pursue your orininal sensor for the sake of an extra 08M, however, as it was asked in this thread, here are some results using SFR08 outdoors on a windy day.

Code used on AXE110 (data logger) with AXE033 fitted in serial mode.
Power supply 4XNiMh @ 5.3v

main:
i2cslave &amp;E0,i2cfast,i2cbyte
writei2c,1,(23) 'reduce gain (this value is specific to each SRF08 for best results
loop:
writei2c,0,(81) 'general broadcast to trigger
waitforreply:
readi2c 0,(b0) 'dummy read of firmware revision
if b0=255 then waitforreply 'loop until ready
readi2c 2,(b1,b0) '1st echo
readi2c 4,(b3,b2) '2nd echo
readi2c 6,(b5,b4) '3rd echo
serout 6,N2400,(254,128,#w0,&quot; &quot;,#w1,&quot; &quot;,#w2,&quot; &quot;)
pause 100 'not required but makes display easier to read.
goto loop

by tweaking the gain value, I could get this to reliably detect a brick wall from 11m. The SRF08 did need to be at least 2m from the ground to prevent spurious reflections. Reducing the gain to 18 reduced the unwanted reflections but also reduced the reliabale detection range to about 6m.
I tried 3 different units and all gave similar results but required different gain settings. Two of the units gave false readings at over 2m using the default gain setting of 31. All worked well up to 2m even at the lowest setting.
None showed any significant change when the wind was quite strong. Posiibly a slight reduction in the maximum range but no noticeable change in readings. Slightly higher false triggers but easily cured by dropping gain a little further.
I did not do any tests in the rain or with other supply voltages.
 
Thanks hippy. I have some questions to ask.
From your diagrams and codes, master PICAXE triggers slave PICAXE on input 3 and output 0 sends INIT to the sensor. Is output 1 pulse only for other sensors so i dont need to worry right? Output 2 is not in use. Output 4 gives out value which will the go to AND gate with NOT gate ECHO. the final signal will go to Master PICAXE.
Have I understood right?
 
Back
Top