I am currently having programming difficulties with the optical encoder. We are able to establish that it is counting through the test program but have not figured out how to reset the encoder at 0. It is arbitrarily starting at crazy numbers like 16,365 and 9,348. Does anyone have a basic code that will atleast help us get going in the right direction???..HELP!!!
umm, i think there is a preset encoder function which lets you set its value. or i guess you could use an assignment statement to set it. and the encoders have to be plugged into the interrupt ports, could that be messed up?
Which ‘C’, EasyC 1.x, 2.x, 3.x, or MPLAB???
Have you looked at the sample program, Vex Sensor Test, from the Vex Labs web page??
we are using easyC and we made sure to put them in the interrupt ports
Come on now - You don’t need a zillion exclamation points for a question whose answer appears to be right smack in front of you.
In one of my EasyC installations, I dragged an optical encoder icon into a “program”.
I then clicked on the “Preset” radio button EasyC displayed in the a pop-up window that appeared “on behalf” of the that icon.
When I did that, EasyC showed me a data entry field (in the pop-up window) into which I can enter the value at which I want the count to begin.
Does this solve your problem?
Blake
Are you using EasyC 2.x???
It appears that the sample program, Vex Sensor Test, from the Vex Labs web page is in MPLAB ‘C’, not EasyC and does not include support for the Optical Encode anyway??
The EasyC 2.x help says:
To see a sample program demonstrating how the Optical Shaft Encoder is used, open the ENCODERTEST.ECP Project located in the Test Code folder.
As for the “arbitrarily starting at crazy numbers like 16,365 and 9,348”, I would guess that you are not setting a Default Value (preset) for the Encoder.
The EasyC 2.x help says:
The preset option allows the user to set the encoder to a fixed value (like 25 in the example) or to the value of a variable.
Plus what 1885.blake said.
thanks guys…sorry i just kind of had a freak out moment
i just had set the encoders as an int variable instead of a float and the print to screen was just throwing it off somewhere…
The ENCODERTEST.SCP shows an int is used for the return value… Don’t forget to use the correct formatting in the Print to Screen statement.
i created a test real quick here it is
test.zip (860 Bytes)
Include your *.ECP file in the Zip as well… I created a new .ECP file from another, since the File Dialog Box is looking for the *.ECP files…
TEST.BCD plus TEST.ECP attached
StoneBot-001_test.zip (1.1 KB)