Quadrator Encoders not working properly

I tried this code to get my quadrator shaft encoders to work, but they won’t work. The code works if the encoders are not spun otherwise one of them have a higher value than the other and then you would have to spin it back to zero to get them to be equal to each other.

#pragma config(Sensor, dgtl1,  LQuadEnc,       sensorQuadEncoder)
#pragma config(Sensor, dgtl3,  RQuadEnc,       sensorQuadEncoder)
#pragma config(Motor,  port1,            ,             tmotorVex393_HBridge, openLoop, reversed)
#pragma config(Motor,  port10,           ,             tmotorVex393_HBridge, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
	SensorValue[dgtl1] = 0;
	SensorValue[dgtl3] = 0;
	while (1 == 1){
		if (SensorValue[dgtl1] < SensorValue[dgtl3]-30){
			motor[port1] = 50;
		else if (SensorValue[dgtl1] > SensorValue[dgtl3]+30){
			motor[port10] = 50;
			motor[port1] = 0;
			motor[port10] = 0;

I think this may be something to do with the firmware. The joystick’s joysticks channels are not correctly numbered and only 3 of the 4 channels work.

What firmware version for the vex cortex and joystick should I be using?

First off, please always surround your code in

 '/code] tags. (without the ' obviously, and you can access this with the </> button)

Second, what do you mean by work? Is your robot not behaving as expected? Make sure you understand the logic of your code fully. The nature of encoders is that they count ticks/rotation, meaning that yes, when you spin them they won't necessarily be the same. That's part of the logic with using PID.

When I spin the encoders the same amount, say 4 turns, by connecting them with an axle, then turn one way farther than the 30 tick range, one of the motors is supposed to stay on while the other stays off. However, during the initial turns, one of the motors turns on and when I turn the encoder either way past the 30 tick range, nothing happens. the motor stays on while the other stays off. To turn on the other motor and off the first, I have to turn the encoders back to the 0 tick start.

An also, what version of the cortex firmware am I supposed to have on the cortex?

preferably the latest. I suppose it doesn’t particularly matter though as long as the joystick/cortex are compatible firmware.

If I understand correctly (clarify if I’m wrong): you intend for this program to essentially make your robot drive in a straight line while adjusting for mechanical inaccuracy. Or maybe you want to just make it center itself. Either way… the logic to do this seems to be missing some steps. For instance, you are at no point stopping/slowing the other side motor when the inequality condition is met. You will need to add that. Also, if this is not just for forward, you’ll need to zero out encoders between operations.

However, if this is what you are trying to accomplish, I’d suggest you look at Master/Slave or PID or some such control instead. Bang-bang logic like this tends to be ineffective in the long run. You’ll probably have more inaccuracy then the natural drift of your drivetrain. See this: http://www.robotc.net/wikiarchive/Tutorials/Arduino_Projects/Mobile_Robotics/VEX/Using_encoders_to_drive_straight

Or maybe I’ve completely misinterpreted what you are trying to do and read into your post too much. LMK.

Yes, that perfectly helped me.

That would be “quadrature” not “quadrator.” HTH.