Welcome to the Parallax Discussion Forums, sign-up to participate.

Posts: 2
Hi everyone, I'm trying to figure out what is a basic code to test if the 36-position encoders I ordered from parallax work. However since i'm fairly new to coding, i'm struggling to understand how to do it. Anyone can help? Im using the green board of education.

Thanks

• Posts: 1,194
edited 2018-12-06 - 16:37:49
Hi

What you have is part of the Arlo robot.

Here is a linkto the robot.

You have to look in documentation for robot to find some code you can adapt.

https://www.parallax.com/news/2016-05-05/introducing-arlo-complete-robot-system-take-project-based-learning-next-stage-robot
• Posts: 1,452
This is PropBasic but it's self-explanatory and shows how the decode logic actually works.

Chan_A and Chan_B are constants for the inputs.

Just ignore the Wrlong stuff.

```
'Decide where to start
If Chan_A = 1 And
Chan_B = 1 Then
Goto A1B1
Endif

If Chan_A = 0 And
Chan_B = 0 Then
Goto A0B0
Endif

If Chan_A = 1 And
Chan_B = 0 Then
Goto A1B0
Endif

If Chan_A = 0 And
Chan_B = 1 Then
Goto A0B1
Endif

'Keep hopping between these labels

A1B1:
If Chan_A = 0 Then
Dec Counter
Wrlong HubCTR,Counter
Goto A0B1
Elseif Chan_B = 0 Then
Inc Counter
Wrlong HubCTR,Counter
Goto A1B0
Endif
Goto A1B1

A0B0:
If Chan_A = 1 Then
Dec Counter
Wrlong HubCTR,Counter
Goto A1B0
Elseif Chan_B = 1 Then
Inc Counter
Wrlong HubCTR,Counter
Goto A0B1
Endif
Goto A0B0

A1B0:
If Chan_A = 0 Then
Inc Counter
Wrlong HubCTR,Counter
Goto A0B0
Elseif Chan_B = 1 Then
Dec Counter
Wrlong HubCTR,Counter
Goto A1B1
Endif
Goto A1B0

A0B1:
If Chan_A = 1 Then
Inc Counter
Wrlong HubCTR,Counter
Goto A1B1
Elseif Chan_B = 0 Then
Dec Counter
Wrlong HubCTR,Counter
Goto A0B0
Endif
Goto A0B1
End
```
Failure is not an option...it's bundled with the software.
• Posts: 1,065
search "quadrature". There is tons of stuff on the forum.
Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.