Has anyone had problems with the cortex and the potentiometers? I’m trying to use a potentiometer with easyC for Cortex to measure a lifting arm. The readings I’m getting jump between ~2, ~64, and ~1021 (+/- 1), without any apparent readings in between, even when driven very slowly. Any ideas?
Have you Double Checked that the Potentiometer is plugged into the Port that your Code is reading?? The values your are getting seem like the Input is Floating… This could be a Software Issue, or a Hardware Issue.
Is this one of the Vex Potentiometers???
Have you tried a different Potentiometer to see if you get the same readings??
Have you tried a different Analog Port, and changed the Code to read that Port?
I have also seen Values like this when one side of the Voltage Divider is not connected to either Ground or 5 Volts (AKA Vcc). This could be caused by a Broken Wire or Bad Connection.
Have you done Trouble-Shooting with a Known Good device and an Unknown device??
I can not locate the resistance value of the Vex Potentiometer, but it is likely to be between 5K Ohms and 10K Ohms.
If you have a Known Good Potentiometer, use a Volt-Ohm Meter (VOM) to test the Resistance between the Black (Ground) and the Red (Power, AKA 5 Volts, AKA Vcc) pins, while it is NOT plugged into the Vex Controller. It will read some value, most likely between 5K Ohms and 10K Ohms.
Then, take the Unknown Potentiometer, use a Volt-Ohm Meter (VOM) to test the Resistance between the Black (Ground) and the Red (Power, AKA 5 Volts, AKA Vcc), while it is NOT plugged into the Vex Controller. It will read some value, which should be very close in value to the Known Good Potentiometer. (+/- 5% to 10%). If it is NOT close in value, wiggle wires, while checking the value, if it works some of the time, but not others, you might have a broken wire or loose connection.
You can take the Known Good Potentiometer and Test either the Black or the Red Pin and the White Pin. Have someone help turn the Potentiometer and watch the VOM. By turning the Known Good Potentiometer fully one direction, it should read 0 (Zero) Ohms, and fully the other direction it should read almost the the Value in Ohms you found between the Black and Red Pins.
SO, for example… If the Potentiometer reads 10K Ohms between the Black and Red Pins (I am guessing here, it might be a different value), you find that the VOM changes from, 0 (Zero) Ohms to 10K Ohms and back again as you move the Potentiometer from side to the other. If the VOM is reading 0 (Zero) Ohms between the Black and the White Pins, it should read 10K Ohms between the Red and the White Pins, if you don’t move the Potentiometer. And when you move the Potentiometer to the opposite end of it “sweep”, it should read 10K Ohms between the Black and the White Pins, and it should read 0 (Zero) Ohms between the Red and the White Pins.
When testing the Unknown Potentiometer, the same way, if it reads correctly between the White Pin and only ONE of the other Pins, that is side is connected correctly, the side that does not read correctly, has the Bad Connection, and it will be up to you to determine if you need to seek Warranty Repair, of if you will attempt to repair it yourself.
I’m pretty sure potentiometer we were using was not faulty, as I tested it with a different microcontroller and the readings were fine. We have been having the same problem with an optical shaft encoder - in other microcontrollers it works well, but with the cortex the readings jump. I will try different analog ports as soon as I can, and triple check my code. Thank you for your suggestions