PacktPublishing / Learn-Robotics-Programming

Learn Robotics - Fundamentals of Robotics Programming, published by Packt
MIT License
40 stars 14 forks source link

Problem with hcsr04. timed out - missed pulse start #3

Closed Onydus closed 4 years ago

Onydus commented 4 years ago

Danny,

Sorry again for troubling you. Lockdown has me back in for round 2 on the robot. I'm having problems getting the hcsr sensors to work. I believe I've tried everything suggested in the troubleshooting section of the book. I've resorted to copying and pasting the raw code for the associated python files from here to ensure no code errors. I've tried swapping the pin numbers in the code for the trigger and echo. I've scanned over and wired the breadboard numerous times to make sure that isn't the issue. I've even tried replacing the sensors with new ones, to no avail.

Here is the read out I'm getting in the console: hcsr04error

After Ctrl+C: hcsr04error2

Then after swapping the pins: hcsr04error3

Does this give you any indication as to what the problem might be? I'm hoping it's something simple I've overlooked with my noobishness.

Thanks again, Rowan

Progress so far: robot

dannystaple commented 4 years ago

Hello Onydus, First I want to say I love the way your robot looks - are you aiming for an R2 type thing? Is that 3d printed panels?

Ok lets talk about the HCSR04. Your wiring will be important here - could you show me how you have wired the Raspberry Pi, to the Level shifters, to the HC-SR04, including the power connections involved?

A photo, or sketch diagram with pin numbers will help.

At the moment, I don’t suspect the code yet, but we can check after.

Danny

On 13 Jun 2020, at 22:05, Onydus notifications@github.com wrote:

Danny,

Sorry again for troubling you. Lockdown has me back in for round 2 on the robot. I'm having problems getting the hcsr sensors to work. I believe I've tried everything suggested in the troubleshooting section of the book. I've resorted to copying and pasting the raw code for the associated python files from here to ensure no code errors. I've tried swapping the pin numbers in the code for the trigger and echo. I'm scanned over and wired the breadboard numerous times to make sure that isn't the issue. I've even tried replacing the sensors with new ones, to no avail.

Here is the read out I'm getting in the console: https://user-images.githubusercontent.com/57407114/84578787-a0bc9780-adc8-11ea-884d-6b5ca36b4154.png After Ctrl+C: https://user-images.githubusercontent.com/57407114/84578793-af0ab380-adc8-11ea-96c4-5b7333eb709a.png Then after swapping the pins: https://user-images.githubusercontent.com/57407114/84578818-ec6f4100-adc8-11ea-99a3-ddff5440d79f.png Does this give you any indication as to what the problem might be? I'm hoping it's something simple I've overlooked with my noobishness.

Thanks again, Rowan

Progress so far: https://user-images.githubusercontent.com/57407114/84578958-2856d600-adca-11ea-9871-8b3388ba7a90.jpg — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/PacktPublishing/Learn-Robotics-Programming/issues/3, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADIG2YV3UZK7BRURM6ORQTRWPSY3ANCNFSM4N5ESS2Q.

Onydus commented 4 years ago

Danny,

Thank you! Yeah, pretty much going for the astromech type droid design! Yes, I've done as much in 3d print as possible. I've learned a fair deal during all this haha. The chassis are based off the one recommended in your book but I've made them round. I really like the look of stacked robots. The domed head took 27 hours to print!

Ok, so here's my board layout: hcsr04boardlayout

I've completed the LEDs section of the book and they work fine.

Kind regards, Onydus

dannystaple commented 4 years ago

Hi Onydus, That is awesome. I should try too be a bit more ambitious with my case designs - my longest 3D print so far was 8 hours. What have you used for the frame parts there? Metal rod?

Are those level shifters Bidirectional? That is important for the HC-SR04. The LED’s communication is only 1 way. The return channel might not be right on these. Some level shifters have an on board regulator for the 3v3 side. Those pictured d not, in which case you will need a wire from the LV (3v3) rail of the breadboard to the LV supply pin on each of the level shifters.

Thanks, Danny

On 14 Jun 2020, at 11:28, Onydus notifications@github.com wrote:

Danny,

Thank you! Yeah, pretty much going for the astromech type droid design! Yes, I've done as much in 3d print as possible. I've learned a fair deal during all this haha. The chassis are based off the one recommended in your book but I've made them round. I really like the look of stacked robots. The domed head took 27 hours to print!

Ok, so here's my board layout: https://user-images.githubusercontent.com/57407114/84590820-11e86300-ae3a-11ea-9cd6-e9e0933851a4.png I've completed the LEDs section of the book and they work fine.

Kind regards, Onydus

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/PacktPublishing/Learn-Robotics-Programming/issues/3#issuecomment-643747576, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADIG2ZINAYQWTY5IAXMT23RWSQ4JANCNFSM4N5ESS2Q.

Onydus commented 4 years ago

Hello Danny, Thanks again. Go for it, dude. It's definitely the longest print I've ever done by far! Anxiety was high after the halfway point! Such a big investment in time for it all the go wrong! I could ramble on about how great 3d printers are for ages though! I've definitely caught the robotics bug now though thanks to your book! The frame posts are made from lots of standoffs screwed together so I can adjust the heights if required. They work pretty well and are sturdy.

The level shifters I am using are described as "2 Channel Logic Level Converter 3.3V to 5V TTL Bi-directional Module For Arduino".

Pictured below: levelshifter thumbnail_IMG_20200614_150504 thumbnail_IMG_20200614_145915

I really appreciate the help, Onydus

dannystaple commented 4 years ago

Hi Onydus, Let me know if the extra wire helps. It should do the trick.

I’ve 3d printed a number of brackets and shims to bolt stuff together in Piwars robots, with my most ambitious being the 2019 robot - https://orionrobots.co.uk/2019/02/13/piwars-cad-files.html.

Have you had any centre of mass/toppling issues? I had those with my 2018 piwars robot on slopes, and opted to move the batteries as low as I could on subsequent designs.

Danny

On 14 Jun 2020, at 15:44, Onydus notifications@github.com wrote:

Hello Danny, Thanks again. Go for it, dude. It's definitely the longest print I've ever done by far! Anxiety was high after the halfway point! Such a big investment in time for it all the go wrong! I could ramble on about how great 3d printers are for ages though! I've definitely caught the robotics bug now though thanks to your book! The frame posts are made from lots of standoffs screwed together so I can adjust the heights if required. They work pretty well and are sturdy.

The level shifters I am using are described as "2 Channel Logic Level Converter 3.3V to 5V TTL Bi-directional Module For Arduino".

Pictured below: https://user-images.githubusercontent.com/57407114/84595875-a9f64480-ae5a-11ea-8921-d3c24ad176b2.png https://user-images.githubusercontent.com/57407114/84595892-c2665f00-ae5a-11ea-9481-792c047443a9.jpg https://user-images.githubusercontent.com/57407114/84595894-c4c8b900-ae5a-11ea-9b33-172f69242290.jpg I really appreciate the help, Onydus

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/PacktPublishing/Learn-Robotics-Programming/issues/3#issuecomment-643776337, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADIG23OTCH4DROF4V7JBVDRWTO57ANCNFSM4N5ESS2Q.

Onydus commented 4 years ago

Danny,

It worked! Such a big relief! It's been driving me nuts for a long time! Thank you very much, sir.

hcsr04working

Nice! I had a good laugh picturing your robot's guts sliding out it's back end during it's ascent! I can only imagine your reaction! Great article. I can relate with the tedium of recreating a CAD file from an existing object. The transparent default kit chassis being my own experience. I will have to look further into Piwars as I've never heard of it!

Not yet, fortunately. Although I haven't attempted any climbs yet! I've got all the heavy stuff at the bottom to try and mitigate this. The head is quite weighty though so we'll see. I only converted it all from the robot design in your book to this during this last week!

Thanks again for the help. I really appreciate you taking the time to look into my problem. I have lots of ideas regarding future robots and am looking forward to learning more. I will definitely be more careful in selecting component suppliers in future.

Kind regards, Onydus

dannystaple commented 4 years ago

Wow - that looks great for 1 week! Piwars is rather brilliant, it's a community of Raspberry Pi robot enthusiasts building robots to take on competitions. There's a robot building discord channel, lively twitter community. https://www.youtube.com/watch?v=tXETOq2gd6Y&feature=youtu.be for a video taste, and https://piwars.org.