pd417
New Member
Posts: 5
|
Post by pd417 on Mar 14, 2015 8:29:59 GMT -8
My son and I just finished the PiBot, a fantastic experience, which he will be entering in his first STEM competition next week. He downloaded the object avoidance with LED program and ran it. All went well except for two things:
1. The robot seems to be moving fairly quickly. We need to slow it down, since it will be on a table for the expo. 2. Each time the robot encountered an object, it stopped and backed away, but it spun quickly in a circle 3-4 times before moving on. This doesn't seem right and this didn't happen in the build/demo video.
I realize these are reprogramming issues, but since my "C" is rusty, a step by step tutorial would be helpful.
Thanks.....
|
|
jasea
Junior Member
Posts: 53
|
Post by jasea on Mar 17, 2015 2:08:34 GMT -8
Hi pd417, I am glad that you both enjoyed building your Pi-Bot, but be carefull this high can be addictive! The problem with the speed of the Pi-Bot is values of two variables called speed1 and speed2. Open up the Arduino IDE and load the ObstacleAdvoidancewithLEDs sketch you will see some definitions at the beginning of the sketch "const int speed1 = 150;" and " const int speed2 = 150; "are the definitions that we are going to change. If you left mouse button click on the line then at the bottom left of the ID screen you should see the line number displayed , for speed1 this should be 22. The values for these can be from 0 (Stop) to 255 (Full speed), in practice I have found that a value below 70 does not produce enough motor power to move the Pi-Bot. So it is a case of reducing the these values to a point that you is slow enough for your table top course. Your second question is also related to the speed of the motors. Look at line 60 "if (distance > MaxDistance) " we have called the ping() routine to see if there is anything in our way, it returns the distance to any obstruction in the global variable "cm" which is the copied to variable distance. Now if the value of distance is greater than the definition for MaxDistance, defined one line above speed1, then we set green LED on and carry on going forwards. BUT, if the distance is less than MaxDistance we switch off Green LED switch on the RED led, then STOP wait for one tenth of a second, reverse for two seconds and then turn left for two seconds. You can see that the program uses time and not distance in these manoeuvres. So the distance reversed and the how far the Pi-Bot turns is governed by the values of speed1 and speed2. Also the values of the delay(2000) calls can be reduced to reduce the amount activity.
If I have not been clear then please repost any further questions.
I wish you the best of luck in your competition.
Regards
John
|
|
pd417
New Member
Posts: 5
|
Post by pd417 on Mar 17, 2015 8:24:14 GMT -8
John..
Thanks for the reply. I changed both speed values to 100 and this slowed it down enough to work on a tabletop. In changing the speed, the Pi-Bot stopped spinning 3-4 times and now will periodically make a 360 turn. This is fine and looks good for the demo.
If you don't mind, I have another question. When we ran the line following program, the Pi-Bot followed the line for about 12 inches then went wiggled left / right then went off course. We retested the sensors and they are functioning correctly. Could this also be a speed issue? If not, why is this happening?
Thx.....Paul
|
|
jasea
Junior Member
Posts: 53
|
Post by jasea on Mar 18, 2015 1:42:46 GMT -8
Hi Paul, Good to see that you both are winning, Now try and reduce the value in the delay(2000): call after the call to TurnLeft(speed1,speed2); at line 77 to see if you can get the Pi-Bot to turn just 90 or 180 degrees.
Remember that the PI-Bot is an educational tool, and the programs supplied are only sufficient to get some activity for the students, and their fathers. I would guess that the follow-on sessions from building the Pi-Bot will encourage the students to experiment and change and improve the basic programs.
I have not run the Line following program, my wife will not allow me to stick tape to her dinning table!!! I have had a look at the program, and there is plenty of scope for improvement. Why not try putting the Pi-Bot on jacks or a matchbox so the the driving wheels can turn freely. Now gat a piece of white cardboard wider than the Pi-Bot place under the sensor and check that when the black tape is under the centre sensor that both motors run and that when it is under one of the side sensors only the motor on the opposite side is running, again the way that motors have been wired up will effect which way the Pi-Bot will turn. Reducing the speed will slow down the rate that the PI-Bot turns and will help to keep it on course. An other possible problem could be a loose connection, try getting a constant reading whilst using the test card, and then just tapping the PI-Bot to see if anything changes.
Let me know how you get on.
John
|
|
pd417
New Member
Posts: 5
|
Post by pd417 on Mar 20, 2015 8:35:13 GMT -8
Hi John..
I think I'll try changing the speed values and see if that helps keep it on course. I'll let you know how it goes.
Thx,,,
Paul
|
|