Problem using the GoPiGo port A1 and straight driving


#1

Hello,

I have a couples of problems with the GoPiGo, and I didn’t find any answers on the forum.

I’m using the Raspberry B+, but as I understand this shouldn’t be a problem.

First, even after the 1.3 update, the GoPiGo doesn’t drive forward straight, but it can go backwards straight without any problems.

And secondly, I can’t make the US sensor test programs to work. I use a HC-SR04 as a US sensor, pretty much the same as the one used in the tutorial as far as I can tell.
I checked the voltage of the pins of the A1 port directly with an oscilloscope, and there is no activity of any sort on 3 of the four pins. For the ground pin it is normal, for the other 2, I can’t see any commands of any kind (logic level is always 0). The Vcc pin is at a constant +5v.

The US sensor is working just fine, I tested it with the PI on its one, imprecise but working.

Any ideas?

Thanks


#2

Hey Rob

I’m using the Raspberry B+, but as I understand this shouldn’t be a problem.
That's right, it should not make a difference. The B+ is superior, it offers better power management.
First, even after the 1.3 update, the GoPiGo doesn’t drive forward straight, but it can go backwards straight without any problems.
Does the GoPiGo consistently lean in one direction? Are you using the PID commands to try to drive straight?
And secondly, I can’t make the US sensor test programs to work. I use a HC-SR04 as a US sensor, pretty much the same as the one used in the tutorial as far as I can tell. I checked the voltage of the pins of the A1 port directly with an oscilloscope, and there is no activity of any sort on 3 of the four pins. For the ground pin it is normal, for the other 2, I can’t see any commands of any kind (logic level is always 0). The Vcc pin is at a constant +5v.
I think there's a small difference on this sensor, I have to check. I think there are two standard US sensors that are usually used, I'm not sure which one the Seeed sensor is. I also think you will need to run some code to see any life out of the sensor pins; they don't turn on by themselves.
The US sensor is working just fine, I tested it with the PI on its one, imprecise but working.

Do you mean one of the sensors you bought from us here? That’s working ok?


#3

Hello,

Thanks for the answer.

The GoPiGo was indeed always leaning to the right with the PID command, but I found that it was that the motors, and more precisely the encoders, where not straight enough, so this problem is resolved.

I don’t have the US sensor from Dexter Industries, as I’m not the one who buys the equipment, the only one I have is the HC-SR04.

"The US sensor is working just fine, I tested it with the PI on its one, imprecise but working."
I made a typo, it should have been “on its own”, sorry.

What I meant here was that the sensor I have is working correctly, I tested it using a standard GPIO method directly with the Raspberry, without the GoPiGo board, it is very imprecise but it works fine.

If there is any difference between my sensor and the one normally used by the GoPiGo it might explain why there is no answer from the sensor, but I can’t find any technical data sheet (with the pin layout) about the Seeed sensor you are referring to.
I also can’t seem to find the electronic layout of the GoPiGo board by the way.

But there is another problem: if I run the example code “Ultrasonic Basic Obstacle Avoider”, or a modified version so that I ask the distance every second, I don’t see any electrical activity directly on the GoPiGo board. I have tested this code without the sensor connected to it, and I should be able to see at least the polling from the board to the sensor, but the only electrical activity I detect is Vcc at +5V, the other pins are at a constant 0V


#4

Hey Rob,
Glad to hear that the GoPiGo started moving properly for you.

Now coming to the ultrasonic sensor, the one that Seeed uses looks like a variant on the SR04, but we are not sure about the exact specs. The Seeed ultrasonic sensor uses only one Pin for both sending the ultrasonic pulse and receiving the signal back unlike the normal SR04 sensors. Also, on the GoPiGo we only have one digital Pin connected to the port on which the ultrasonic sensor is connected. We went with the Seeed ultrasonic sensor, because it gave us the best data when compared to other sensors and different batches of SR04 sensors too. I think using the SR04 directly with the Pi might be the best way for you to use it.

-Karan


#5

Hey Karan,

Oh OK, so there is a difference between the sensor, that explains why I have some issues.

Well using directly the Raspberry Pi with the US sensor is not very precise if I can’t access the Hardware timers. I have to write the code in Python, and the different threads of the OS and Python will mess around with the precise PWM inputs. That’s what I understood from the different forums I read at least: RPi is not very good with PWM input. So that why a Arduino board, or the GoPiGo board is necessary.

Another method could be that I modify the GoPiGo Firmware to make it compatible with my sensor. I look into the code on the github, and I think it won’t be that hard, I just need to know the addresses/number of the 4 pins of the A1 port.
I have no experience with Arduino programming unfortunately and I don’t know if it is really possible to do what I want, and how to update the GoPiGo board after my homemade modifications.

Rob


#6

Hey Rob,
The GoPiGo has an Atmega328 at it’s core which can be programmed. If you really want to use the ultrasonic sensor, then the pins available to you are: TX, RX (Digital 0,1) on the Serial Port, Pin A1 on the Analog Port, pin 10 on the Digital port and pin 5 on the Servo port. It’ll be better to use an Arduino to try to get the ultrasonic sensor to work using only these ports and then drop that code in the Firmware here: https://github.com/DexterInd/GoPiGo/blob/master/Firmware/fw_ver_13/fw_ver_13.ino#L600-616 .

I am not sure how good the performance would be with the SR04 sensor but do let us know how it goes if you try it.

-Karan