Canada
Asked — Edited

4-In-1 Sensor Questions

I am attempting to get a 4-in-1 sensor to work as I need it to and not have much success - I need a hand. I am trying to get the 4- in-1 sensor to drive 2 servos to keep something level/plumb. I have the servos set to go up or down depending on the sensor readings. The problems I'm having are;

  1. It will kind of work for a short time but will only drive one servo at a time even if both should move,
  2. The Y axis stops working after a few minutes,
  3. Then everything stops working,
  4. For some reason the 'Sleep' command above the 'loop' is run each time and anything else put there -except the first line. I am running the sensor on a EZBv4/2. My code is a modified version of one from a JD project. Here's my code;

ControlCommand("MPU9150", Init)

sleep(1000)

:loop
#Added these because $AccelX and $AccelY were not recognized later in the script for some reason.
$XAccel = $AccelX
$YAccel = $AccelY

if ("x" =0)

print(1)  

sleep(2000)
  
goto(loop)
  
endif 
  
ControlCommand("MPU9150", RunOnce)

print("x: " + $XAccel)
print("y: " + $YAccel)

if ($XAccel > 1000)
ServoUp(D1,10)
Servospeed(D1,2)
 
ELSEif ($XAccel  < -1000)
ServoDown(D3,10)
Servospeed(D3,2)
Endif

if ($YAccel > 1000)
ServoUp(D3,10)
Servospeed(D3,2) 
  
ELSEif ($YAccel < -1000)
ServoDown(D3,10)
Servospeed(D3,2) 
Sleep(500)

endif  
sleep(1500)

goto(loop)

Has anyone played with these sensors much and got them working? I know I have a lot to learn about them so your assistance will be appreciated.
Thanks


ARC Pro

Upgrade to ARC Pro

ARC Pro is your gateway to a community of like-minded robot enthusiasts and professionals, all united by a passion for advanced robot programming.

PRO
USA
#9  

@bhouston:

Did you noticed the servo positions:


> D1: -225
> D1: -240
> D1: -255
> D1: -270
> D1: -285
> D1: -300
> D1: -315
> D1: -330
> D1: -345
> D1: -360
> D1: -375
> D1: -390
> D3: 150
> D3: 165
> D3: 180
> D3: 195
> D3: 210
> D3: 225
> D3: 240
> D3: 255
> D3: 270
> D3: 285
> D3: 300
> D3: 315

EZ-B Digital Port servo valid positions are 1-180. Q: The $1,000,000 question what should ARC do with -390 or a 256 value ? A: Nothing, Ignore => Stop working

You are using ServoUp, ServoDown functions to increment/decrement the position, when you get outside of 1-180 range, ARC ignores the value.

I believe you want track the absolute orientation not the relative orientation.

#10  

Thanks ptp, I noticed those numbers - didn't know what to make of them. Any advise on how to proceed? I want the sensor to move the servos so the sensor is back to level.

PRO
USA
#11  

Can you describe your setup, the IMU location and the relation with the servos.

some examples:

Control the servos manipulating the IMU similar to a mocap or kinect ? Detect motion (manual pushing or pulling the servos) ? Fall or equilibrium control ?

#12  

I will have the sensor centered on the top of the robot. The robot will start out in a level position, held by the two servos. These servos are then controlled by the 4-in-1 sensor. If the robot is put out of level, say by something going on below these servos, then the sensor would adjust the top of the robot back to a level position using the two servos. I hope that explains it OK.

PRO
USA
#13  

I'm familiar with the IMU9150, it's a cheap device easily sourced from Ebay china vendors, sometimes not the original chip but a clone with some glitches...

Also does not fit in the JD slot, so I order a 4-in-1 sensor to do a demo, it will take a few days to arrive, I'll come back later.

I don't believe you can get good results without a micro-processor processing the IMU data, before being sent to EZB.

most accelerometers are very sensitive, gyrometers drift, compass have noise, you can't rely on a single sensor, you need to query them multiple times per second, combine the sensors and apply a fusion algorithm to obtain "stable" values, this kind operations i.e. 100 times per second or more, can't be done on the PC (EZ-Builder).

So the solution needs an extra addon.

#14  

Thanks again ptp, It's interesting that it will run on servo OK but when the second one is added, the sensor can't handle it. I look forward to seeing what you come up with.

PRO
USA
#15  

@bhouston,

I don't think is related to more than one servo, i believe you can still use the sensor as it is...

The problem is the absolute vs relative values, maybe with some code tweaking you can keep track of the position.

#16  

I agree with @PTP... Put a conditional check on servo positions before ServoUp or ServoDown commands. This way it will only allow the servo to move as long as it doesn't try to move the servo out of it's 1 to 180 range...


if(GetServo(D1) > 15)
ServoDown(D1,15) # may have to be ServoUp depending on your servo's orientation
endif

#and/or

if(GetServo(D1) < 166)
ServoUp(D1,15) # may have to be ServoDown depending on your servo's orientation
endif