View Full Version : memsic 2125

05-21-2005, 12:02 PM
Hello, I have been trying to use the memsic 2125 on my boe bot. The idea was this. If the bot rode up onto something high on the left side, it would back up nad turn left, and the same for the opisit side, but turning right of course. So I wanted to start with some real basic values to just try it out at first. I ran the code found in the stamp in class pdh. Got a basic value for x and y on level ground, then I telted it to each side and got values for x and y. High on left, and high on right.
· Using the bs2px I got the following values..
··· on level ground x = 6060, y = 6060 aprox..
··· high on the left x=·5940 aprox, y= 6250
··· high on the right side x= 5905 y = 5750· (these are aprox values true within +/- 5 to 10).
· So I wrote some real basic code that went something like this...

·· x var word
·· y var word
·· x_y:
·· pulsin 6, 1, x
·· pulsin 7, 1, y
·· if (x < 5905 and y < 5750) then··· ' high on right..
·· gosub back_up
·· gosub left_turn
·· elseif (x <·5940 and y < 6250) then·· ' high on left
·· gosub back_up
·· gosub right_turn
·· gosub forward
·· pause 20··
·· endif
·· return

·· Keep in mide that this is just one routine within the prog.... called from main.·· Anyway my propblem is this. when the bot is high on the righ it works fine, but wont repond correct when high on the left... I have experimented with different values... with the same results... At the moment I am at a loss... If anyone can help , I would greatly appriciate it... thank you _Duane


Andy Lindsay (Parallax)
05-21-2005, 02:38 PM
Here is an example of some conditionals that might give you better results:
IF (x < 6000) THEN
· IF (y > 6150) AND (Y < 6350) THEN· ' high on left
··· ' code omitted here
· ELSEIF ( y < 5850) AND (y > 5650) THEN ' high on right
··· ' code omitted here
There's also another·activity on the Stamps in Class forum that might be useful:
· Boe-Bot® Robot Navigation with Accelerometer Incline Sensing (http://forums.parallax.com/showthread.php?p=522967)
One interesting thing I found while writing that article was that the MX2125 performs best when the accelerometer PULSIN commands come immediately after the servo PULSOUT commands.· My experience has been that if any kind of PAUSE command is inserted between the PULSOUT and PULSIN commands, the measurements become unreliable and the Boe-Bot's navigation goes haywire.·
Ramping into and out of maneuvers is also really important because abrupt changes in direction also cause unpredictable accelerometer readings.· There's some ramping code in that Stamps in Class activity that might come in handy after the pulse durations are updated for the BS2px.

Post Edited (Andy Lindsay (Parallax)) : 5/22/2005 8:04:35 PM GMT

05-21-2005, 11:28 PM
Thouse conditianals work far better than my sad code... thanks.. I'll be reading your artical latter today. Thanks very much _Duane