Program Questions: Reply Rly. Fast!!

How do you program the Optical Shaft Encoder & the Potentiometer’s? :confused::confused::confused:. If you could give us a test code with 230 ticks for the Shaft Encoder, that would be great.

Thanks:

Hey it’s me again. Could someone make a program where after 230 ticks, it stops moter 1???:confused::confused: That would be a bbiiiggg help to us.:):smiley:

Thanks:

something like this

Get Encoder1 to your variable (we will call it “Encoder” for now)
Start Encoder 1

If (encoder < 230)
Set PWM 1 to 255
Set PWM 2 to 255
Set PWM 3 to 255
Set PWM 4 to 255 (All of these set pwm’s will make the bot drive forward but i don’t know how your drive is set up so i just assumsed you are using 4 motor drive using ports 1, 2, 3 and 4)

Else
Set PWM 1 to 127
Set PWM 2 to 127
Set PWM 3 to 127
Set PWM 4 to 127 (This will stop the bot after 230 ticks of the encoder)

Just read your new post so you only need motor 1 to stop after 230 ticks.

that will look more like this

Get Encoder1 to your variable (we will call it “Encoder” for now)
Start Encoder 1

If (encoder < 230)
Set PWM 1 to 255
(This will drive motor 1 if the encoder returns a valuse less than 230 ticks)
Else
Set PWM 1 to 127
(This will stop the Motor after 230 ticks of the encoder)

Thx. Ill try it.

you can use the encoder block on the left of the easy C screen and it will pop up with a box asking you what you want to with options like GET, Start, Stop and Preset. Just remember to make a variable called something like “Encoder” where the micro controller can store the data. the encoder dialogue box will tell you what kind of variable you need to make it.

Hope this helps
~DK

I tried to do your program, but all it does is run the moter. Can you send me a picture of wat the program looks like???:confused::confused::confused:

i can’t post a picture right now but i have an idea try putting the get encoder button and start encoder into a while (1==1) loop and it think that should do it.

ill try. i was just customizing your old sofware.

sorry idid not see the “get” it the program.

Does it work now?

no i dont think so at all

sry. i did not have the program in the right motor num. changing to motor 2

do you have your variable defined? you need to make a variable which you can title yourself i suggest calling it something like “Encoder” then you need to tell the encoder to store its information there by using the “get” option.

I trid every thing and it still does not work. y cant you send me the pic.?:confused:

i don’t have my laptop on me right now.

alright here are some final ideas. toss everything within a while (1==1) loop

should i ask where is it and y cant you do it on the computer your on?

the computer i am using right now does not have easy c on it.

Why don’t you try something like this:

Please note that I do not know what programming language you are using, your motor setup, or your encoder setup. You’ll need to change the variable/motor ports/values to match your programming language. Also, depending on which way your shaft is rotating, the value might be either positive or negative.

Try this:
encoder = 0; // Reset the encoder

while (encoder < 230)
{
motor[port1] = 127;
}

motor[port1] = 0;

oh:rolleyes:
ok. when will you get your laptop back. cause i need the pictures by 5:00pm EST tommorow

Sunny were using EasyC V2:). Can you make a picture of what the program looks like, or do you not have easy c v2?:confused: