Tagged: Ultra sonic distance sensor
- This topic has 8 replies, 6 voices, and was last updated 4 years, 12 months ago by
Dr_Alex.
-
AuthorPosts
-
February 16, 2017 at 10:23 am #4195
Sian
ParticipantI would like any advice on how to programme the distance sensor…. I am trying to programme the motors to stop if they are 5 cm from any object!! HELP
February 19, 2017 at 4:04 pm #4198Chris
ParticipantAre you using the most current version of crumble software?
February 22, 2017 at 4:57 pm #4209Mike
ParticipantHave you tried something like this?
(I assume you know how to connect the sensor)
🙂
Attachments:
February 16, 2018 at 4:06 pm #6702MrShaunL
ParticipantI’m having an issue with the distance sensor too.
My issue is that when I try to run 2 motors simultaneously, the distance sensor reading drops down to 0. So my program to make the buggy turn when it gets close to a wall triggers a turn constantly.
I know my wiring is correct and my code is correct, as I have tested everything. Disconnecting power to one of the motors gives me accurate distance sensor readings but as soon as both are running, the distance sensor fails again.
It might be that my motors are drawing too much power (I’m using modern medium sized lego technic motors at the moment ) – when I can obtain some other motors I may try again.
At the moment a crude work-around is to have the buggy stop and re-check the distance whilst stationary, but it makes for very juddery progress…
February 19, 2018 at 11:39 am #6711Daniel
ModeratorHi MrShaunL,
Thank you getting in contact with us.
Is the value of the ultrasonic distance sensor erratic or does it just drop to zero when the motors are running? You could try running the motors at a lower speed % or, if you haven’t already, try connecting the distance sensor’s power directly to the batteries.
If you do suffer from erratic values, you can try averaging them out – so take 10 samples a second, add them up and then divide the result by 10. You could then adapt this depending on how sensitive you need it to be.
I hope this answers your question. Any more problems, please don’t hesitate to ask.
Kind regards,
Dan
February 19, 2018 at 7:50 pm #6717MrShaunL
ParticipantIt drops straight to zero, whenever both motors are running.
The Sensor is already connected directly to the battery pack, as per the recommended wiring.
I think my probably solution (if I want to keep using the lego motors) is to attach a second (possibly smaller) battery pack just to the sensor.
When I get these for my class I will be using the motors from your site, mot lego,so hopefully that will avoid the issue entirely.
February 19, 2018 at 7:53 pm #6718MrShaunL
Participant(And just because – here is the robot himself 🙂 A friend says he looks like a prototype Wall-E 🙂
Attachments:
February 20, 2018 at 9:09 am #6721Daniel
ModeratorHi MrShaunL,
It does sound like the motors are drawing too much power then. The second battery pack could help solve this.
If you were still looking to create tracked vehicles, we do sell tracks and the relevant wheels for the gearboxes on our partner site https://mindsetsonline.co.uk/shop/caterpillar-track/
He definitely does look like a prototype Wall-E, fantastic!
Kind regards,
Dan
December 5, 2018 at 9:39 am #8324Dr_Alex
ParticipantThe distance sensor needs a good 5V supply to work reliably. I no longer use the 4.5V Crumble battery pack, it’s not reliable enough with the distance sensor, especially if driving motors at the same time.
I use a Poundland, £1 lithium battery pack and hack the USB cable by removing the micro USB plug and putting crocks on instead. Works great. Two can be connected in parallel if you need more current.
-
AuthorPosts
- You must be logged in to reply to this topic.