Blazemaguire
Senior Member
Hi,
I am making a simple project to show the kids on my electronics course what can be done with PIC chips and ultrasonics (the SRF04 module - I know its discontinued but I found it lying in a cupboard in my electronics classroom and its all I have!) - In essence its an ultrasonic range finder that displays the distance (under 1 meter) on 2 seven segment displays in real time.
- I have incoporated it into a circuit with an 18X chip linked to 2 4026 decade counters (one decade counter is providing a 'count out every 10th pulse' to count the second decade counter in a chain and by quickly pulsing the 4026's quickly I can get the 7 segments displays to display the range that the ultrasonic sensor is detecting - obviously the decade counters are in fact counting from zero to whatever value is being measured quicker than the eye can see - one of the PICs outputs is also connected to the reset pin of the 4026's to allow resetting of the displayed value when needed.
The ultrasonics and program appear to work, and the range is displayed on the 7 segments as intended, However, it seems to have an annoying intermittent fault that I dont know how to fix.
Even if its completley still, facing a solid wall it will randomly loose its signal every few seconds and then (bearing in mind the time it takes the 4026's to pulse from 0 to whatever measurement) it regains it - you can move it closer and further from the object and the range displayed will adjust accordingly, but it keeps fluctuating and losing its reading. - The strange thing is these 'fluctuations' happen in sync with an audible 'clicking' from the ultrasonic sensor module. - I find this strange as I diddnt think you were supposed to be able to 'hear' ultrasound?! (correct me if i'm wrong however as this is my first time playing with them!)
So.... - it appears to drop its signal in relation to an audible pulsing from the ultrasonics...... - Is there anything I might have done wrong in either my circuit or on the programme to cause this? - Or do I just have a faulty ultrasonic module? - have I missed an important pull up / pull down resistor on one of the input / output connections to the PIC?
I'm afraid i'm not too good with the BASIC language and I do all my programming using PIC logicator flowcharts - I had to teach myself PIC's from scratch when I started my first teaching job and discovered I was teaching GCSE electronics! - hence Logicator was the easiest route in.
Anyhow, included below is the 'code' generated from PIC logicator which i'm well aware is probably not the most efficient it could be..... if it helps.
'Converted on 5/4/2009 at 23:54:08
main:
let b0 = 0 'Expression command
let b1 = 0 'Expression command
label_345: let pins = 0 ' %00000000
label_362: pulsout 0, 2 'Start of Ultra command.
pulsin 1, 1, w6
pause 10
w6 = w6 * 10 / 58
let b0 = b12
if b13 = 0 then label_u362
let b0 = 255 'End of Ultra command.
label_u362:
label_356:
if b1 < b0 then label_360 'Compare command
if b1 = b0 then label_369 'Compare command
let b1 = 0 'Expression command
let pins = 32 ' %00100000
label_369:
if b0 > 99 then label_370 'Compare command
goto label_362
label_370: let pins = 32 ' %00100000
goto label_345
label_360: let b1 = b1 + 1 'Inc command
pulsout 4,1
let pins = 0 ' %00000000
goto label_356
'Notes
'Variables A-H are shown as B0 to B7 in BASIC
Thanks for your time......
Rob
P.S Does anyone have any links to intersting ultrasonics projects they've done or know off that I could also show the kids i'm teaching?
I am making a simple project to show the kids on my electronics course what can be done with PIC chips and ultrasonics (the SRF04 module - I know its discontinued but I found it lying in a cupboard in my electronics classroom and its all I have!) - In essence its an ultrasonic range finder that displays the distance (under 1 meter) on 2 seven segment displays in real time.
- I have incoporated it into a circuit with an 18X chip linked to 2 4026 decade counters (one decade counter is providing a 'count out every 10th pulse' to count the second decade counter in a chain and by quickly pulsing the 4026's quickly I can get the 7 segments displays to display the range that the ultrasonic sensor is detecting - obviously the decade counters are in fact counting from zero to whatever value is being measured quicker than the eye can see - one of the PICs outputs is also connected to the reset pin of the 4026's to allow resetting of the displayed value when needed.
The ultrasonics and program appear to work, and the range is displayed on the 7 segments as intended, However, it seems to have an annoying intermittent fault that I dont know how to fix.
Even if its completley still, facing a solid wall it will randomly loose its signal every few seconds and then (bearing in mind the time it takes the 4026's to pulse from 0 to whatever measurement) it regains it - you can move it closer and further from the object and the range displayed will adjust accordingly, but it keeps fluctuating and losing its reading. - The strange thing is these 'fluctuations' happen in sync with an audible 'clicking' from the ultrasonic sensor module. - I find this strange as I diddnt think you were supposed to be able to 'hear' ultrasound?! (correct me if i'm wrong however as this is my first time playing with them!)
So.... - it appears to drop its signal in relation to an audible pulsing from the ultrasonics...... - Is there anything I might have done wrong in either my circuit or on the programme to cause this? - Or do I just have a faulty ultrasonic module? - have I missed an important pull up / pull down resistor on one of the input / output connections to the PIC?
I'm afraid i'm not too good with the BASIC language and I do all my programming using PIC logicator flowcharts - I had to teach myself PIC's from scratch when I started my first teaching job and discovered I was teaching GCSE electronics! - hence Logicator was the easiest route in.
Anyhow, included below is the 'code' generated from PIC logicator which i'm well aware is probably not the most efficient it could be..... if it helps.
'Converted on 5/4/2009 at 23:54:08
main:
let b0 = 0 'Expression command
let b1 = 0 'Expression command
label_345: let pins = 0 ' %00000000
label_362: pulsout 0, 2 'Start of Ultra command.
pulsin 1, 1, w6
pause 10
w6 = w6 * 10 / 58
let b0 = b12
if b13 = 0 then label_u362
let b0 = 255 'End of Ultra command.
label_u362:
label_356:
if b1 < b0 then label_360 'Compare command
if b1 = b0 then label_369 'Compare command
let b1 = 0 'Expression command
let pins = 32 ' %00100000
label_369:
if b0 > 99 then label_370 'Compare command
goto label_362
label_370: let pins = 32 ' %00100000
goto label_345
label_360: let b1 = b1 + 1 'Inc command
pulsout 4,1
let pins = 0 ' %00000000
goto label_356
'Notes
'Variables A-H are shown as B0 to B7 in BASIC
Thanks for your time......
Rob
P.S Does anyone have any links to intersting ultrasonics projects they've done or know off that I could also show the kids i'm teaching?